private Object getValue(String value){ if(schemaNode != null){ if(schemaNode instanceof LeafListSchemaNode){ return TypeDefinitionAwareCodec .from(LeafListSchemaNode.class.cast(schemaNode).getType()).deserialize(value); } } return value; }
private static Object domValueFromString(final Codec<Object, Object> codec, final TypeDefinition<?> type, final Object defaultValue) { TypeDefinitionAwareCodec<?, ?> typeDefAwareCodec = TypeDefinitionAwareCodec.from(type); if (typeDefAwareCodec != null) { Object castedDefaultValue = typeDefAwareCodec.deserialize((String) defaultValue); return codec.deserialize(castedDefaultValue); } // FIXME: BUG-4647 Refactor / redesign this to throw hard error, // once BUG-4638 is fixed and will provide proper getDefaultValue implementation. return null; }
private static Object domValueFromString(final Codec<Object, Object> codec, final TypeDefinition<?> type, final Object defaultValue) { final TypeDefinitionAwareCodec<?, ?> typeDefAwareCodec = TypeDefinitionAwareCodec.from(type); if (typeDefAwareCodec != null) { final Object castedDefaultValue = typeDefAwareCodec.deserialize((String) defaultValue); return codec.deserialize(castedDefaultValue); } // FIXME: BUG-4647 Refactor / redesign this to throw hard error, // once BUG-4638 is fixed and will provide proper getDefaultValue implementation. return null; }
if (typeAwarecodec != null) { if (input instanceof IdentityValuesDTO) { return typeAwarecodec.deserialize(((IdentityValuesDTO) input).getOriginValue()); return typeAwarecodec.deserialize(String.valueOf(input)); } else { logger.debug("Codec for type \"" + type.getQName().getLocalName()
@Override @SuppressWarnings("checkstyle:illegalCatch") public Object deserialize(final String stringRepresentation) { if (!getTypeDefinition().isPresent()) { return stringRepresentation; } for (final TypeDefinition<?> type : getTypeDefinition().get().getTypes()) { final TypeDefinitionAwareCodec<Object, ?> typeAwareCodec = from(type); if (typeAwareCodec == null) { /* * This is a type for which we have no codec (eg identity ref) so we'll say it's * valid */ return stringRepresentation; } try { return typeAwareCodec.deserialize(stringRepresentation); } catch (final Exception e) { LOG.debug("Value {} did not matched representation for {}",stringRepresentation,type,e); // invalid - try the next union type. } } throw new IllegalArgumentException("Invalid value \"" + stringRepresentation + "\" for union type."); } }
@Override @SuppressWarnings("checkstyle:illegalCatch") public Object deserialize(final String stringRepresentation) { if (!getTypeDefinition().isPresent()) { return stringRepresentation; } for (final TypeDefinition<?> type : getTypeDefinition().get().getTypes()) { final TypeDefinitionAwareCodec<Object, ?> typeAwareCodec = from(type); if (typeAwareCodec == null) { /* * This is a type for which we have no codec (eg identity ref) so we'll say it's * valid */ return stringRepresentation; } try { return typeAwareCodec.deserialize(stringRepresentation); } catch (final Exception e) { LOG.debug("Value {} did not matched representation for {}",stringRepresentation,type,e); // invalid - try the next union type. } } throw new IllegalArgumentException("Invalid value \"" + stringRepresentation + "\" for union type."); } }
private Object getValue(QName key, String value){ if(listSchemaNode != null){ for(DataSchemaNode node : listSchemaNode.getChildNodes()){ if(node instanceof LeafSchemaNode && node.getQName().equals(key)){ return TypeDefinitionAwareCodec.from(LeafSchemaNode.class.cast(node).getType()).deserialize(value); } } } return value; } }