add inheritance
This commit is contained in:
parent
b2671d2421
commit
072298f9d7
2
pom.xml
2
pom.xml
|
@ -7,7 +7,7 @@
|
|||
|
||||
<groupId>de.swingbe.ifleet</groupId>
|
||||
<artifactId>irt-parser</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.1.0</version>
|
||||
|
||||
<description>
|
||||
IVU radio telegram parser.
|
||||
|
|
|
@ -2,13 +2,13 @@ package de.swingbe.ifleet.model;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
public class LctMsg extends TelegrCntnt{
|
||||
public class TcLctMsg extends TelegrCntnt{
|
||||
|
||||
private final Position position;
|
||||
private final String driverNumber;
|
||||
private final Trip trip;
|
||||
|
||||
public LctMsg(final String type, final Position position, final String driverNumber, final Trip trip) {
|
||||
public TcLctMsg(final String type, final Position position, final String driverNumber, final Trip trip) {
|
||||
super(type);
|
||||
this.position = position;
|
||||
this.driverNumber = driverNumber;
|
||||
|
@ -36,7 +36,7 @@ public class LctMsg extends TelegrCntnt{
|
|||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
LctMsg that = (LctMsg) o;
|
||||
TcLctMsg that = (TcLctMsg) o;
|
||||
return position.equals(that.position) && driverNumber.equals(that.driverNumber) && trip.equals(that.trip);
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
package de.swingbe.ifleet.parser;
|
||||
|
||||
import de.swingbe.ifleet.model.LctMsg;
|
||||
import de.swingbe.ifleet.model.TcLctMsg;
|
||||
|
||||
/**
|
||||
* Parses a {@link LctMsg}.
|
||||
* Parses a {@link TcLctMsg}.
|
||||
*/
|
||||
interface LctMsgParser {
|
||||
|
||||
/**
|
||||
* Returns a new {@link LctMsg} that holds the parses fields.
|
||||
* Returns a new {@link TcLctMsg} that holds the parses fields.
|
||||
*
|
||||
* @param type the telegram type
|
||||
* @param input the {@link String} to be parsed
|
||||
* @return the parsed {@link LctMsg}
|
||||
* @return the parsed {@link TcLctMsg}
|
||||
*/
|
||||
LctMsg parse(final String type, final String input);
|
||||
TcLctMsg parse(final String type, final String input);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.swingbe.ifleet.parser;
|
||||
|
||||
import de.swingbe.ifleet.model.LctMsg;
|
||||
import de.swingbe.ifleet.model.TcLctMsg;
|
||||
import de.swingbe.ifleet.model.Position;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -13,7 +13,7 @@ class LctMsgParserImpl implements LctMsgParser {
|
|||
|
||||
public final static int DRIVER_NO_FIELD_NO = 1;
|
||||
|
||||
public LctMsg parse(final String type, final String input) {
|
||||
public TcLctMsg parse(final String type, final String input) {
|
||||
LOG.debug("parse() type: " + type);
|
||||
|
||||
//parse position
|
||||
|
@ -31,6 +31,6 @@ class LctMsgParserImpl implements LctMsgParser {
|
|||
|
||||
//parse trip
|
||||
inputNew = popField(inputNew, DRIVER_NO_FIELD_NO);
|
||||
return new LctMsg(type, position, driverNo, TripParserFactory.createTripParser().parse(inputNew));
|
||||
return new TcLctMsg(type, position, driverNo, TripParserFactory.createTripParser().parse(inputNew));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
class TelegrParserImplTest {
|
||||
|
||||
private final Enty eSendLctMsg = new Enty("2021-11-30", "11:24:13,438", "INFO", "BON", "195.30.103.89:58713", "(NpmTCPAcceptedChannel)", "(195.30.103.89:58713)", "sent", new Comm(new Header(new Sender("I", "WOL/234"), new Receiver("B", "")), new Telegr(new TelegramHdr("1", "1.8", "1"), new LctMsg("1", new Position("1501303H", "280", "87263783", "529019052", "0", "420", "162"), "29", new Trip("711", "1101", "1101099", "", "452", "0", "2", "2")))));
|
||||
private final Enty eSendLctMsg = new Enty("2021-11-30", "11:24:13,438", "INFO", "BON", "195.30.103.89:58713", "(NpmTCPAcceptedChannel)", "(195.30.103.89:58713)", "sent", new Comm(new Header(new Sender("I", "WOL/234"), new Receiver("B", "")), new Telegr(new TelegramHdr("1", "1.8", "1"), new TcLctMsg("1", new Position("1501303H", "280", "87263783", "529019052", "0", "420", "162"), "29", new Trip("711", "1101", "1101099", "", "452", "0", "2", "2")))));
|
||||
private final String strSendLctMsg = "2021-11-30 11:24:13,438 INFO [BON /195.30.103.89:58713] (NpmTCPAcceptedChannel) (/195.30.103.89:58713) sent <I#WOL/234#B##1#1.8#1#1501303H#280#87263783#529019052#0#420#162#29#711#1101#1101099##452#0#2#37500#0#6.>";
|
||||
private final Enty eFromStrSendLctMsg = EntyParserFactory.createEntyParser().parse(strSendLctMsg);
|
||||
|
||||
|
|
Loading…
Reference in New Issue