Merge "Simplify method isMutualExclusive in Subnet. Remove redundant 'if' statements."
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / dom / serializer / impl / LazyGeneratedCodecRegistry.java
index 39bd0816f50fb63e68bbbdb85ca7cbdce74812b6..cabb1bc4e2c5359582bc95e1e30514f557801b64 100644 (file)
@@ -175,7 +175,7 @@ public class LazyGeneratedCodecRegistry implements //
                     });
             return ret;
         } catch (Exception e) {
-            LOG.error("Could not find augmentable for {}", augmentation, e);
+            LOG.debug("Could not find augmentable for {} using {}", augmentation, augmentation.getClassLoader(), e);
             return null;
         }
     }
@@ -233,7 +233,7 @@ public class LazyGeneratedCodecRegistry implements //
         if (typeToClass.containsKey(typeRef)) {
             return;
         }
-        LOG.info("Binding Class {} encountered.", cls);
+        LOG.trace("Binding Class {} encountered.", cls);
         WeakReference<Class> weakRef = new WeakReference<>(cls);
         typeToClass.put(typeRef, weakRef);
         if (Augmentation.class.isAssignableFrom(cls)) {
@@ -250,7 +250,7 @@ public class LazyGeneratedCodecRegistry implements //
         if (typeToClass.containsKey(typeRef)) {
             return;
         }
-        LOG.info("Binding Class {} encountered.", cls);
+        LOG.trace("Binding Class {} encountered.", cls);
         WeakReference<Class> weakRef = new WeakReference<>((Class) cls);
         typeToClass.put(typeRef, weakRef);
     }
@@ -389,8 +389,10 @@ public class LazyGeneratedCodecRegistry implements //
     public void onModuleContextAdded(SchemaContext schemaContext, Module module, ModuleContext context) {
         pathToType.putAll(context.getChildNodes());
         qnamesToIdentityMap.putAll(context.getIdentities());
-        for(Entry<QName, GeneratedTOBuilder> identity : context.getIdentities().entrySet()) {
-            typeToQname.put(new ReferencedTypeImpl(identity.getValue().getPackageName(), identity.getValue().getName()),identity.getKey());
+        for (Entry<QName, GeneratedTOBuilder> identity : context.getIdentities().entrySet()) {
+            typeToQname.put(
+                    new ReferencedTypeImpl(identity.getValue().getPackageName(), identity.getValue().getName()),
+                    identity.getKey());
         }
         captureCases(context.getCases(), schemaContext);
     }
@@ -947,12 +949,12 @@ public class LazyGeneratedCodecRegistry implements //
         @Override
         public Class<?> deserialize(QName input) {
             Type type = qnamesToIdentityMap.get(input);
-            if(type == null) {
+            if (type == null) {
                 return null;
             }
             ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
             WeakReference<Class> softref = typeToClass.get(typeref);
-            if(softref == null) {
+            if (softref == null) {
                 return null;
             }
             return softref.get();
@@ -963,12 +965,12 @@ public class LazyGeneratedCodecRegistry implements //
             checkArgument(BaseIdentity.class.isAssignableFrom(input));
             bindingClassEncountered(input);
             QName qname = identityQNames.get(input);
-            if(qname != null) {
+            if (qname != null) {
                 return qname;
             }
             ConcreteType typeref = Types.typeForClass(input);
             qname = typeToQname.get(typeref);
-            if(qname != null) {
+            if (qname != null) {
                 identityQNames.put(input, qname);
             }
             return qname;
@@ -980,4 +982,26 @@ public class LazyGeneratedCodecRegistry implements //
             return serialize((Class) input);
         }
     }
+
+    public boolean isCodecAvailable(Class<? extends DataContainer> cls) {
+        if (containerCodecs.containsKey(cls)) {
+            return true;
+        }
+        if (identifierCodecs.containsKey(cls)) {
+            return true;
+        }
+        if (choiceCodecs.containsKey(cls)) {
+            return true;
+        }
+        if (caseCodecs.containsKey(cls)) {
+            return true;
+        }
+        if (augmentableCodecs.containsKey(cls)) {
+            return true;
+        }
+        if (augmentationCodecs.containsKey(cls)) {
+            return true;
+        }
+        return false;
+    }
 }
\ No newline at end of file