Adopt odlparent-10.0.0/yangtools-8.0.0-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / impl / UnionTypeCodec.java
index 41710c97c77a304a5bb34a02c57b981ed5ec0b55..6e4bbdb85f22c16693197aae621abd7cc198c37f 100644 (file)
@@ -83,14 +83,12 @@ final class UnionTypeCodec extends ReflectionBasedCodec {
 
     @Override
     public Object serialize(final Object input) {
-        if (input != null) {
-            for (final UnionValueOptionContext valCtx : typeCodecs) {
-                final Object domValue = valCtx.serialize(input);
-                if (domValue != null) {
-                    return domValue;
-                }
+        for (final UnionValueOptionContext valCtx : typeCodecs) {
+            final Object domValue = valCtx.serialize(input);
+            if (domValue != null) {
+                return domValue;
             }
         }
-        return null;
+        throw new IllegalStateException("No codec matched value " + input);
     }
 }