Fixed nullness anotations for TriggerHandlerCallback (#2589)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>pull/2591/head
parent
3493c85e19
commit
eb982f430d
|
@ -54,5 +54,5 @@ public interface TriggerHandlerCallback extends ModuleHandlerCallback {
|
|||
/**
|
||||
* @return the scheduler of this rule
|
||||
*/
|
||||
public @Nullable ScheduledExecutorService getScheduler();
|
||||
public ScheduledExecutorService getScheduler();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.automation.RuleStatus;
|
||||
|
@ -37,15 +36,16 @@ import org.openhab.core.common.NamedThreadFactory;
|
|||
* @author Kai Kreuzer - improved stability
|
||||
* @author Fabian Wolter - Change executor to ScheduledExecutorService and expose it
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class TriggerHandlerCallbackImpl implements TriggerHandlerCallback {
|
||||
|
||||
private final RuleEngineImpl re;
|
||||
|
||||
private final String ruleUID;
|
||||
|
||||
private ScheduledExecutorService executor;
|
||||
|
||||
private Future<?> future;
|
||||
|
||||
private final RuleEngineImpl re;
|
||||
private @Nullable Future<?> future;
|
||||
|
||||
protected TriggerHandlerCallbackImpl(RuleEngineImpl re, String ruleUID) {
|
||||
this.re = re;
|
||||
|
@ -54,11 +54,8 @@ public class TriggerHandlerCallbackImpl implements TriggerHandlerCallback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void triggered(Trigger trigger, @Nullable Map<@NonNull String, ?> context) {
|
||||
public void triggered(Trigger trigger, @Nullable Map<String, ?> context) {
|
||||
synchronized (this) {
|
||||
if (executor == null) {
|
||||
return;
|
||||
}
|
||||
future = executor.submit(new TriggerData(trigger, context));
|
||||
}
|
||||
re.logger.debug("The trigger '{}' of rule '{}' is triggered.", trigger.getId(), ruleUID);
|
||||
|
@ -69,7 +66,6 @@ public class TriggerHandlerCallbackImpl implements TriggerHandlerCallback {
|
|||
return future == null || !future.isDone();
|
||||
}
|
||||
|
||||
@NonNullByDefault
|
||||
class TriggerData implements Runnable {
|
||||
|
||||
private final Trigger trigger;
|
||||
|
@ -96,16 +92,15 @@ public class TriggerHandlerCallbackImpl implements TriggerHandlerCallback {
|
|||
|
||||
public void dispose() {
|
||||
synchronized (this) {
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
AccessController.doPrivileged((PrivilegedAction<@Nullable Void>) () -> {
|
||||
executor.shutdownNow();
|
||||
return null;
|
||||
});
|
||||
executor = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isEnabled(String ruleUID) {
|
||||
public @Nullable Boolean isEnabled(String ruleUID) {
|
||||
return re.isEnabled(ruleUID);
|
||||
}
|
||||
|
||||
|
@ -115,12 +110,12 @@ public class TriggerHandlerCallbackImpl implements TriggerHandlerCallback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RuleStatusInfo getStatusInfo(String ruleUID) {
|
||||
public @Nullable RuleStatusInfo getStatusInfo(String ruleUID) {
|
||||
return re.getStatusInfo(ruleUID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleStatus getStatus(String ruleUID) {
|
||||
public @Nullable RuleStatus getStatus(String ruleUID) {
|
||||
return re.getStatus(ruleUID);
|
||||
}
|
||||
|
||||
|
@ -130,7 +125,7 @@ public class TriggerHandlerCallbackImpl implements TriggerHandlerCallback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void runNow(String uid, boolean considerConditions, Map<String, Object> context) {
|
||||
public void runNow(String uid, boolean considerConditions, @Nullable Map<String, Object> context) {
|
||||
re.runNow(uid, considerConditions, context);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue