Cleanup ObjectCodec a bit 28/97228/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 13 Aug 2021 19:33:58 +0000 (21:33 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 17 Aug 2021 09:46:57 +0000 (11:46 +0200)
Use a return expression and do not use the useless this.obviously
field references.

Change-Id: I2144d8e855ff56269118df505c43741bb292e282
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 96f7049b19b910561cce75d1b27e950c86dbd5df)

restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/codecs/RestCodec.java

index f0705b1233de76599fe785b89995e10a6dcb0706..96281b41a46b492195c900463e2df3cac9ecf8c2 100644 (file)
@@ -102,9 +102,9 @@ public final class RestCodec {
         @Override
         public Object deserialize(final Object input) {
             try {
-                if (this.type instanceof IdentityrefTypeDefinition) {
+                if (type instanceof IdentityrefTypeDefinition) {
                     if (input instanceof IdentityValuesDTO) {
-                        return this.identityrefCodec.deserialize(input);
+                        return identityrefCodec.deserialize(input);
                     }
                     if (LOG.isDebugEnabled()) {
                         LOG.debug(
@@ -113,14 +113,9 @@ public final class RestCodec {
                             input == null ? "null" : input.getClass(), String.valueOf(input));
                     }
                     return null;
-                } else if (this.type instanceof InstanceIdentifierTypeDefinition) {
-                    if (input instanceof IdentityValuesDTO) {
-                        return this.instanceIdentifier.deserialize(input);
-                    } else {
-                        final StringModuleInstanceIdentifierCodec codec =
-                                new StringModuleInstanceIdentifierCodec(schemaContext);
-                        return codec.deserialize((String) input);
-                    }
+                } else if (type instanceof InstanceIdentifierTypeDefinition) {
+                    return input instanceof IdentityValuesDTO ? instanceIdentifier.deserialize(input)
+                        : new StringModuleInstanceIdentifierCodec(schemaContext).deserialize((String) input);
                 } else {
                     final TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> typeAwarecodec =
                             TypeDefinitionAwareCodec.from(this.type);