Eliminate ValueTypeCodec.encapsulatedValueCodecFor() 36/100536/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 11 Apr 2022 14:29:53 +0000 (16:29 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 11 Apr 2022 14:49:44 +0000 (16:49 +0200)
There are only two call sites in the same method, inline it and remove
the unnecessary indirection through ValueTypeCodec -- which any reason
for existence except binding IllegalArgumentCodec vtable.

JIRA: MDSAL-704
Change-Id: I11cd0b4f08a1cb8dacd1f66fec9070102ba47889
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/BindingCodecContext.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/ValueTypeCodec.java

index 57426e2e42e27fe92bf577034e1f22b925110d50..1d34844cfd9802f9fecef3aeb94ad54b28400358 100644 (file)
@@ -443,9 +443,9 @@ public final class BindingCodecContext extends AbstractBindingNormalizedNodeSeri
     private IllegalArgumentCodec<Object, Object> getCodecForBindingClass(final Class<?> valueType,
             final TypeDefinition<?> typeDef) {
         if (typeDef instanceof IdentityrefTypeDefinition) {
-            return ValueTypeCodec.encapsulatedValueCodecFor(valueType, typeDef, identityCodec);
+            return new CompositeValueCodec(SchemaUnawareCodec.of(valueType, typeDef), identityCodec);
         } else if (typeDef instanceof InstanceIdentifierTypeDefinition) {
-            return ValueTypeCodec.encapsulatedValueCodecFor(valueType, typeDef, instanceIdentifierCodec);
+            return new CompositeValueCodec(SchemaUnawareCodec.of(valueType, typeDef), instanceIdentifierCodec);
         } else if (typeDef instanceof UnionTypeDefinition) {
             final Callable<UnionTypeCodec> unionLoader = UnionTypeCodec.loader(valueType, (UnionTypeDefinition) typeDef,
                 this);
index d9e3255027a60fb2c92e442c24088b58fd85f874..45343e560fe83e612603b8d895641a74502f53d6 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.mdsal.binding.dom.codec.impl;
 
 import org.opendaylight.yangtools.concepts.IllegalArgumentCodec;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
 /**
  * Value codec, which serializes / deserializes values from DOM simple values.
@@ -16,9 +15,4 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 // FIXME: IllegalArgumentCodec is perhaps not appropriate here due to null behavior
 abstract class ValueTypeCodec implements IllegalArgumentCodec<Object, Object> {
 
-    @SuppressWarnings("rawtypes")
-    static ValueTypeCodec encapsulatedValueCodecFor(final Class<?> typeClz, final TypeDefinition<?> typeDef,
-             final IllegalArgumentCodec delegate) {
-        return new CompositeValueCodec(SchemaUnawareCodec.of(typeClz, typeDef), delegate);
-    }
 }