diff options
author | Michael DÜrre <michael.duerre@highstreet-technologies.com> | 2021-09-23 10:15:21 +0200 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2021-09-23 15:37:31 +0000 |
commit | f03758806c601e63cc835e423498c17c0b5dc429 (patch) | |
tree | 21dcb3fd490ec8ec8298dac62d724d0a9921f2da /sdnr/wt/common-yang/utils/src/main | |
parent | 0eaf2d56a8ac8de275cd80d3db38c02f110faa30 (diff) |
fixed yang enum serialization
fixed serializer for yang types with -
Issue-ID: CCSDK-3452
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Change-Id: I0e212c585b2874c2f5d154b25615aac17a3da634
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
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()); + } } } |