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 1 commit
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);
}
}
}
Loading