Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change of LocalVariableCouldBeFinal #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public final void sentenceRead(AISSentence sentence) {
if (sentence.isLastFragment()) {
AISSentence[] sentences = queue.toArray(new AISSentence[queue.size()]);
try {
AISMessage message = factory.create(sentences);
final AISMessage message = factory.create(sentences);
if (messageType.isAssignableFrom(message.getClass())) {
onMessage((T) message);
}
Expand Down Expand Up @@ -145,4 +145,4 @@ public void readingStarted() {
@Override
public void readingStopped() {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class AISListenerExample extends AbstractAISMessageListener<AISMessage01>
public AISListenerExample(File file) throws IOException {

// create sentence reader and provide input stream
InputStream stream = new FileInputStream(file);
final InputStream stream = new FileInputStream(file);
reader = new SentenceReader(stream);

// listen for for all AIS VDM messages
Expand Down Expand Up @@ -89,4 +89,4 @@ public static void main(String[] args) {
System.exit(1);
}
}
}
}
10 changes: 5 additions & 5 deletions src/main/java/net/sf/marineapi/nmea/io/AbstractDataReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ boolean isRunning() {
*/
public void run() {

ActivityMonitor monitor = new ActivityMonitor(parent);
SentenceFactory factory = SentenceFactory.getInstance();
final ActivityMonitor monitor = new ActivityMonitor(parent);
final SentenceFactory factory = SentenceFactory.getInstance();

while (isRunning) {
try {
String data = read();
final String data = read();
if (data == null) {
Thread.sleep(SLEEP_TIME);
} else if (SentenceValidator.isValid(data)) {
monitor.refresh();
Sentence s = factory.createParser(data);
final Sentence s = factory.createParser(data);
parent.fireSentenceEvent(s);
} else if (!SentenceValidator.isSentence(data)) {
parent.fireDataEvent(data);
Expand All @@ -151,4 +151,4 @@ public void run() {
public void stop() {
isRunning = false;
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/net/sf/marineapi/nmea/io/ActivityMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public void refresh() {
*/
public void tick() {
if (lastUpdated > 0) {
long elapsed = System.currentTimeMillis() - lastUpdated;
int timeout = parent.getPauseTimeout();
final long elapsed = System.currentTimeMillis() - lastUpdated;
final int timeout = parent.getPauseTimeout();
if (elapsed >= timeout) {
parent.fireReadingPaused();
reset();
}
}
}
}
}
16 changes: 8 additions & 8 deletions src/main/java/net/sf/marineapi/util/GenericTypeResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private GenericTypeResolver() { }
* at runtime.
*/
public static Class<?> resolve(Class<?> child, Class<?> parent) {
Type t = resolve(child, parent, new HashMap<>());
final Type t = resolve(child, parent, new HashMap<>());
if (t == null || t instanceof TypeVariable) {
throw new IllegalStateException("Cannot resolve generic type <T>, use constructor with Class<T> param.");
}
Expand All @@ -71,18 +71,18 @@ public static Class<?> resolve(Class<?> child, Class<?> parent) {
private static Type resolve(Class<?> child, final Class<?> parent,
final Map<TypeVariable<?>, Type> types) {

Type superClass = child.getGenericSuperclass();
final Type superClass = child.getGenericSuperclass();

if (superClass instanceof ParameterizedType) {

ParameterizedType pt = (ParameterizedType) superClass;
Class<?> rawType = (Class<?>) pt.getRawType();
TypeVariable<?>[] typeParams = rawType.getTypeParameters();
Type[] typeArgs = pt.getActualTypeArguments();
final ParameterizedType pt = (ParameterizedType) superClass;
final Class<?> rawType = (Class<?>) pt.getRawType();
final TypeVariable<?>[] typeParams = rawType.getTypeParameters();
final Type[] typeArgs = pt.getActualTypeArguments();

for (int i = 0; i < typeParams.length; i++) {
if (typeArgs[i] instanceof TypeVariable) {
TypeVariable<?> arg = (TypeVariable<?>) typeArgs[i];
final TypeVariable<?> arg = (TypeVariable<?>) typeArgs[i];
types.put(typeParams[i], types.getOrDefault(arg, arg));
} else {
types.put(typeParams[i], typeArgs[i]);
Expand All @@ -98,4 +98,4 @@ private static Type resolve(Class<?> child, final Class<?> parent,

return resolve((Class<?>) superClass, parent, types);
}
}
}
10 changes: 7 additions & 3 deletions src/test/java/net/sf/marineapi/ais/parser/AISMessage04Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
* Expected values based on http://www.maritec.co.za/tools/aisvdmvdodecoding/
*/
public class AISMessage04Test {

// !AIVDM,1,1,,A,400TcdiuiT7VDR>3nIfr6>i00000,0*78
// !AIVDM,1,1,,A,400TcdiuiT7VDR>3nIfr6>i00000,0*78
private final String payload = "400TcdiuiT7VDR>3nIfr6>i00000";
private final Sixbit sixbit = new Sixbit(payload, 0);
private final AISMessage04 msg = new AISMessage04Parser(sixbit);



public AISMessage04Test() {

}

@Test
public void getUtcYear() throws Exception {
assertEquals(2012, msg.getUtcYear());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public class AISMessage21ParserTest {
private final String payload = "E1c2;q@b44ah4ah0h:2ab@70VRpU<Bgpm4:gP50HH`Th`QF51CQ1A83PCAH0";
private final Sixbit sixbit = new Sixbit(payload, 0);
private final AISMessage21 msg = new AISMessage21Parser(sixbit);

public AISMessage21ParserTest() {

}

@Test
public void getAidType() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public class AISMessage27ParserTest {
private final String payload = "Kk:qFP0?fhT8=7m@";
private final Sixbit sixbit = new Sixbit(payload, 0);
private final AISMessage27 message = new AisMessage27Parser(sixbit);


public AISMessage27ParserTest() {

}
@Test
public void getRepeatIndicator() {
assertEquals(3, message.getRepeatIndicator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ public class AISMessageFactoryTest {
private String s1 = "!AIVDM,1,1,,A,13aEOK?P00PD2wVMdLDRhgvL289?,0*26";
private String s2_1 = "!AIVDM,2,1,9,B,53nFBv01SJ<thHp6220H4heHTf2222222222221?50:454o<`9QSlUDp,0*09";
private String s2_2 = "!AIVDM,2,2,9,B,888888888888880,2*2E";


private final AISSentence single = (AISSentence) sf.createParser(s1);
private final AISSentence split1 = (AISSentence) sf.createParser(s2_1);
private final AISSentence split2 = (AISSentence) sf.createParser(s2_2);

public AISMessageFactoryTest() {

}

@Test
public void testCreate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public class AISPositionReportParserTest {
private final String payload = "13u?etPv2;0n:dDPwUM1U1Cb069D";
private final Sixbit sixbit = new Sixbit(payload, 0);
private final AISPositionReport msg = new AISPositionReportParser(sixbit);

public AISPositionReportParserTest() {

}

@Test
public void getNavigationalStatus() throws Exception {
Expand Down