Rework ThingActions (#8755)
* Remove duplication by making use of default Java generated exceptions * Make ThingActions labels/descriptions more consistent Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -54,12 +54,8 @@ public class AutomowerActions implements ThingActions {
|
||||
}
|
||||
}
|
||||
|
||||
public static void start(@Nullable ThingActions actions, int durationMin) {
|
||||
if (actions instanceof AutomowerActions) {
|
||||
((AutomowerActions) actions).start(durationMin);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of AutomowerActions");
|
||||
}
|
||||
public static void start(ThingActions actions, int durationMin) {
|
||||
((AutomowerActions) actions).start(durationMin);
|
||||
}
|
||||
|
||||
@RuleAction(label = "@text/action-pause-label", description = "@text/action-pause-desc")
|
||||
@@ -72,12 +68,8 @@ public class AutomowerActions implements ThingActions {
|
||||
}
|
||||
}
|
||||
|
||||
public static void pause(@Nullable ThingActions actions) {
|
||||
if (actions instanceof AutomowerActions) {
|
||||
((AutomowerActions) actions).pause();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of AutomowerActions");
|
||||
}
|
||||
public static void pause(ThingActions actions) {
|
||||
((AutomowerActions) actions).pause();
|
||||
}
|
||||
|
||||
@RuleAction(label = "@text/action-parkuntilnextschedule-label", description = "@text/action-parkuntilnextschedule-desc")
|
||||
@@ -90,12 +82,8 @@ public class AutomowerActions implements ThingActions {
|
||||
}
|
||||
}
|
||||
|
||||
public static void parkUntilNextSchedule(@Nullable ThingActions actions) {
|
||||
if (actions instanceof AutomowerActions) {
|
||||
((AutomowerActions) actions).parkUntilNextSchedule();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of AutomowerActions");
|
||||
}
|
||||
public static void parkUntilNextSchedule(ThingActions actions) {
|
||||
((AutomowerActions) actions).parkUntilNextSchedule();
|
||||
}
|
||||
|
||||
@RuleAction(label = "@text/action-parkuntilfurthernotice-label", description = "@text/action-parkuntilfurthernotice-desc")
|
||||
@@ -108,12 +96,8 @@ public class AutomowerActions implements ThingActions {
|
||||
}
|
||||
}
|
||||
|
||||
public static void parkUntilFurtherNotice(@Nullable ThingActions actions) {
|
||||
if (actions instanceof AutomowerActions) {
|
||||
((AutomowerActions) actions).parkUntilFurtherNotice();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of AutomowerActions");
|
||||
}
|
||||
public static void parkUntilFurtherNotice(ThingActions actions) {
|
||||
((AutomowerActions) actions).parkUntilFurtherNotice();
|
||||
}
|
||||
|
||||
@RuleAction(label = "@text/action-park-label", description = "@text/action-park-desc")
|
||||
@@ -127,12 +111,8 @@ public class AutomowerActions implements ThingActions {
|
||||
}
|
||||
}
|
||||
|
||||
public static void park(@Nullable ThingActions actions, int durationMin) {
|
||||
if (actions instanceof AutomowerActions) {
|
||||
((AutomowerActions) actions).park(durationMin);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of AutomowerActions");
|
||||
}
|
||||
public static void park(ThingActions actions, int durationMin) {
|
||||
((AutomowerActions) actions).park(durationMin);
|
||||
}
|
||||
|
||||
@RuleAction(label = "@text/action-resumeschedule-label", description = "@text/action-resumeschedule-desc")
|
||||
@@ -145,11 +125,7 @@ public class AutomowerActions implements ThingActions {
|
||||
}
|
||||
}
|
||||
|
||||
public static void resumeSchedule(@Nullable ThingActions actions) {
|
||||
if (actions instanceof AutomowerActions) {
|
||||
((AutomowerActions) actions).resumeSchedule();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Actions is not an instance of AutomowerActions");
|
||||
}
|
||||
public static void resumeSchedule(ThingActions actions) {
|
||||
((AutomowerActions) actions).resumeSchedule();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,23 +40,23 @@ comm-error-send-mower-command-failed = Unable to send automower command
|
||||
|
||||
comm-error-mower-not-connected-to-cloud = Automower not connected to the cloud
|
||||
|
||||
action-start-label = Start
|
||||
action-start-desc = Starts the automower for a defined amount of time, overriding its schedule
|
||||
action-start-label = start the automower
|
||||
action-start-desc = Starts the automower for a defined amount of time, overriding its schedule.
|
||||
|
||||
action-pause-label = Pause
|
||||
action-pause-desc = Pauses the automower wherever it currently is
|
||||
action-pause-label = pause the automower
|
||||
action-pause-desc = Pauses the automower wherever it currently is.
|
||||
|
||||
action-parkuntilnextschedule-label = Park until next schedule
|
||||
action-parkuntilnextschedule-desc = Parks the automower until the next schedule
|
||||
action-parkuntilnextschedule-label = park until the next schedule
|
||||
action-parkuntilnextschedule-desc = Parks the automower until the next schedule.
|
||||
|
||||
action-parkuntilfurthernotice-label = Park until further notice
|
||||
action-parkuntilfurthernotice-desc = Parks the automower until the schedule is resumed
|
||||
action-parkuntilfurthernotice-label = park until further notice
|
||||
action-parkuntilfurthernotice-desc = Parks the automower until the schedule is resumed.
|
||||
|
||||
action-park-label = Park
|
||||
action-park-desc = Parks the automower for a defined amount of time, overriding its schedule
|
||||
action-park-label = park the automower
|
||||
action-park-desc = Parks the automower for a defined amount of time, overriding its schedule.
|
||||
|
||||
action-resumeschedule-label = Resume schedule
|
||||
action-resumeschedule-desc = Resumes the schedule for the automower
|
||||
action-resumeschedule-label = resume the schedule
|
||||
action-resumeschedule-desc = Resumes the schedule for the automower.
|
||||
|
||||
action-input-duration-label = Duration
|
||||
action-input-duration-desc = The duration of the automower command in minutes
|
||||
|
||||
Reference in New Issue
Block a user