package org.openhab.binding.astro.internal.calc;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.Calendar;
import org.openhab.binding.astro.internal.model.Eclipse;
rounded = Math.floor(rounded) + riseMinute;
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();
}
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();
}
/**
public @Nullable ZonedDateTime getEventTime(SunPhaseName sunPhase, ZonedDateTime date, boolean begin) {
Range eventRange = getSunAt(date).getAllRanges().get(sunPhase);
- Calendar cal = begin ? eventRange.getStart() : eventRange.getEnd();
- return ZonedDateTime.ofInstant(cal.toInstant(), date.getZone());
+ if (eventRange != null) {
+ Calendar cal = begin ? eventRange.getStart() : eventRange.getEnd();
+ return ZonedDateTime.ofInstant(cal.toInstant(), date.getZone());
+ } else {
+ return null;
+ }
}
@Override
Method m = instance.getClass().getMethod(toGetterString(propertyName), null);
Object result = m.invoke(instance, (Object[]) null);
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;
}