diff options
Diffstat (limited to 'sdnr/wt/common-yang/utils/src/main')
-rw-r--r-- | sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java index 55a20d6c0..8959e913a 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/EnumSerializer.java @@ -25,12 +25,19 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import java.io.IOException; +import org.opendaylight.yangtools.yang.binding.Enumeration; @SuppressWarnings("rawtypes") public class EnumSerializer extends JsonSerializer<Enum> { @Override public void serialize(Enum value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - gen.writeString(value.name()); + //sadly a seperate serializer for class Enumeration doesn't work, so we have to catch it here + if(value instanceof Enumeration) { + gen.writeString(((Enumeration)value).getName()); + } + else { + gen.writeString(value.name()); + } } } |