private final SchemaContext schemaContext;
private final JSONCodec<?> iidCodec;
- private final JSONCodec<?> idrefCodec;
private JSONCodecFactory(final SchemaContext context) {
this.schemaContext = Preconditions.checkNotNull(context);
iidCodec = new JSONStringInstanceIdentifierCodec(context);
- idrefCodec = new JSONStringIdentityrefCodec(context);
}
/**
return superType;
}
+ @SuppressWarnings("unchecked")
private JSONCodec<Object> createCodec(DataSchemaNode key, TypeDefinition<?> type) {
TypeDefinition<?> baseType = resolveBaseTypeFrom(type);
if (baseType instanceof LeafrefTypeDefinition) {
return createReferencedTypeCodec(key, (LeafrefTypeDefinition) baseType);
+ } else if (baseType instanceof IdentityrefType) {
+ final JSONCodec<?> jsonStringIdentityrefCodec = new JSONStringIdentityrefCodec(schemaContext,
+ key.getQName().getModule());
+ return (JSONCodec<Object>) jsonStringIdentityrefCodec;
}
return createFromSimpleType(type);
}
// FIXME: Verify if this does indeed support leafref of leafref
TypeDefinition<?> referencedType =
SchemaContextUtil.getBaseTypeForLeafRef(type, getSchemaContext(), schema);
- return createFromSimpleType(referencedType);
+ return createCodec(schema, referencedType);
}
@SuppressWarnings("unchecked")
if (baseType instanceof InstanceIdentifierType) {
return (JSONCodec<Object>) iidCodec;
}
- if (baseType instanceof IdentityrefType) {
- return (JSONCodec<Object>) idrefCodec;
- }
final TypeDefinitionAwareCodec<Object, ?> codec = TypeDefinitionAwareCodec.from(type);
if (codec == null) {