diff options
Diffstat (limited to 'models-base/src/main/java/org/onap/policy/models/base/PfValidator.java')
-rw-r--r-- | models-base/src/main/java/org/onap/policy/models/base/PfValidator.java | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java b/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java index db7b9d63e..c2eb2b649 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfValidator.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,11 +49,10 @@ public class PfValidator extends BeanValidator { * @return {@code true} if the next check should be performed, {@code false} otherwise */ public boolean verPfMin(BeanValidationResult result, String fieldName, PfMin annot, Object value) { - if (!(value instanceof Number)) { + if (!(value instanceof Number num)) { return true; } - Number num = (Number) value; if (num.longValue() == annot.allowed()) { // this value is always allowed return true; @@ -93,11 +93,10 @@ public class PfValidator extends BeanValidator { * @return {@code true} if the next check should be performed, {@code false} otherwise */ public boolean verKey(BeanValidationResult result, String fieldName, VerifyKey annot, Object value) { - if (!(value instanceof PfKey)) { + if (!(value instanceof PfKey pfkey)) { return true; } - var pfkey = (PfKey) value; if (annot.keyNotNull() && pfkey.isNullKey()) { result.addResult(fieldName, xlate(pfkey), ValidationStatus.INVALID, Validated.IS_A_NULL_KEY); return false; @@ -107,14 +106,12 @@ public class PfValidator extends BeanValidator { verCascade(result, fieldName, value); } - if (!(pfkey instanceof PfKeyImpl)) { + if (!(pfkey instanceof PfKeyImpl keyimpl)) { return true; } var result2 = new BeanValidationResult(fieldName, value); - PfKeyImpl keyimpl = (PfKeyImpl) pfkey; - if (annot.nameNotNull() && keyimpl.isNullName()) { result2.addResult("name", pfkey.getName(), ValidationStatus.INVALID, Validated.IS_NULL); } |