You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cs...@apache.org on 2020/03/17 11:57:11 UTC
[felix-dev] branch master updated: FELIX-6240 - Make sure null
description is handled gracefully
This is an automated email from the ASF dual-hosted git repository.
cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 2e56c35 FELIX-6240 - Make sure null description is handled gracefully
2e56c35 is described below
commit 2e56c35922262965e5b656809e5690938ecb76f1
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Tue Mar 17 12:57:00 2020 +0100
FELIX-6240 - Make sure null description is handled gracefully
---
.../org/apache/felix/systemready/CheckStatus.java | 50 ++++++++++------------
1 file changed, 23 insertions(+), 27 deletions(-)
diff --git a/systemready/src/main/java/org/apache/felix/systemready/CheckStatus.java b/systemready/src/main/java/org/apache/felix/systemready/CheckStatus.java
index ff42169..d4cfe10 100644
--- a/systemready/src/main/java/org/apache/felix/systemready/CheckStatus.java
+++ b/systemready/src/main/java/org/apache/felix/systemready/CheckStatus.java
@@ -20,61 +20,57 @@ package org.apache.felix.systemready;
import static java.util.stream.Collectors.minBy;
+import java.util.Objects;
import java.util.stream.Stream;
public final class CheckStatus {
- public enum State {
- // Be aware that the order of the enum declarations matters for the Comparator
- RED, YELLOW, GREEN;
+ public enum State {
+ // Be aware that the order of the enum declarations matters for the Comparator
+ RED, YELLOW, GREEN;
- public static State fromBoolean(boolean ready) {
+ public static State fromBoolean(boolean ready) {
return (ready) ? State.GREEN : State.YELLOW;
}
-
+
public static State worstOf(Stream<State> states) {
return states.collect(minBy(State::compareTo)).orElse(State.GREEN);
}
}
-
+
private final String checkName;
-
+
private final StateType type;
private final State state;
private final String details;
-
+
public CheckStatus(String checkName, StateType type, State state, String details) {
- this.checkName = checkName;
- this.type = type;
- this.state = state;
- this.details = details;
+ this.checkName = Objects.requireNonNull(checkName);
+ this.type = Objects.requireNonNull(type);
+ this.state = Objects.requireNonNull(state);
+ this.details = Objects.toString(details, "");
}
-
+
public String getCheckName() {
- return checkName;
- }
-
-
+ return checkName;
+ }
+
public StateType getType() {
- return type;
- }
-
+ return type;
+ }
+
public State getState() {
return state;
}
-
+
public String getDetails() {
return details;
}
@Override
public String toString() {
- return "CheckStatus{" +
- "state=" + state +
- ", details='" + details + '\'' +
- '}';
+ return "CheckStatus{" + "state=" + state + ", details='" + details + '\'' + '}';
}
-
-
+
}