diff options
Diffstat (limited to 'common-parameters/src/main/java/org')
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/FieldValidator.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/FieldValidator.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/FieldValidator.java index 51c5d57f..d441c286 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/FieldValidator.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/FieldValidator.java @@ -20,6 +20,7 @@ package org.onap.policy.common.parameters; +import com.google.gson.annotations.SerializedName; import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedParameterizedType; import java.lang.reflect.AnnotatedType; @@ -58,6 +59,11 @@ public class FieldValidator extends ValueValidator { private final Field field; /** + * Name of the field when serialized (i.e., as the client would know it). + */ + private final String serializedName; + + /** * Method to retrieve the field's value. */ private Method accessor; @@ -76,9 +82,13 @@ public class FieldValidator extends ValueValidator { String fieldName = field.getName(); if (fieldName.contains("$")) { + serializedName = fieldName; return; } + SerializedName serAnnot = field.getAnnotation(SerializedName.class); + serializedName = (serAnnot != null ? serAnnot.value() : fieldName); + validator.addValidators(this); addListValidator(validator); addMapValidator(validator); @@ -184,7 +194,7 @@ public class FieldValidator extends ValueValidator { // get the value Object value = getValue(object, accessor); - validateValue(result, field.getName(), value); + validateValue(result, serializedName, value); } /** |