diff options
author | Anton Tananaev <anton@traccar.org> | 2024-07-06 17:46:17 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-07-06 17:46:17 -0700 |
commit | b8390005722dd1cdb24d762797ef3f98ebc37755 (patch) | |
tree | caabf1a7541aebc4e81565e95ee78e2d8afe3d75 /src/main/java/org/traccar/model | |
parent | 75e3c6a6bbb028b2f99b06faac66d5b53cf59900 (diff) | |
download | trackermap-server-b8390005722dd1cdb24d762797ef3f98ebc37755.tar.gz trackermap-server-b8390005722dd1cdb24d762797ef3f98ebc37755.tar.bz2 trackermap-server-b8390005722dd1cdb24d762797ef3f98ebc37755.zip |
Update instanceof expressions
Diffstat (limited to 'src/main/java/org/traccar/model')
-rw-r--r-- | src/main/java/org/traccar/model/ExtendedModel.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/model/ExtendedModel.java b/src/main/java/org/traccar/model/ExtendedModel.java index d5cd094da..f1183e11a 100644 --- a/src/main/java/org/traccar/model/ExtendedModel.java +++ b/src/main/java/org/traccar/model/ExtendedModel.java @@ -105,8 +105,8 @@ public class ExtendedModel extends BaseModel { public double getDouble(String key) { if (attributes.containsKey(key)) { Object value = attributes.get(key); - if (value instanceof Number) { - return ((Number) attributes.get(key)).doubleValue(); + if (value instanceof Number numberValue) { + return numberValue.doubleValue(); } else { return Double.parseDouble(value.toString()); } @@ -118,8 +118,8 @@ public class ExtendedModel extends BaseModel { public boolean getBoolean(String key) { if (attributes.containsKey(key)) { Object value = attributes.get(key); - if (value instanceof Boolean) { - return (Boolean) attributes.get(key); + if (value instanceof Boolean booleanValue) { + return booleanValue; } else { return Boolean.parseBoolean(value.toString()); } @@ -131,8 +131,8 @@ public class ExtendedModel extends BaseModel { public int getInteger(String key) { if (attributes.containsKey(key)) { Object value = attributes.get(key); - if (value instanceof Number) { - return ((Number) attributes.get(key)).intValue(); + if (value instanceof Number numberValue) { + return numberValue.intValue(); } else { return Integer.parseInt(value.toString()); } @@ -144,8 +144,8 @@ public class ExtendedModel extends BaseModel { public long getLong(String key) { if (attributes.containsKey(key)) { Object value = attributes.get(key); - if (value instanceof Number) { - return ((Number) attributes.get(key)).longValue(); + if (value instanceof Number numberValue) { + return numberValue.longValue(); } else { return Long.parseLong(value.toString()); } |