import java.util.Map.Entry;
import java.util.Optional;
import java.util.ServiceLoader;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.util.ClassLoaderUtils;
import org.opendaylight.yangtools.yang.binding.Action;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.binding.BaseNotification;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.DataObject;
// FIXME: this is probably not right w.r.t. nulls
IllegalArgumentCodec<Object, Object> getCodec(final Class<?> valueType, final TypeDefinition<?> instantiatedType) {
- if (Class.class.equals(valueType)) {
+ if (BaseIdentity.class.isAssignableFrom(valueType)) {
@SuppressWarnings({ "unchecked", "rawtypes" })
final IllegalArgumentCodec<Object, Object> casted = (IllegalArgumentCodec) identityCodec;
return casted;
}
// FIXME: MDSAL-670: this is right for most situations, but we must never return NOOP_CODEC for
// valueType=Object.class
- return ValueTypeCodec.NOOP_CODEC;
+ return SchemaUnawareCodec.NOOP_CODEC;
}
@SuppressWarnings("checkstyle:illegalCatch")
private IllegalArgumentCodec<Object, Object> getCodecForBindingClass(final Class<?> valueType,
final TypeDefinition<?> typeDef) {
if (typeDef instanceof IdentityrefTypeDefinition) {
- return ValueTypeCodec.encapsulatedValueCodecFor(valueType, typeDef, identityCodec);
+ return new CompositeValueCodec.OfIdentity(valueType, identityCodec);
} else if (typeDef instanceof InstanceIdentifierTypeDefinition) {
- return ValueTypeCodec.encapsulatedValueCodecFor(valueType, typeDef, instanceIdentifierCodec);
+ return new CompositeValueCodec.OfInstanceIdentifier(valueType, instanceIdentifierCodec);
} else if (typeDef instanceof UnionTypeDefinition) {
- final Callable<UnionTypeCodec> unionLoader = UnionTypeCodec.loader(valueType, (UnionTypeDefinition) typeDef,
- this);
try {
- return unionLoader.call();
- } catch (final Exception e) {
+ return UnionTypeCodec.of(valueType, (UnionTypeDefinition) typeDef, this);
+ } catch (Exception e) {
throw new IllegalStateException("Unable to load codec for " + valueType, e);
}
} else if (typeDef instanceof LeafrefTypeDefinition) {
}
return getCodec(valueType, def);
}
- return ValueTypeCodec.getCodecFor(valueType, typeDef);
+ return SchemaUnawareCodec.of(valueType, typeDef);
}
@Override