[New] Added State.getState(Set<State>)

This commit is contained in:
Robert von Burg 2023-02-27 10:49:43 +01:00
parent 8d28727c68
commit 4c9458f1c3
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
1 changed files with 10 additions and 3 deletions

View File

@ -235,7 +235,7 @@ public enum State {
public static State parseAllowNull(String s) {
for (State state : values()) {
if (state.state.toLowerCase().equals(s.toLowerCase()))
if (state.state.equalsIgnoreCase(s))
return state;
}
@ -245,7 +245,7 @@ public enum State {
public static State parse(String s) {
DBC.PRE.assertNotEmpty("Value may not be null", s);
for (State state : values()) {
if (state.state.toLowerCase().equals(s.toLowerCase()))
if (state.state.equalsIgnoreCase(s))
return state;
}
@ -253,8 +253,15 @@ public enum State {
}
public static State getState(Activity activity) {
Set<State> states = activity.elementStream().map(e -> e.getValue().getState()).collect(toSet());
return getState(states);
}
public static State getState(Set<State> states) {
// if no states
if (states.isEmpty())
return CREATED;
// if only one state
if (states.size() == 1)