diff --git a/action-node/src/main/java/me/retrodaredevil/action/node/expression/result/SimpleNumericExpressionResult.java b/action-node/src/main/java/me/retrodaredevil/action/node/expression/result/SimpleNumericExpressionResult.java index a8a5d70e..6a81dac5 100644 --- a/action-node/src/main/java/me/retrodaredevil/action/node/expression/result/SimpleNumericExpressionResult.java +++ b/action-node/src/main/java/me/retrodaredevil/action/node/expression/result/SimpleNumericExpressionResult.java @@ -1,7 +1,5 @@ package me.retrodaredevil.action.node.expression.result; -import java.util.Objects; - import static java.util.Objects.requireNonNull; final class SimpleNumericExpressionResult implements NumericExpressionResult { @@ -27,6 +25,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(number.doubleValue()); + return Double.hashCode(number.doubleValue()); } } diff --git a/server/src/main/java/me/retrodaredevil/solarthing/rest/database/InMemoryReplicatorConfig.java b/server/src/main/java/me/retrodaredevil/solarthing/rest/database/InMemoryReplicatorConfig.java index 970d8372..6a633153 100644 --- a/server/src/main/java/me/retrodaredevil/solarthing/rest/database/InMemoryReplicatorConfig.java +++ b/server/src/main/java/me/retrodaredevil/solarthing/rest/database/InMemoryReplicatorConfig.java @@ -65,16 +65,16 @@ public String getDocumentId() { /** * @param inMemoryCouch The {@link CouchProperties} the in memory database can use to refer to itself. {@link CouchProperties#getUri()} should be a localhost address. * @param externalCouch The external {@link CouchProperties} the in memory database can use to refer to the external database. - * @return + * @return A {@link SimpleReplicatorDocument.Builder} that has the source/target set automatically based on {@link #externalIsTarget} */ public SimpleReplicatorDocument.Builder createDocumentBuilder(CouchProperties inMemoryCouch, CouchProperties externalCouch) { ReplicatorSource inMemoryDatabase = createSource(inMemoryCouch, databaseType.getName()); ReplicatorSource externalDatabase = createSource(externalCouch, databaseType.getName()); - SimpleReplicatorDocument.Builder builder = SimpleReplicatorDocument.builder( - externalIsTarget ? inMemoryDatabase : externalDatabase, - externalIsTarget ? externalDatabase : inMemoryDatabase - ); + SimpleReplicatorDocument.Builder builder = SimpleReplicatorDocument.builder( + externalIsTarget ? inMemoryDatabase : externalDatabase, + externalIsTarget ? externalDatabase : inMemoryDatabase + ); // do not make it continuous if we are replication a certain duration. // I have found that if you do make it continuous, the replication will remain triggered, which will not allow it to be updated if (duplicatePastDuration == null) { diff --git a/server/src/main/java/me/retrodaredevil/solarthing/rest/graphql/SolarThingGraphQLExtensions.java b/server/src/main/java/me/retrodaredevil/solarthing/rest/graphql/SolarThingGraphQLExtensions.java index d3ce9ff8..ce22489e 100644 --- a/server/src/main/java/me/retrodaredevil/solarthing/rest/graphql/SolarThingGraphQLExtensions.java +++ b/server/src/main/java/me/retrodaredevil/solarthing/rest/graphql/SolarThingGraphQLExtensions.java @@ -68,11 +68,11 @@ public float getControllerTemperatureFahrenheit(@GraphQLContext TracerStatusPack return "" + identifiable.getDataId(); } @GraphQLQuery - public @NotNull boolean isActive(@GraphQLContext ActivePeriod activePeriod, @GraphQLArgument(name = "dateMillis") long dateMillis) { + public boolean isActive(@GraphQLContext ActivePeriod activePeriod, @GraphQLArgument(name = "dateMillis") long dateMillis) { return activePeriod.isActive(dateMillis); } @GraphQLQuery - public @NotNull boolean isActiveNow(@GraphQLContext ActivePeriod activePeriod) { + public boolean isActiveNow(@GraphQLContext ActivePeriod activePeriod) { return activePeriod.isActive(Instant.now()); } } diff --git a/server/src/main/java/me/retrodaredevil/solarthing/rest/graphql/service/SolarThingGraphQLService.java b/server/src/main/java/me/retrodaredevil/solarthing/rest/graphql/service/SolarThingGraphQLService.java index 639141d2..ad92cb2d 100644 --- a/server/src/main/java/me/retrodaredevil/solarthing/rest/graphql/service/SolarThingGraphQLService.java +++ b/server/src/main/java/me/retrodaredevil/solarthing/rest/graphql/service/SolarThingGraphQLService.java @@ -232,10 +232,9 @@ public SolarThingStatusQuery(PacketGetter packetGetter, List extends Fragmente MetaDatabase metaDatabase = simpleQueryHandler.queryMeta(); FXChargingTemperatureAdjustPacket fxChargingTemperatureAdjustPacket = null; // Depending on the date, there could be different configurations. So, this just gets the date of the last packet - long currentConfigurationDateMillis = sortedPackets.get(sortedPackets.size() - 1).getDateMillis(); + long currentConfigurationDateMillis = sortedPackets.getLast().getDateMillis(); for (BasicMetaPacket basicMetaPacket : metaDatabase.getMeta(currentConfigurationDateMillis)) { - if (basicMetaPacket instanceof TargetMetaPacket) { - TargetMetaPacket targetMetaPacket = (TargetMetaPacket) basicMetaPacket; + if (basicMetaPacket instanceof TargetMetaPacket targetMetaPacket) { for (TargetedMetaPacket targetedMetaPacket : targetMetaPacket.getPackets()) { if (targetedMetaPacket.getPacketType() == TargetedMetaPacketType.FX_CHARGING_TEMPERATURE_ADJUST) { fxChargingTemperatureAdjustPacket = (FXChargingTemperatureAdjustPacket) targetedMetaPacket; @@ -280,8 +279,7 @@ public SolarThingStatusQuery(PacketGetter packetGetter, List extends Fragmente float sum = 0; int count = 0; for (Packet packet : packetGroup.getPackets()) { - if (packet instanceof BatteryVoltage) { - BatteryVoltage batteryVoltagePacket = (BatteryVoltage) packet; + if (packet instanceof BatteryVoltage batteryVoltagePacket) { float batteryVoltage = batteryVoltagePacket.getBatteryVoltage(); sum += batteryVoltage; count++; diff --git a/server/src/main/java/me/retrodaredevil/solarthing/rest/spring/NioPathPropertyEditorSupport.java b/server/src/main/java/me/retrodaredevil/solarthing/rest/spring/NioPathPropertyEditorSupport.java index 932b1742..9fe541de 100644 --- a/server/src/main/java/me/retrodaredevil/solarthing/rest/spring/NioPathPropertyEditorSupport.java +++ b/server/src/main/java/me/retrodaredevil/solarthing/rest/spring/NioPathPropertyEditorSupport.java @@ -3,6 +3,15 @@ import java.beans.PropertyEditorSupport; import java.nio.file.Path; +/** + * This class allows spring configuration to read in string values as {@link Path}s. For example: + *
+ * {@code + * @Value("${solarthing.config.database}") + * private Path databaseFile; + * } + *+ */ public class NioPathPropertyEditorSupport extends PropertyEditorSupport { @Override public String getAsText() { @@ -11,7 +20,7 @@ public String getAsText() { } @Override - public void setAsText(String text) throws IllegalArgumentException { + public void setAsText(String text) { setValue(Path.of(text)); } }