add inheritance

This commit is contained in:
dancingCycle 2023-02-01 22:08:08 +01:00
parent b2671d2421
commit 072298f9d7
5 changed files with 13 additions and 13 deletions

View File

@ -7,7 +7,7 @@
<groupId>de.swingbe.ifleet</groupId> <groupId>de.swingbe.ifleet</groupId>
<artifactId>irt-parser</artifactId> <artifactId>irt-parser</artifactId>
<version>1.0.0</version> <version>1.1.0</version>
<description> <description>
IVU radio telegram parser. IVU radio telegram parser.

View File

@ -2,13 +2,13 @@ package de.swingbe.ifleet.model;
import java.util.Objects; import java.util.Objects;
public class LctMsg extends TelegrCntnt{ public class TcLctMsg extends TelegrCntnt{
private final Position position; private final Position position;
private final String driverNumber; private final String driverNumber;
private final Trip trip; 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); super(type);
this.position = position; this.position = position;
this.driverNumber = driverNumber; this.driverNumber = driverNumber;
@ -36,7 +36,7 @@ public class LctMsg extends TelegrCntnt{
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; 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); return position.equals(that.position) && driverNumber.equals(that.driverNumber) && trip.equals(that.trip);
} }

View File

@ -1,18 +1,18 @@
package de.swingbe.ifleet.parser; 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 { 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 type the telegram type
* @param input the {@link String} to be parsed * @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);
} }

View File

@ -1,6 +1,6 @@
package de.swingbe.ifleet.parser; package de.swingbe.ifleet.parser;
import de.swingbe.ifleet.model.LctMsg; import de.swingbe.ifleet.model.TcLctMsg;
import de.swingbe.ifleet.model.Position; import de.swingbe.ifleet.model.Position;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -13,7 +13,7 @@ class LctMsgParserImpl implements LctMsgParser {
public final static int DRIVER_NO_FIELD_NO = 1; 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); LOG.debug("parse() type: " + type);
//parse position //parse position
@ -31,6 +31,6 @@ class LctMsgParserImpl implements LctMsgParser {
//parse trip //parse trip
inputNew = popField(inputNew, DRIVER_NO_FIELD_NO); 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));
} }
} }

View File

@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
class TelegrParserImplTest { 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 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); private final Enty eFromStrSendLctMsg = EntyParserFactory.createEntyParser().parse(strSendLctMsg);