DSL Scripts and Rules: import static all Types/State/Command enums - #5509
DSL Scripts and Rules: import static all Types/State/Command enums#5509dilyanpalauzov wants to merge 1 commit into
Conversation
|
I'm not sure exactly what you're changing to make the error disappear, but I think removing the centrally defined definition is a bad idea. It means more places in the code to maintain/be aware of that exists, leading to more bugs and inconsistencies. I assume that the cause for the validation failure has to do with timing, it should be possible to resolve the timing issue without removing the central definition of states and commands? |
I am removing centrally defined hacks.
Here exactly the opposite is the case. OnOffType.ON is handled exactly in the same way as ZonedDateTime.now. |
| result.add(IncreaseDecreaseType.class); | ||
| result.add(NextPreviousType.class); | ||
| result.add(OnOffType.class); | ||
| result.add(OpenClosedType.class); | ||
| result.add(PlayPauseType.class); | ||
| result.add(RefreshType.class); | ||
| result.add(RewindFastforwardType.class); | ||
| result.add(StopMoveType.class); | ||
| result.add(UnDefType.class); | ||
| result.add(UpDownType.class); |
There was a problem hiding this comment.
@dilyanpalauzov Here you have hardcoded them. Instead, they should be retrieved from a centralized location, so that all code use "the same list" of states and commands.
I made a comment to try to point out what I was referring to. The structural changes you have made to where things are inserted I can't really evaluate, I know too little of the consequences of this. But, wherever you insert them, you must have a centrally defined "list" of states and commands to insert. This list should be the same here as in parsers, serializers and similar code, which is what |
|
There is no need in this context to have a place containing a list of all command and all states. In JSR223 context, the |
This change makes using all Type/Command/State enums as static import simpler … by reducing the code size with 30 lines. It removes all current usages of class org.openhab.core.model.script.scoping.StateAndCommandProvider.
Before this change a global variable
produced
Now the above works as expected.