refractor: lint

This commit is contained in:
js0ny 2025-11-22 23:47:00 +00:00
parent aa9a870e94
commit 9fbc2f3a14
2 changed files with 14 additions and 12 deletions

View file

@ -89,8 +89,8 @@ public class DroneController {
} }
@PostMapping("/queryAvailableDrones") @PostMapping("/queryAvailableDrones")
public int[] queryAvailableDrones(@RequestBody MedDispathRecDto[] records) { public String[] queryAvailableDrones(@RequestBody MedDispathRecDto[] records) {
return new int[] {}; return droneService.dronesMatchesRequirements(records);
} }
@PostMapping("/calcDeliveryPath") @PostMapping("/calcDeliveryPath")

View file

@ -2,6 +2,7 @@ package io.github.js0ny.ilp_coursework.service;
import io.github.js0ny.ilp_coursework.data.AttrComparatorDto; import io.github.js0ny.ilp_coursework.data.AttrComparatorDto;
import io.github.js0ny.ilp_coursework.data.DroneDto; import io.github.js0ny.ilp_coursework.data.DroneDto;
import io.github.js0ny.ilp_coursework.data.MedDispathRecDto;
import io.github.js0ny.ilp_coursework.util.AttrOperator; import io.github.js0ny.ilp_coursework.util.AttrOperator;
import static io.github.js0ny.ilp_coursework.util.AttrComparator.isValueMatched; import static io.github.js0ny.ilp_coursework.util.AttrComparator.isValueMatched;
@ -48,7 +49,7 @@ public class DroneInfoService {
* *
* @param state determines the capability filtering * @param state determines the capability filtering
* @return if {@code state} is true, return ids of drones with cooling * @return if {@code state} is true, return ids of drones with cooling
* capability, else without cooling * capability, else without cooling
* @see io.github.js0ny.ilp_coursework.controller.DroneController#getDronesWithCoolingCapability(boolean) * @see io.github.js0ny.ilp_coursework.controller.DroneController#getDronesWithCoolingCapability(boolean)
*/ */
public String[] dronesWithCooling(boolean state) { public String[] dronesWithCooling(boolean state) {
@ -58,7 +59,7 @@ public class DroneInfoService {
DroneDto[].class); DroneDto[].class);
if (drones == null) { if (drones == null) {
return new String[]{}; return new String[] {};
} }
return Arrays.stream(drones) return Arrays.stream(drones)
@ -119,7 +120,8 @@ public class DroneInfoService {
} }
/** /**
* Return an array of ids of drones which matches all given complex comparing rules * Return an array of ids of drones which matches all given complex comparing
* rules
* *
* @param attrComparators The filter rule with Name, Value and Operator * @param attrComparators The filter rule with Name, Value and Operator
* @return array of drone ids that matches all rules * @return array of drone ids that matches all rules
@ -139,7 +141,7 @@ public class DroneInfoService {
} }
} }
if (matchingDroneIds == null) { if (matchingDroneIds == null) {
return new String[]{}; return new String[] {};
} }
return matchingDroneIds.toArray(String[]::new); return matchingDroneIds.toArray(String[]::new);
} }
@ -155,10 +157,10 @@ public class DroneInfoService {
* @param attrVal the attribute value to filter on * @param attrVal the attribute value to filter on
* @param op the comparison operator * @param op the comparison operator
* @return array of drone ids matching the attribute name and value (filtered by * @return array of drone ids matching the attribute name and value (filtered by
* {@code op}) * {@code op})
* @see io.github.js0ny.ilp_coursework.util.AttrComparator#isValueMatched(JsonNode, * @see io.github.js0ny.ilp_coursework.util.AttrComparator#isValueMatched(JsonNode,
* String, * String,
* AttrOperator) * AttrOperator)
*/ */
private String[] dronesWithAttributeCompared(String attrName, String attrVal, AttrOperator op) { private String[] dronesWithAttributeCompared(String attrName, String attrVal, AttrOperator op) {
URI droneUrl = URI.create(baseUrl).resolve(dronesEndpoint); URI droneUrl = URI.create(baseUrl).resolve(dronesEndpoint);
@ -168,7 +170,7 @@ public class DroneInfoService {
DroneDto[].class); DroneDto[].class);
if (drones == null) { if (drones == null) {
return new String[]{}; return new String[] {};
} }
// Use Jackson's ObjectMapper to convert DroneDto to JsonNode for dynamic // Use Jackson's ObjectMapper to convert DroneDto to JsonNode for dynamic
@ -190,7 +192,7 @@ public class DroneInfoService {
.toArray(String[]::new); .toArray(String[]::new);
} }
public int[] dronesMatchesRequirements() { public String[] dronesMatchesRequirements(MedDispathRecDto[] rec) {
return new int[]{}; return new String[] {};
} }
} }