Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Model: getValue() unnecessary #6443

Closed
wants to merge 1 commit into from
Closed
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 @@ -232,7 +232,7 @@ public Iterable<Rule> getRules(TriggerTypes triggerType, String channel, String
EventEmittedTrigger et = (EventEmittedTrigger) t;

if (et.getChannel().equals(channel)
&& (et.getTrigger() == null || et.getTrigger().getValue().equals(event))) {
&& (et.getTrigger() == null || et.getTrigger().equals(event))) {
// if the rule does not have a specific event , execute it on any event
result.add(rule);
}
Expand Down Expand Up @@ -298,14 +298,14 @@ private void internalGetUpdateRules(String name, Boolean isGroup, List<Class<? e
if ((!isGroup) && (t instanceof UpdateEventTrigger)) {
final UpdateEventTrigger ut = (UpdateEventTrigger) t;
if (ut.getItem().equals(name)) {
triggerStateString = ut.getState() != null ? ut.getState().getValue() : null;
triggerStateString = ut.getState() != null ? ut.getState() : null;
} else {
continue;
}
} else if ((isGroup) && (t instanceof GroupMemberUpdateEventTrigger)) {
final GroupMemberUpdateEventTrigger gmut = (GroupMemberUpdateEventTrigger) t;
if (gmut.getGroup().equals(name)) {
triggerStateString = gmut.getState() != null ? gmut.getState().getValue() : null;
triggerStateString = gmut.getState() != null ? gmut.getState() : null;
} else {
continue;
}
Expand Down Expand Up @@ -333,16 +333,16 @@ private void internalGetChangeRules(String name, Boolean isGroup, List<Class<? e
if ((!isGroup) && (t instanceof ChangedEventTrigger)) {
final ChangedEventTrigger ct = (ChangedEventTrigger) t;
if (ct.getItem().equals(name)) {
triggerOldStateString = ct.getOldState() != null ? ct.getOldState().getValue() : null;
triggerNewStateString = ct.getNewState() != null ? ct.getNewState().getValue() : null;
triggerOldStateString = ct.getOldState() != null ? ct.getOldState() : null;
triggerNewStateString = ct.getNewState() != null ? ct.getNewState() : null;
} else {
continue;
}
} else if ((isGroup) && (t instanceof GroupMemberChangedEventTrigger)) {
final GroupMemberChangedEventTrigger gmct = (GroupMemberChangedEventTrigger) t;
if (gmct.getGroup().equals(name)) {
triggerOldStateString = gmct.getOldState() != null ? gmct.getOldState().getValue() : null;
triggerNewStateString = gmct.getNewState() != null ? gmct.getNewState().getValue() : null;
triggerOldStateString = gmct.getOldState() != null ? gmct.getOldState() : null;
triggerNewStateString = gmct.getNewState() != null ? gmct.getNewState() : null;
} else {
continue;
}
Expand Down Expand Up @@ -375,14 +375,14 @@ private void internalGetCommandRules(String name, Boolean isGroup,
if ((!isGroup) && (t instanceof CommandEventTrigger)) {
final CommandEventTrigger ct = (CommandEventTrigger) t;
if (ct.getItem().equals(name)) {
triggerCommandString = ct.getCommand()!=null?ct.getCommand().getValue() : null;
triggerCommandString = ct.getCommand() != null ? ct.getCommand() : null;
} else {
continue;
}
} else if ((isGroup) && (t instanceof GroupMemberCommandEventTrigger)) {
final GroupMemberCommandEventTrigger gmct = (GroupMemberCommandEventTrigger) t;
if (gmct.getGroup().equals(name)) {
triggerCommandString = gmct.getCommand() != null ? gmct.getCommand().getValue() : null;
triggerCommandString = gmct.getCommand() != null ? gmct.getCommand() : null;
} else {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public void testChangedEventTrigger_withoutQuotes() throws Exception {
" logInfo(\"test says\", \"Boo!\") " + //
"end ";

assertTriggerWith(model, TriggerTypes.CHANGE, ChangedEventTrigger.class,
trigger -> trigger.getNewState().getValue());
assertTriggerWith(model, TriggerTypes.CHANGE, ChangedEventTrigger.class, trigger -> trigger.getNewState());
}

@Test
Expand All @@ -66,8 +65,7 @@ public void testChangedEventTrigger_withQuotes() throws Exception {
" logInfo(\"test says\", \"Boo!\") " + //
"end ";

assertTriggerWith(model, TriggerTypes.CHANGE, ChangedEventTrigger.class,
trigger -> trigger.getNewState().getValue());
assertTriggerWith(model, TriggerTypes.CHANGE, ChangedEventTrigger.class, trigger -> trigger.getNewState());
}

@Test
Expand All @@ -79,8 +77,7 @@ public void testCommandEventTrigger_withoutQuotes() throws Exception {
" logInfo(\"test says\", \"Boo!\") " + //
"end ";

assertTriggerWith(model, TriggerTypes.COMMAND, CommandEventTrigger.class,
trigger -> trigger.getCommand().getValue());
assertTriggerWith(model, TriggerTypes.COMMAND, CommandEventTrigger.class, trigger -> trigger.getCommand());
}

@Test
Expand All @@ -92,8 +89,7 @@ public void testCommandEventTrigger_withQuotes() throws Exception {
" logInfo(\"test says\", \"Boo!\") " + //
"end ";

assertTriggerWith(model, TriggerTypes.COMMAND, CommandEventTrigger.class,
trigger -> trigger.getCommand().getValue());
assertTriggerWith(model, TriggerTypes.COMMAND, CommandEventTrigger.class, trigger -> trigger.getCommand());
}

@Test
Expand All @@ -105,8 +101,7 @@ public void testEventEmittedTrigger_withoutQuotes() throws Exception {
" logInfo(\"test says\", \"Boo!\") " + //
"end ";

assertTriggerWith(model, TriggerTypes.TRIGGER, EventEmittedTrigger.class,
trigger -> trigger.getTrigger().getValue());
assertTriggerWith(model, TriggerTypes.TRIGGER, EventEmittedTrigger.class, trigger -> trigger.getTrigger());
}

@Test
Expand All @@ -118,8 +113,7 @@ public void testEventEmittedTrigger_withQuotes() throws Exception {
" logInfo(\"test says\", \"Boo!\") " + //
"end ";

assertTriggerWith(model, TriggerTypes.TRIGGER, EventEmittedTrigger.class,
trigger -> trigger.getTrigger().getValue());
assertTriggerWith(model, TriggerTypes.TRIGGER, EventEmittedTrigger.class, trigger -> trigger.getTrigger());
}

private <T> void assertTriggerWith(String model, TriggerTypes triggerType, Class<T> triggerClass,
Expand Down