aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-07-06 17:46:17 -0700
committerAnton Tananaev <anton@traccar.org>2024-07-06 17:46:17 -0700
commitb8390005722dd1cdb24d762797ef3f98ebc37755 (patch)
treecaabf1a7541aebc4e81565e95ee78e2d8afe3d75 /src/main/java/org/traccar/protocol
parent75e3c6a6bbb028b2f99b06faac66d5b53cf59900 (diff)
downloadtrackermap-server-b8390005722dd1cdb24d762797ef3f98ebc37755.tar.gz
trackermap-server-b8390005722dd1cdb24d762797ef3f98ebc37755.tar.bz2
trackermap-server-b8390005722dd1cdb24d762797ef3f98ebc37755.zip
Update instanceof expressions
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java14
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java4
-rw-r--r--src/main/java/org/traccar/protocol/OutsafeProtocolDecoder.java8
-rw-r--r--src/main/java/org/traccar/protocol/T55ProtocolDecoder.java5
4 files changed, 15 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java b/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java
index ea076afd8..168b3b3cd 100644
--- a/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java
@@ -247,15 +247,15 @@ public class FlespiProtocolDecoder extends BaseHttpProtocolDecoder {
}
private void decodeUnknownParam(String name, JsonValue value, Position position) {
- if (value instanceof JsonNumber) {
- if (((JsonNumber) value).isIntegral()) {
- position.set(name, ((JsonNumber) value).longValue());
+ if (value instanceof JsonNumber jsonNumber) {
+ if (jsonNumber.isIntegral()) {
+ position.set(name, jsonNumber.longValue());
} else {
- position.set(name, ((JsonNumber) value).doubleValue());
+ position.set(name, jsonNumber.doubleValue());
}
- position.set(name, ((JsonNumber) value).doubleValue());
- } else if (value instanceof JsonString) {
- position.set(name, ((JsonString) value).getString());
+ position.set(name, jsonNumber.doubleValue());
+ } else if (value instanceof JsonString jsonString) {
+ position.set(name, jsonString.getString());
} else if (value == JsonValue.TRUE || value == JsonValue.FALSE) {
position.set(name, value == JsonValue.TRUE);
}
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 3afea3b1b..373e1c91c 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -1729,8 +1729,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
}
if (result != null) {
- if (result instanceof Position) {
- ((Position) result).set(Position.KEY_TYPE, type);
+ if (result instanceof Position position) {
+ position.set(Position.KEY_TYPE, type);
} else {
for (Position p : (List<Position>) result) {
p.set(Position.KEY_TYPE, type);
diff --git a/src/main/java/org/traccar/protocol/OutsafeProtocolDecoder.java b/src/main/java/org/traccar/protocol/OutsafeProtocolDecoder.java
index f71778412..0a6026d91 100644
--- a/src/main/java/org/traccar/protocol/OutsafeProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/OutsafeProtocolDecoder.java
@@ -77,10 +77,10 @@ public class OutsafeProtocolDecoder extends BaseHttpProtocolDecoder {
}
private void decodeUnknownParam(String name, JsonValue value, Position position) {
- if (value instanceof JsonNumber) {
- position.set(name, ((JsonNumber) value).doubleValue());
- } else if (value instanceof JsonString) {
- position.set(name, ((JsonString) value).getString());
+ if (value instanceof JsonNumber jsonNumber) {
+ position.set(name, jsonNumber.doubleValue());
+ } else if (value instanceof JsonString jsonString) {
+ position.set(name, jsonString.getString());
} else if (value == JsonValue.TRUE || value == JsonValue.FALSE) {
position.set(name, value == JsonValue.TRUE);
}
diff --git a/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java b/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
index 9e7518ce5..2538c914d 100644
--- a/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/T55ProtocolDecoder.java
@@ -420,9 +420,8 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
sentence = sentence.substring(index);
} else {
deviceSession = getDeviceSession(channel, remoteAddress);
- if (deviceSession == null && remoteAddress instanceof InetSocketAddress) {
- String host = ((InetSocketAddress) remoteAddress).getHostString();
- deviceSession = getDeviceSession(channel, remoteAddress, host);
+ if (deviceSession == null && remoteAddress instanceof InetSocketAddress inetSocketAddress) {
+ deviceSession = getDeviceSession(channel, remoteAddress, inetSocketAddress.getHostString());
}
}