Skip to content

Commit

Permalink
Fixed some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
retrodaredevil committed Dec 18, 2024
1 parent 038142f commit 7d04d38
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -27,6 +25,6 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hashCode(number.doubleValue());
return Double.hashCode(number.doubleValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* <pre>
* {@code
* @Value("${solarthing.config.database}")
* private Path databaseFile;
* }
* </pre>
*/
public class NioPathPropertyEditorSupport extends PropertyEditorSupport {
@Override
public String getAsText() {
Expand All @@ -11,7 +20,7 @@ public String getAsText() {
}

@Override
public void setAsText(String text) throws IllegalArgumentException {
public void setAsText(String text) {
setValue(Path.of(text));
}
}

0 comments on commit 7d04d38

Please sign in to comment.