Signed-off-by: Martin Grześlowski <martin.grzeslowski@gmail.com>
pull/4381/head
Martin Grześlowski 2024-09-15 10:41:33 +02:00
parent e027bb5cb1
commit 2c90807a92
4 changed files with 16 additions and 0 deletions

View File

@ -60,6 +60,10 @@ public enum OnOffType implements PrimitiveType, State, Command {
return super.toString();
}
public OnOffType toggle() {
return this == ON ? OFF : ON;
}
@Override
public <T extends State> @Nullable T as(@Nullable Class<T> target) {
if (target == DecimalType.class) {

View File

@ -42,6 +42,10 @@ public enum OpenClosedType implements PrimitiveType, State, Command {
return super.toString();
}
public OpenClosedType toggle() {
return this == OPEN ? CLOSED : OPEN;
}
@Override
public <T extends State> @Nullable T as(@Nullable Class<T> target) {
if (target == DecimalType.class) {

View File

@ -42,4 +42,8 @@ public enum PlayPauseType implements PrimitiveType, State, Command {
public String toFullString() {
return super.toString();
}
public PlayPauseType toggle() {
return this == PLAY ? PAUSE : PLAY;
}
}

View File

@ -44,6 +44,10 @@ public enum UpDownType implements PrimitiveType, State, Command {
return super.toString();
}
public UpDownType toggle() {
return this == UP ? DOWN : UP;
}
@Override
public <T extends State> @Nullable T as(@Nullable Class<T> target) {
if (target == DecimalType.class) {