use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.
the class ModuleTypeGSONParser method createMapByType.
private Map<String, List<? extends ModuleType>> createMapByType(Set<ModuleType> dataObjects) {
Map<String, List<? extends ModuleType>> map = new HashMap<>();
List<TriggerType> triggers = new ArrayList<>();
List<ConditionType> conditions = new ArrayList<>();
List<ActionType> actions = new ArrayList<>();
for (ModuleType moduleType : dataObjects) {
if (moduleType instanceof TriggerType) {
triggers.add((TriggerType) moduleType);
} else if (moduleType instanceof ConditionType) {
conditions.add((ConditionType) moduleType);
} else if (moduleType instanceof ActionType) {
actions.add((ActionType) moduleType);
}
}
map.put("triggers", triggers);
map.put("conditions", conditions);
map.put("actions", actions);
return map;
}
use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.
the class ModuleTypeRegistryImpl method createCopy.
@Nullable
private ModuleType createCopy(@Nullable ModuleType mType) {
if (mType == null) {
return null;
}
ModuleType result;
if (mType instanceof CompositeTriggerType) {
CompositeTriggerType m = (CompositeTriggerType) mType;
result = new CompositeTriggerType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getOutputs(), new ArrayList<>(m.getChildren()));
} else if (mType instanceof TriggerType) {
TriggerType m = (TriggerType) mType;
result = new TriggerType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getOutputs());
} else if (mType instanceof CompositeConditionType) {
CompositeConditionType m = (CompositeConditionType) mType;
result = new CompositeConditionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), new ArrayList<>(m.getChildren()));
} else if (mType instanceof ConditionType) {
ConditionType m = (ConditionType) mType;
result = new ConditionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs());
} else if (mType instanceof CompositeActionType) {
CompositeActionType m = (CompositeActionType) mType;
result = new CompositeActionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), m.getOutputs(), new ArrayList<>(m.getChildren()));
} else if (mType instanceof ActionType) {
ActionType m = (ActionType) mType;
result = new ActionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), m.getOutputs());
} else {
throw new IllegalArgumentException("Invalid template type:" + mType);
}
return result;
}
use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.
the class ModuleTypeRegistryImpl method getConditions.
@Override
public Collection<ConditionType> getConditions(String... tags) {
Collection<ModuleType> moduleTypes = getByTags(tags);
Collection<ConditionType> conditionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof ConditionType) {
conditionTypes.add((ConditionType) mt);
}
}
return conditionTypes;
}
use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.
the class ModuleTypeRegistryImpl method getConditions.
@Override
public Collection<ConditionType> getConditions(@Nullable Locale locale, String... tags) {
Collection<ModuleType> moduleTypes = getByTags(locale, tags);
Collection<ConditionType> conditionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof ConditionType) {
conditionTypes.add((ConditionType) mt);
}
}
return conditionTypes;
}
use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.
the class TestModuleTypeProvider method createConditionType.
private ConditionType createConditionType() {
List<Input> inputs = new ArrayList<>(3);
// no connection, missing condition tag
inputs.add(createInput("in0", Set.of("tagE")));
// conflict in2 -> out1 or in2 -> out3
inputs.add(createInput("in1", Set.of("tagA")));
// in2 -> out3
inputs.add(createInput("in2", Set.of("tagA", "tagB")));
ConditionType t = new ConditionType(CONDITION_TYPE, null, inputs);
return t;
}
Aggregations