summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/common-yang/utils/src/main
diff options
context:
space:
mode:
authorMichael Dürre <michael.duerre@highstreet-technologies.com>2022-07-20 09:32:50 +0200
committerMichael Dürre <michael.duerre@highstreet-technologies.com>2022-07-21 12:38:52 +0200
commit25423c50e504676f15c7a57c03aad40bfc35c7e6 (patch)
tree811649e2ec44e0332e601c6563e00e914d355b9a /sdnr/wt/common-yang/utils/src/main
parentcea47224b7b6afdd7b3d3ead8d08baf46eadc575 (diff)
migrate sdnr features to sulfur
fix sdnr code for sulfur Issue-ID: CCSDK-3692 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com> Change-Id: I0a62ade424bb978222e7ce6450215fb327f957b7 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/YangToolsMapper.java26
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java13
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java6
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java151
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java146
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java50
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java30
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/SetDeserializer.java39
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java25
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java25
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java25
-rw-r--r--sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java25
12 files changed, 353 insertions, 208 deletions
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper.java
index 7d73afae0..0d9045658 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper.java
@@ -46,7 +46,8 @@ public class YangToolsMapper extends ObjectMapper {
private final YangToolsBuilderAnnotationIntrospector annotationIntrospector;
private final YangToolsModule module;
private static final long serialVersionUID = 1L;
- private boolean isModuleRegistered=false;
+ private boolean isModuleRegistered = false;
+
public YangToolsMapper() {
this(new YangToolsBuilderAnnotationIntrospector());
}
@@ -63,6 +64,7 @@ public class YangToolsMapper extends ObjectMapper {
enable(MapperFeature.USE_GETTERS_AS_SETTERS);
setAnnotationIntrospector(yangToolsBuilderAnnotationIntrospector);
}
+
public void addDeserializer(Class<?> clsToDeserialize, String builderClassName) {
this.annotationIntrospector.addDeserializer(clsToDeserialize, builderClassName);
}
@@ -70,21 +72,23 @@ public class YangToolsMapper extends ObjectMapper {
public void addKeyDeserializer(Class<?> type, KeyDeserializer deserializer) {
this.module.addKeyDeserializer(type, deserializer);
}
+
@Override
public <T> T readValue(String content, Class<T> valueType) throws JsonProcessingException, JsonMappingException {
- if(!this.isModuleRegistered) {
- this.registerModule(this.module);
- this.isModuleRegistered=true;
- }
- return super.readValue(content, valueType);
+ if (!this.isModuleRegistered) {
+ this.registerModule(this.module);
+ this.isModuleRegistered = true;
+ }
+ return super.readValue(content, valueType);
}
+
@Override
public String writeValueAsString(Object value) throws JsonProcessingException {
- if(!this.isModuleRegistered) {
- this.registerModule(this.module);
- this.isModuleRegistered=true;
- }
- return super.writeValueAsString(value);
+ if (!this.isModuleRegistered) {
+ this.registerModule(this.module);
+ this.isModuleRegistered = true;
+ }
+ return super.writeValueAsString(value);
}
}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java
index 5c5aeb6de..6b5704078 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapper2.java
@@ -22,6 +22,8 @@
package org.onap.ccsdk.features.sdnr.wt.yang.mapper;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
import javax.annotation.Nullable;
import org.eclipse.jdt.annotation.NonNull;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions.YangToolsBuilderAnnotationIntrospector;
@@ -40,7 +42,7 @@ public class YangToolsMapper2<T extends DataObject> extends YangToolsMapper {
private static final Logger LOG = LoggerFactory.getLogger(YangToolsMapper2.class);
private static final long serialVersionUID = 1L;
- private @Nullable final Class<? extends Builder<? extends T>> builderClazz;
+ private @Nullable final Class<?> builderClazz;
/**
* Generic Object creation of yangtools java class builder pattern.
@@ -52,7 +54,7 @@ public class YangToolsMapper2<T extends DataObject> extends YangToolsMapper {
* If null the clazz is expected to support normal jackson build pattern.
* @throws ClassNotFoundException if builderClazz not available in bundle
*/
- public <X extends T, B extends Builder<X>> YangToolsMapper2(@NonNull Class<T> clazz,
+ public <X extends T, B> YangToolsMapper2(@NonNull Class<T> clazz,
@Nullable Class<B> builderClazz) throws ClassNotFoundException {
super(new YangToolsBuilderAnnotationIntrospector(clazz, builderClazz));
@@ -67,10 +69,10 @@ public class YangToolsMapper2<T extends DataObject> extends YangToolsMapper {
* @param clazz class with interface.
* @return builder for interface or null if not existing
*/
- public @Nullable Builder<? extends T> getBuilder(Class<T> clazz) {
+ public @Nullable<B> B getBuilder(Class<T> clazz) {
try {
if (builderClazz != null)
- return builderClazz.getDeclaredConstructor().newInstance();
+ return (B) builderClazz.getDeclaredConstructor().newInstance();
else
return null;
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
@@ -90,8 +92,9 @@ public class YangToolsMapper2<T extends DataObject> extends YangToolsMapper {
* @throws ClassNotFoundException
*/
@SuppressWarnings("unchecked")
- private <X extends T, B extends Builder<X>> Class<B> getBuilderClass(String name) throws ClassNotFoundException {
+ private <X extends T, B> Class<B> getBuilderClass(String name) throws ClassNotFoundException {
return (Class<B>) YangToolsMapperHelper.getBuilderClass(name);
}
+
}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java
index fe7631a6d..e72e962bb 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java
@@ -311,4 +311,10 @@ public class YangToolsMapperHelper {
public static <K extends Identifier<V>, V extends Identifiable<K>> Map<K,V> toMap(List<V> list) {
return list == null || list.isEmpty() ? null : Maps.uniqueIndex(list, Identifiable::key);
}
+
+ @SuppressWarnings("unchecked")
+ public static <S,T> T callBuild(S builder) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Method method = builder.getClass().getMethod("build");
+ return (T) method.invoke(builder);
+ }
}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java
index 0fe8ab9d7..b7f1782b6 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier.java
@@ -29,18 +29,19 @@ import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.KeyDeserializer;
import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;
-import com.fasterxml.jackson.databind.type.ArrayType;
import com.fasterxml.jackson.databind.type.MapType;
-
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.NoSuchElementException;
import java.util.Optional;
+import java.util.Set;
+
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.BaseIdentityDeserializer;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.ClassDeserializer;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.IdentifierDeserializer;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.SetDeserializer;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize.TypeObjectDeserializer;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.binding.Identifier;
@@ -51,87 +52,87 @@ import org.slf4j.LoggerFactory;
public class YangToolsDeserializerModifier extends BeanDeserializerModifier {
- private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier.class);
- private static final String getEnumMethodName = "valueOf";
- private static final String getEnumMethodName2 = "forName";
+ private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier.class);
+ private static final String getEnumMethodName = "valueOf";
+ private static final String getEnumMethodName2 = "forName";
- @SuppressWarnings("unchecked")
- public static Enum<?> parseEnum(String value, Class<?> clazz) throws IllegalAccessException,
- IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- try {
- Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class);
- Enum<?> result = (Enum<?>) method.invoke(null, value);
- LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result);
- return result;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
- | NoSuchElementException | SecurityException e) {
- Method method = clazz.getDeclaredMethod(getEnumMethodName2, String.class);
- Optional<Enum<?>> result = (Optional<Enum<?>>) method.invoke(null, value);
- LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result);
- return result.orElseThrow();
- }
- }
+ @SuppressWarnings("unchecked")
+ public static Enum<?> parseEnum(String value, Class<?> clazz) throws IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ try {
+ Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class);
+ Enum<?> result = (Enum<?>) method.invoke(null, value);
+ LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result);
+ return result;
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | NoSuchElementException | SecurityException e) {
+ Method method = clazz.getDeclaredMethod(getEnumMethodName2, String.class);
+ Optional<Enum<?>> result = (Optional<Enum<?>>) method.invoke(null, value);
+ LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result);
+ return result.orElseThrow();
+ }
+ }
- @Override
- public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type,
- BeanDescription beanDesc, final JsonDeserializer<?> deserializer) {
- return new JsonDeserializer<Enum<?>>() {
+ @Override
+ public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type,
+ BeanDescription beanDesc, final JsonDeserializer<?> deserializer) {
+ return new JsonDeserializer<Enum<?>>() {
- @Override
- public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- Class<?> clazz = type.getRawClass();
+ @Override
+ public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
+ Class<?> clazz = type.getRawClass();
- try {
- return parseEnum(jp.getValueAsString(), clazz);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | NoSuchMethodException | NoSuchElementException | SecurityException e) {
- LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(),
- jp.getValueAsString(), e);
- }
- throw new IOException(
- "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString());
- }
- };
- }
+ try {
+ return parseEnum(jp.getValueAsString(), clazz);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | NoSuchMethodException | NoSuchElementException | SecurityException e) {
+ LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(),
+ jp.getValueAsString(), e);
+ }
+ throw new IOException(
+ "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString());
+ }
+ };
+ }
- @Override
- public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc,
- JsonDeserializer<?> deserializer) {
- final JavaType type = beanDesc.getType();
- final Class<?> rawClass = type.getRawClass();
+ @Override
+ public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc,
+ JsonDeserializer<?> deserializer) {
+ final JavaType type = beanDesc.getType();
+ final Class<?> rawClass = type.getRawClass();
- JsonDeserializer<?> deser = super.modifyDeserializer(config, beanDesc, deserializer);
+ JsonDeserializer<?> deser = super.modifyDeserializer(config, beanDesc, deserializer);
- if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) {
- deser = new TypeObjectDeserializer<TypeObject>(type, deser);
- } else if (YangToolsMapperHelper.implementsInterface(rawClass, ScalarTypeObject.class)) {
- deser = new TypeObjectDeserializer<ScalarTypeObject<?>>(type, deser);
- } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) {
- deser = new BaseIdentityDeserializer<BaseIdentity>(deser);
- } else if (rawClass.equals(Class.class)) {
- deser = new ClassDeserializer(rawClass);
- }
+ if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) {
+ deser = new TypeObjectDeserializer<TypeObject>(type, deser);
+ } else if (YangToolsMapperHelper.implementsInterface(rawClass, ScalarTypeObject.class)) {
+ deser = new TypeObjectDeserializer<ScalarTypeObject<?>>(type, deser);
+ } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) {
+ deser = new BaseIdentityDeserializer<BaseIdentity>(deser);
+ } else if (rawClass.equals(Class.class)) {
+ deser = new ClassDeserializer(rawClass);
+ }
- LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName());
- return deser;
- }
+ LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName());
+ return deser;
+ }
- @Override
- public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type,
- BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
- final Class<?> rawClass = type.getBindings().getBoundType(1).getRawClass();
- return new YangtoolsMapDesirializer(rawClass);
- }
+ @Override
+ public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type,
+ BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
+ final Class<?> rawClass = type.getBindings().getBoundType(1).getRawClass();
+ return new YangtoolsMapDesirializer(rawClass);
+ }
- @Override
- public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) {
- KeyDeserializer res;
- if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) {
- res = new IdentifierDeserializer();
- } else {
- res = super.modifyKeyDeserializer(config, type, deser);
- }
- LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName());
- return res;
- }
+ @Override
+ public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) {
+ KeyDeserializer res;
+ if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) {
+ res = new IdentifierDeserializer();
+ } else {
+ res = super.modifyKeyDeserializer(config, type, deser);
+ }
+ LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName());
+ return res;
+ }
}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java
index 0697f5f2e..800f41481 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangToolsDeserializerModifier2.java
@@ -49,87 +49,87 @@ import org.slf4j.LoggerFactory;
public class YangToolsDeserializerModifier2 extends BeanDeserializerModifier {
- private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier2.class);
- private static final String getEnumMethodName = "valueOf";
- private static final String getEnumMethodName2 = "forName";
+ private static final Logger LOG = LoggerFactory.getLogger(YangToolsDeserializerModifier2.class);
+ private static final String getEnumMethodName = "valueOf";
+ private static final String getEnumMethodName2 = "forName";
- @SuppressWarnings("unchecked")
- public static Enum<?> parseEnum(String value, Class<?> clazz) throws IllegalAccessException,
- IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- try {
- Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class);
- Enum<?> result = (Enum<?>) method.invoke(null, value);
- LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result);
- return result;
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
- | NoSuchElementException | SecurityException e) {
- Method method = clazz.getDeclaredMethod(getEnumMethodName2, String.class);
- Optional<Enum<?>> result = (Optional<Enum<?>>) method.invoke(null, value);
- LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result);
- return result.orElseThrow();
- }
- }
+ @SuppressWarnings("unchecked")
+ public static Enum<?> parseEnum(String value, Class<?> clazz) throws IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+ try {
+ Method method = clazz.getDeclaredMethod(getEnumMethodName, String.class);
+ Enum<?> result = (Enum<?>) method.invoke(null, value);
+ LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result);
+ return result;
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | NoSuchElementException | SecurityException e) {
+ Method method = clazz.getDeclaredMethod(getEnumMethodName2, String.class);
+ Optional<Enum<?>> result = (Optional<Enum<?>>) method.invoke(null, value);
+ LOG.debug("Deserialize '{}' with class '{}' to '{}'", value, clazz.getName(), result);
+ return result.orElseThrow();
+ }
+ }
- @Override
- public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type,
- BeanDescription beanDesc, final JsonDeserializer<?> deserializer) {
- return new JsonDeserializer<Enum<?>>() {
+ @Override
+ public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type,
+ BeanDescription beanDesc, final JsonDeserializer<?> deserializer) {
+ return new JsonDeserializer<Enum<?>>() {
- @Override
- public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- Class<?> clazz = type.getRawClass();
+ @Override
+ public Enum<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
+ Class<?> clazz = type.getRawClass();
- try {
- return parseEnum(jp.getValueAsString(), clazz);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | NoSuchMethodException | NoSuchElementException | SecurityException e) {
- LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(),
- jp.getValueAsString(), e);
- }
- throw new IOException(
- "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString());
- }
- };
- }
+ try {
+ return parseEnum(jp.getValueAsString(), clazz);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | NoSuchMethodException | NoSuchElementException | SecurityException e) {
+ LOG.warn("problem deserializing enum for {} with value {}: {}", clazz.getName(),
+ jp.getValueAsString(), e);
+ }
+ throw new IOException(
+ "unable to parse enum (" + type.getRawClass() + ")for value " + jp.getValueAsString());
+ }
+ };
+ }
- @Override
- public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc,
- JsonDeserializer<?> deserializer) {
- final JavaType type = beanDesc.getType();
- final Class<?> rawClass = type.getRawClass();
+ @Override
+ public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc,
+ JsonDeserializer<?> deserializer) {
+ final JavaType type = beanDesc.getType();
+ final Class<?> rawClass = type.getRawClass();
- JsonDeserializer<?> deser = super.modifyDeserializer(config, beanDesc, deserializer);
+ JsonDeserializer<?> deser = super.modifyDeserializer(config, beanDesc, deserializer);
- if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) {
- deser = new TypeObjectDeserializer<TypeObject>(type, deser);
- } else if (YangToolsMapperHelper.implementsInterface(rawClass, ScalarTypeObject.class)) {
- deser = new TypeObjectDeserializer<ScalarTypeObject<?>>(type, deser);
- } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) {
- deser = new BaseIdentityDeserializer<BaseIdentity>(deser);
- } else if (rawClass.equals(Class.class)) {
- deser = new ClassDeserializer(rawClass);
- }
+ if (YangToolsMapperHelper.implementsInterface(rawClass, TypeObject.class)) {
+ deser = new TypeObjectDeserializer<TypeObject>(type, deser);
+ } else if (YangToolsMapperHelper.implementsInterface(rawClass, ScalarTypeObject.class)) {
+ deser = new TypeObjectDeserializer<ScalarTypeObject<?>>(type, deser);
+ } else if (YangToolsMapperHelper.implementsInterface(rawClass, BaseIdentity.class)) {
+ deser = new BaseIdentityDeserializer<BaseIdentity>(deser);
+ } else if (rawClass.equals(Class.class)) {
+ deser = new ClassDeserializer(rawClass);
+ }
- LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName());
- return deser;
- }
+ LOG.debug("Deserialize '{}' with deserializer '{}'", rawClass.getName(), deser.getClass().getName());
+ return deser;
+ }
- @Override
- public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type,
- BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
- final Class<?> rawClass = type.getBindings().getBoundType(1).getRawClass();
- return new YangtoolsMapDesirializer(rawClass);
- }
+ @Override
+ public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type,
+ BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
+ final Class<?> rawClass = type.getBindings().getBoundType(1).getRawClass();
+ return new YangtoolsMapDesirializer(rawClass);
+ }
- @Override
- public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) {
- KeyDeserializer res;
- if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) {
- res = new IdentifierDeserializer();
- } else {
- res = super.modifyKeyDeserializer(config, type, deser);
- }
- LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName());
- return res;
- }
+ @Override
+ public KeyDeserializer modifyKeyDeserializer(DeserializationConfig config, JavaType type, KeyDeserializer deser) {
+ KeyDeserializer res;
+ if (YangToolsMapperHelper.implementsInterface(type.getRawClass(), Identifier.class)) {
+ res = new IdentifierDeserializer();
+ } else {
+ res = super.modifyKeyDeserializer(config, type, deser);
+ }
+ LOG.debug("Keydeserialize '{}' with deserializer '{}'", type.getRawClass().getName(), res.getClass().getName());
+ return res;
+ }
}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java
index 2fe7fa11f..922257d13 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer.java
@@ -1,44 +1,36 @@
package org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.type.CollectionLikeType;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.Identifier;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.ObjectCodec;
-import com.fasterxml.jackson.core.TreeNode;
-import com.fasterxml.jackson.databind.BeanDescription;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.type.CollectionLikeType;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import com.google.common.collect.Maps;
public class YangtoolsMapDesirializer<K extends Identifier<V>, V extends Identifiable<K>>
- extends JsonDeserializer<Map<K, V>> {
+ extends JsonDeserializer<Map<K, V>> {
+
+ private final Class<V> clazz;
+ private final YangToolsMapper mapper;
- private final Class<V> clazz;
- private final YangToolsMapper mapper;
-
- public YangtoolsMapDesirializer(Class<V> clazz) {
- super();
- this.clazz = clazz;
- this.mapper = new YangToolsMapper();
- }
+ public YangtoolsMapDesirializer(Class<V> clazz) {
+ super();
+ this.clazz = clazz;
+ this.mapper = new YangToolsMapper();
+ }
- @Override
- public Map<K, V> deserialize(JsonParser p, DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
- CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(List.class, clazz);
- List<V> list = mapper.readValue(p,type);
- return YangToolsMapperHelper.toMap(list);
- }
+ @Override
+ public Map<K, V> deserialize(JsonParser p, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(List.class, clazz);
+ List<V> list = mapper.readValue(p, type);
+ return YangToolsMapperHelper.toMap(list);
+ }
}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java
index 6a419eee1..4a52f57ee 100644
--- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/mapperextensions/YangtoolsMapDesirializer2.java
@@ -14,23 +14,23 @@ import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.Identifier;
public class YangtoolsMapDesirializer2<K extends Identifier<V>, V extends Identifiable<K>>
- extends JsonDeserializer<Map<K, V>> {
+ extends JsonDeserializer<Map<K, V>> {
- private final Class<V> clazz;
- private final YangToolsMapper mapper;
+ private final Class<V> clazz;
+ private final YangToolsMapper mapper;
- public YangtoolsMapDesirializer2(Class<V> clazz) {
- super();
- this.clazz = clazz;
- this.mapper = new YangToolsMapper();
- }
+ public YangtoolsMapDesirializer2(Class<V> clazz) {
+ super();
+ this.clazz = clazz;
+ this.mapper = new YangToolsMapper();
+ }
- @Override
- public Map<K, V> deserialize(JsonParser p, DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
- CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(List.class, clazz);
- List<V> list = mapper.readValue(p,type);
- return YangToolsMapperHelper.toMap(list);
- }
+ @Override
+ public Map<K, V> deserialize(JsonParser p, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(List.class, clazz);
+ List<V> list = mapper.readValue(p, type);
+ return YangToolsMapperHelper.toMap(list);
+ }
}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/SetDeserializer.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/SetDeserializer.java
new file mode 100644
index 000000000..2ab3fe7c3
--- /dev/null
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/serialize/SetDeserializer.java
@@ -0,0 +1,39 @@
+package org.onap.ccsdk.features.sdnr.wt.yang.mapper.serialize;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.type.CollectionLikeType;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+
+public class SetDeserializer<V>
+ extends JsonDeserializer<Set<V>> {
+
+ private final Class<V> clazz;
+ private final YangToolsMapper mapper;
+
+ public SetDeserializer(Class<V> clazz) {
+ super();
+ this.clazz = clazz;
+ this.mapper = new YangToolsMapper();
+ }
+
+ @Override
+ public Set<V> deserialize(JsonParser p, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ CollectionLikeType type = ctxt.getTypeFactory().constructCollectionType(Set.class, clazz);
+ List<V> list = mapper.readValue(p, type);
+ return new HashSet<>(list);
+ }
+
+}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java
new file mode 100644
index 000000000..3d859e8b5
--- /dev/null
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/HostBuilder.java
@@ -0,0 +1,25 @@
+package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715;
+import java.lang.String;
+import java.lang.UnsupportedOperationException;
+import javax.annotation.processing.Generated;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+@Generated("mdsal-binding-generator")
+public class HostBuilder {
+ private HostBuilder() {
+ //Exists only to defeat instantiation.
+ }
+
+ public static Host getDefaultInstance(String defaultValue) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java
new file mode 100644
index 000000000..62771f669
--- /dev/null
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressBuilder.java
@@ -0,0 +1,25 @@
+package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715;
+import java.lang.String;
+import java.lang.UnsupportedOperationException;
+import javax.annotation.processing.Generated;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+@Generated("mdsal-binding-generator")
+public class IpAddressBuilder {
+ private IpAddressBuilder() {
+ //Exists only to defeat instantiation.
+ }
+
+ public static IpAddress getDefaultInstance(String defaultValue) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java
new file mode 100644
index 000000000..d7b295263
--- /dev/null
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpAddressNoZoneBuilder.java
@@ -0,0 +1,25 @@
+package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715;
+import java.lang.String;
+import java.lang.UnsupportedOperationException;
+import javax.annotation.processing.Generated;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+@Generated("mdsal-binding-generator")
+public class IpAddressNoZoneBuilder {
+ private IpAddressNoZoneBuilder() {
+ //Exists only to defeat instantiation.
+ }
+
+ public static IpAddressNoZone getDefaultInstance(String defaultValue) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+}
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java
new file mode 100644
index 000000000..d5fff3db4
--- /dev/null
+++ b/sdnr/wt/common-yang/utils/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev130715/IpPrefixBuilder.java
@@ -0,0 +1,25 @@
+package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715;
+import java.lang.String;
+import java.lang.UnsupportedOperationException;
+import javax.annotation.processing.Generated;
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ *
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ *
+ */
+@Generated("mdsal-binding-generator")
+public class IpPrefixBuilder {
+ private IpPrefixBuilder() {
+ //Exists only to defeat instantiation.
+ }
+
+ public static IpPrefix getDefaultInstance(String defaultValue) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+}