JAMES-2575 add String value to enum for nicer output Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0fa19617 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0fa19617 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0fa19617
Branch: refs/heads/master Commit: 0fa19617145cf36b6a5f446f8952778d87dccb9b Parents: 6056239 Author: Michael Schnitzler <[email protected]> Authored: Sat Oct 27 20:37:18 2018 +0200 Committer: Benoit Tellier <[email protected]> Committed: Wed Oct 31 08:48:29 2018 +0700 ---------------------------------------------------------------------- .../james/core/healthcheck/ResultStatus.java | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/0fa19617/core/src/main/java/org/apache/james/core/healthcheck/ResultStatus.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/james/core/healthcheck/ResultStatus.java b/core/src/main/java/org/apache/james/core/healthcheck/ResultStatus.java index 89109e9..64547c7 100644 --- a/core/src/main/java/org/apache/james/core/healthcheck/ResultStatus.java +++ b/core/src/main/java/org/apache/james/core/healthcheck/ResultStatus.java @@ -18,6 +18,28 @@ ****************************************************************/ package org.apache.james.core.healthcheck; +import java.util.Arrays; + public enum ResultStatus { - HEALTHY, DEGRADED, UNHEALTHY; + HEALTHY("healthy"), + DEGRADED("degraded"), + UNHEALTHY("unhealthy"); + + public static ResultStatus fromString(String value) { + return Arrays.stream(values()) + .filter(status -> status.value.equalsIgnoreCase(value)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException( + String.format("Unknown status value '%s'", value))); + } + + private final String value; + + ResultStatus(String value) { + this.value = value; + } + + public String getValue() { + return value; + } } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
