Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public PlayActionHandler(Action module, AudioManager audioManager) {
}

@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> context) {
try {
audioManager.playFile(sound, sink, volume);
} catch (AudioException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public SayActionHandler(Action module, VoiceManager voiceManager) {
}

@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> context) {
voiceManager.say(text, null, sink, volume);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public SynthesizeActionHandler(Action module, AudioManager audioManager) {
}

@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> context) {
audioManager.playMelody(melody, sink, volume);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void dispose() {
}

@Override
public @Nullable Map<String, Object> execute(Map<String, @Nullable Object> inputs) {
public @Nullable Map<String, @Nullable Object> execute(Map<String, @Nullable Object> inputs) {
Set<String> keys = new HashSet<>(inputs.keySet());

Map<String, @Nullable Object> extendedInputs = new HashMap<>(inputs);
Expand All @@ -60,7 +60,7 @@ public void dispose() {
}

Object result = actionHandler.execute(module, extendedInputs);
Map<String, Object> resultMap = new HashMap<>();
Map<String, @Nullable Object> resultMap = new HashMap<>();
resultMap.put("result", result);
return resultMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public void compile() throws ScriptException {
}

@Override
public @Nullable Map<String, Object> execute(final Map<String, Object> context) {
Map<String, Object> resultMap = new HashMap<>();
public @Nullable Map<String, @Nullable Object> execute(final Map<String, Object> context) {
Map<String, @Nullable Object> resultMap = new HashMap<>();

if (script.isEmpty()) {
return resultMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public Response executeThingAction(@PathParam("thingUID") @Parameter(description
}

try {
Map<String, Object> returnValue = Objects.requireNonNullElse(
Map<String, @Nullable Object> returnValue = Objects.requireNonNullElse(
handler.execute(actionInputsHelper.mapSerializedInputsToActionInputs(actionType, actionInputs)),
Map.of());
moduleHandlerFactory.ungetHandler(action, ruleUID, handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ default void compile() throws Exception {
* @return a map with the {@code outputs} which are the result of the {@link Action}'s execution (may be null).
*/
@Nullable
Map<String, Object> execute(Map<String, Object> context);
Map<String, @Nullable Object> execute(Map<String, Object> context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
* The context map of a {@link Rule} is cleaned when the execution is completed. The relation is
* {@link Rule}'s UID to Rule context map.
*/
private final Map<String, Map<String, Object>> contextMap = new ConcurrentHashMap<>();
private final Map<String, Map<String, @Nullable Object>> contextMap = new ConcurrentHashMap<>();

/**
* This field holds reference to {@link ModuleTypeRegistry}. The {@link RuleEngineImpl} needs it to auto-map
Expand Down Expand Up @@ -1089,9 +1089,9 @@ protected void runRule(String ruleUID, TriggerHandlerCallbackImpl.TriggerData td
}

@Override
public Map<String, Object> runNow(String ruleUID, boolean considerConditions,
public Map<String, @Nullable Object> runNow(String ruleUID, boolean considerConditions,
@Nullable Map<String, Object> context) {
Map<String, Object> returnContext = new HashMap<>();
Map<String, @Nullable Object> returnContext = new HashMap<>();
final WrappedRule rule = getManagedRule(ruleUID);
if (rule == null) {
logger.warn("Failed to execute rule '{}': Invalid Rule UID", ruleUID);
Expand Down Expand Up @@ -1129,7 +1129,7 @@ public Map<String, Object> runNow(String ruleUID, boolean considerConditions,
}

@Override
public Map<String, Object> runNow(String ruleUID) {
public Map<String, @Nullable Object> runNow(String ruleUID) {
return runNow(ruleUID, false, null);
}

Expand All @@ -1139,7 +1139,7 @@ public Map<String, Object> runNow(String ruleUID) {
* @param ruleUID the UID of the rule whose context must be cleared.
*/
protected void clearContext(String ruleUID) {
Map<String, Object> context = contextMap.get(ruleUID);
Map<String, @Nullable Object> context = contextMap.get(ruleUID);
if (context != null) {
context.clear();
}
Expand All @@ -1163,7 +1163,7 @@ private void setTriggerOutputs(String ruleUID, TriggerData td) {
* @param outputs new output values.
*/
private void updateContext(String ruleUID, String moduleUID, @Nullable Map<String, ?> outputs) {
Map<String, Object> context = getContext(ruleUID, null);
Map<String, @Nullable Object> context = getContext(ruleUID, null);
if (outputs != null) {
for (Map.Entry<String, ?> entry : outputs.entrySet()) {
String key = moduleUID + OUTPUT_SEPARATOR + entry.getKey();
Expand All @@ -1175,8 +1175,8 @@ private void updateContext(String ruleUID, String moduleUID, @Nullable Map<Strin
/**
* @return copy of current context in rule engine
*/
private Map<String, Object> getContext(String ruleUID, @Nullable Set<Connection> connections) {
Map<String, Object> context = contextMap.computeIfAbsent(ruleUID, k -> new HashMap<>());
private Map<String, @Nullable Object> getContext(String ruleUID, @Nullable Set<Connection> connections) {
Map<String, @Nullable Object> context = contextMap.computeIfAbsent(ruleUID, k -> new HashMap<>());
if (context == null) {
throw new IllegalStateException("context cannot be null at that point - please report a bug.");
}
Expand Down Expand Up @@ -1257,7 +1257,7 @@ private boolean calculateConditions(WrappedRule rule) {
}
final Condition condition = wrappedCondition.unwrap();
ConditionHandler tHandler = wrappedCondition.getModuleHandler();
Map<String, Object> context = getContext(ruleUID, wrappedCondition.getConnections());
Map<String, @Nullable Object> context = getContext(ruleUID, wrappedCondition.getConnections());
if (tHandler != null && !tHandler.isSatisfied(Collections.unmodifiableMap(context))) {
logger.debug("The condition '{}' of rule '{}' is unsatisfied.", condition.getId(), ruleUID);
return false;
Expand Down Expand Up @@ -1312,9 +1312,9 @@ private void executeActions(WrappedRule rule, boolean stopOnFirstFail) {
final Action action = wrappedAction.unwrap();
ActionHandler aHandler = wrappedAction.getModuleHandler();
if (aHandler != null) {
Map<String, Object> context = getContext(ruleUID, wrappedAction.getConnections());
Map<String, @Nullable Object> context = getContext(ruleUID, wrappedAction.getConnections());
try {
Map<String, ?> outputs = aHandler.execute(Collections.unmodifiableMap(context));
Map<String, @Nullable ?> outputs = aHandler.execute(Collections.unmodifiableMap(context));
if (outputs != null) {
context = getContext(ruleUID, null);
updateContext(ruleUID, action.getId(), outputs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ public CompositeActionHandler(Action action, CompositeActionType mt,
* @see org.openhab.core.automation.handler.ActionHandler#execute(java.util.Map)
*/
@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
final Map<String, Object> result = new HashMap<>();
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> context) {
final Map<String, @Nullable Object> result = new HashMap<>();
final List<Action> children = getChildren();
final Map<String, Object> compositeContext = getCompositeContext(context);
for (Action child : children) {
ActionHandler childHandler = moduleHandlerMap.get(child);
Map<String, Object> childContext = Collections.unmodifiableMap(getChildContext(child, compositeContext));
Map<String, Object> childResults = childHandler == null ? null : childHandler.execute(childContext);
Map<String, @Nullable Object> childResults = childHandler == null ? null
: childHandler.execute(childContext);
if (childResults != null) {
for (Entry<String, Object> childResult : childResults.entrySet()) {
for (Entry<String, @Nullable Object> childResult : childResults.entrySet()) {
String childOuputName = child.getId() + "." + childResult.getKey();
Output output = compositeOutputs.get(childOuputName);
if (output != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public AnnotationActionHandler(Action module, ActionType mt, Method method, Obje
}

@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
Map<String, Object> output = new HashMap<>();
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> context) {
Map<String, @Nullable Object> output = new HashMap<>();

Annotation[][] annotations = method.getParameterAnnotations();
List<@Nullable Object> args = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ItemCommandActionHandler(Action module, EventPublisher eventPublisher, It
}

@Override
public @Nullable Map<String, Object> execute(Map<String, Object> inputs) {
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> inputs) {
String itemName = (String) module.getConfiguration().get(ITEM_NAME);
String command = (String) module.getConfiguration().get(COMMAND);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ItemStateUpdateActionHandler(Action module, EventPublisher eventPublisher
}

@Override
public @Nullable Map<String, Object> execute(Map<String, Object> inputs) {
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> inputs) {
Configuration config = module.getConfiguration();
String itemName = (String) config.get(ITEM_NAME);
String state = (String) config.get(STATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public RuleEnablementActionHandler(final Action module) {
}

@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> context) {
for (String uid : uids) {
if (callback != null) {
callback.setEnabled(uid, enable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public RunRuleActionHandler(final Action module) {
}

@Override
public @Nullable Map<String, Object> execute(Map<String, Object> context) {
public @Nullable Map<String, @Nullable Object> execute(Map<String, Object> context) {
// execute each rule after the other; at the moment synchronously
Object previousEvent = context.get("event");
Event event = AutomationEventFactory.createExecutionEvent(moduleId,
Expand Down