Trust level updates with dmi status change
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / impl / trustlevel / TrustLevel.java
index 8d1f8e9..f130604 100644 (file)
@@ -25,11 +25,28 @@ import lombok.Getter;
 @Getter
 public enum TrustLevel {
     NONE(0), COMPLETE(99);
+    private final int level;
 
-    private final int value;
+    /**
+     * Creates TrustLevel enum from a numeric value.
+     *
+     * @param       level numeric value between 0-99
+     */
+    TrustLevel(final int level) {
+        this.level = level;
+    }
 
-    TrustLevel(final int value) {
-        this.value = value;
+    /**
+     * Gets the lower trust level (effective) among two.
+     *
+     * @param       other the trust level compared with this
+     * @return      the lower trust level
+     */
+    public final TrustLevel getEffectiveTrustLevel(final TrustLevel other) {
+        if (other.level < this.level) {
+            return other;
+        }
+        return this;
     }
 
-}
\ No newline at end of file
+}