aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-07-06 19:47:06 -0700
committerAnton Tananaev <anton@traccar.org>2024-07-06 19:47:06 -0700
commit2005fd55347816cf4a86b66ae97bc245f53f0bcd (patch)
treea62fce83953b89530c968ef2c95828a80ff18cae /src/main/java/org/traccar/api
parentb8390005722dd1cdb24d762797ef3f98ebc37755 (diff)
downloadtrackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.tar.gz
trackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.tar.bz2
trackermap-server-2005fd55347816cf4a86b66ae97bc245f53f0bcd.zip
Update switch statements
Diffstat (limited to 'src/main/java/org/traccar/api')
-rw-r--r--src/main/java/org/traccar/api/resource/AttributeResource.java14
-rw-r--r--src/main/java/org/traccar/api/resource/DeviceResource.java22
2 files changed, 12 insertions, 24 deletions
diff --git a/src/main/java/org/traccar/api/resource/AttributeResource.java b/src/main/java/org/traccar/api/resource/AttributeResource.java
index 52c4d6324..8debb2e50 100644
--- a/src/main/java/org/traccar/api/resource/AttributeResource.java
+++ b/src/main/java/org/traccar/api/resource/AttributeResource.java
@@ -62,16 +62,10 @@ public class AttributeResource extends ExtendedObjectResource<Attribute> {
Object result = computedAttributesHandler.computeAttribute(entity, position);
if (result != null) {
- switch (entity.getType()) {
- case "number":
- Number numberValue = (Number) result;
- return Response.ok(numberValue).build();
- case "boolean":
- Boolean booleanValue = (Boolean) result;
- return Response.ok(booleanValue).build();
- default:
- return Response.ok(result.toString()).build();
- }
+ return switch (entity.getType()) {
+ case "number", "boolean" -> Response.ok(result).build();
+ default -> Response.ok(result.toString()).build();
+ };
} else {
return Response.noContent().build();
}
diff --git a/src/main/java/org/traccar/api/resource/DeviceResource.java b/src/main/java/org/traccar/api/resource/DeviceResource.java
index 61d96669e..4be8dbb12 100644
--- a/src/main/java/org/traccar/api/resource/DeviceResource.java
+++ b/src/main/java/org/traccar/api/resource/DeviceResource.java
@@ -174,20 +174,14 @@ public class DeviceResource extends BaseObjectResource<Device> {
}
private String imageExtension(String type) {
- switch (type) {
- case "image/jpeg":
- return "jpg";
- case "image/png":
- return "png";
- case "image/gif":
- return "gif";
- case "image/webp":
- return "webp";
- case "image/svg+xml":
- return "svg";
- default:
- throw new IllegalArgumentException("Unsupported image type");
- }
+ return switch (type) {
+ case "image/jpeg" -> "jpg";
+ case "image/png" -> "png";
+ case "image/gif" -> "gif";
+ case "image/webp" -> "webp";
+ case "image/svg+xml" -> "svg";
+ default -> throw new IllegalArgumentException("Unsupported image type");
+ };
}
@Path("{id}/image")