[astro] Correcting some SAT finding and a blocking point (#8964)
Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
parent
bb9a286167
commit
370c367bc3
@ -13,6 +13,7 @@
|
|||||||
package org.openhab.binding.astro.internal.calc;
|
package org.openhab.binding.astro.internal.calc;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
import org.openhab.binding.astro.internal.model.Eclipse;
|
import org.openhab.binding.astro.internal.model.Eclipse;
|
||||||
@ -233,7 +234,7 @@ public class MoonCalc {
|
|||||||
rounded = Math.floor(rounded) + riseMinute;
|
rounded = Math.floor(rounded) + riseMinute;
|
||||||
|
|
||||||
BigDecimal bd = new BigDecimal(Double.toString(rounded));
|
BigDecimal bd = new BigDecimal(Double.toString(rounded));
|
||||||
bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
|
bd = bd.setScale(2, RoundingMode.HALF_UP);
|
||||||
return bd.doubleValue();
|
return bd.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ public class SunZodiacCalc {
|
|||||||
zodiacsByYear.put(year, zodiacs);
|
zodiacsByYear.put(year, zodiacs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return zodiacs.stream().filter(z -> z.isValid(calendar)).findFirst();
|
return zodiacs != null ? zodiacs.stream().filter(z -> z.isValid(calendar)).findFirst() : Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -105,8 +105,12 @@ public class SunHandler extends AstroThingHandler {
|
|||||||
|
|
||||||
public @Nullable ZonedDateTime getEventTime(SunPhaseName sunPhase, ZonedDateTime date, boolean begin) {
|
public @Nullable ZonedDateTime getEventTime(SunPhaseName sunPhase, ZonedDateTime date, boolean begin) {
|
||||||
Range eventRange = getSunAt(date).getAllRanges().get(sunPhase);
|
Range eventRange = getSunAt(date).getAllRanges().get(sunPhase);
|
||||||
Calendar cal = begin ? eventRange.getStart() : eventRange.getEnd();
|
if (eventRange != null) {
|
||||||
return ZonedDateTime.ofInstant(cal.toInstant(), date.getZone());
|
Calendar cal = begin ? eventRange.getStart() : eventRange.getEnd();
|
||||||
|
return ZonedDateTime.ofInstant(cal.toInstant(), date.getZone());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -91,7 +91,11 @@ public class PropertyUtils {
|
|||||||
Method m = instance.getClass().getMethod(toGetterString(propertyName), null);
|
Method m = instance.getClass().getMethod(toGetterString(propertyName), null);
|
||||||
Object result = m.invoke(instance, (Object[]) null);
|
Object result = m.invoke(instance, (Object[]) null);
|
||||||
if (nestedIndex + 1 < properties.length) {
|
if (nestedIndex + 1 < properties.length) {
|
||||||
return getPropertyValue(result, properties, nestedIndex + 1);
|
if (result != null) {
|
||||||
|
return getPropertyValue(result, properties, nestedIndex + 1);
|
||||||
|
} else {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user