X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=PolicyEngineAPI%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fapi%2FPolicyConfigStatus.java;h=f1bbea167ee4fb37bcfd93465162563d63beeaa3;hb=5450bdbfb94fb5217617da6c41971fd26f7e81b5;hp=cee15678613eb47244969bf6bdbf01221970923d;hpb=a9710cb3b80c73c98d257c676ba6ecf9e30ef758;p=policy%2Fengine.git diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java index cee156786..f1bbea167 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigStatus.java @@ -23,58 +23,63 @@ package org.onap.policy.api; import com.fasterxml.jackson.annotation.JsonCreator; /** - * Enumeration of PolicyConfigStatus that can be returned as a part of + * Enumeration of PolicyConfigStatus that can be returned as a part of * {@link org.onap.policy.api.PolicyConfig}. * * @version 0.1 */ -public enum PolicyConfigStatus { - /** - * Indicates that the Configuration has been successfully retrieved. - */ - CONFIG_RETRIEVED("retrieved"), - /** - * Indicates that there is no Configuration Retrieved from PolicyConfig. - */ - CONFIG_NOT_FOUND("not_found"), - ; - - private String name; - private PolicyConfigStatus(String name){ - this.name = name; - } - - /** - * Get the PolicyConfigStatus based on String representation of PolicyConfig - * - * @param configStatus the String Configuration Status - * @return the PolicyConfigResponse with the name matching CONFIG_RETRIEVED or CONFIG_NOT_FOUND - * if no match is found - */ - public static PolicyConfigStatus getStatus(String configStatus) { - if("retrieved".equalsIgnoreCase(configStatus)) { - return CONFIG_RETRIEVED; - }else { - return CONFIG_NOT_FOUND; - } - } - - /** - * Returns the String name for this PolicyConfigStatus - * - * @return the String name for this PolicyConfigStatus - */ - @Override - public String toString(){ - return this.name; - } - @JsonCreator - public static PolicyConfigStatus create (String value) { - for(PolicyConfigStatus type: values()){ - if(type.toString().equals(value) || type.equals(PolicyConfigStatus.valueOf(value))){ +public enum PolicyConfigStatus { + /** + * Indicates that the Configuration has been successfully retrieved. + */ + CONFIG_RETRIEVED("retrieved"), + /** + * Indicates that there is no Configuration Retrieved from PolicyConfig. + */ + CONFIG_NOT_FOUND("not_found"); + + private final String name; + + private PolicyConfigStatus(final String name) { + this.name = name; + } + + /** + * Get the PolicyConfigStatus based on String + * representation of PolicyConfig + * + * @param configStatus + * the String Configuration Status + * @return the PolicyConfigResponse with the name matching + * CONFIG_RETRIEVED or CONFIG_NOT_FOUND if + * no match is found + */ + public static PolicyConfigStatus getStatus(final String configStatus) { + if (CONFIG_RETRIEVED.name.equalsIgnoreCase(configStatus)) { + return CONFIG_RETRIEVED; + } + return CONFIG_NOT_FOUND; + } + + /** + * Returns the String name for this + * PolicyConfigStatus + * + * @return the String name for this + * PolicyConfigStatus + */ + @Override + public String toString() { + return this.name; + } + + @JsonCreator + public static PolicyConfigStatus create(final String value) { + for (final PolicyConfigStatus type : values()) { + if (type.toString().equalsIgnoreCase(value) || type.name().equalsIgnoreCase(value)) { return type; } } - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Invalid value: " + value); } }