use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.
the class GaeEntityState method initializeValueTypes.
private HashMap<QualifiedName, ValueType> initializeValueTypes(EntityDescriptor descriptor) {
HashMap<QualifiedName, ValueType> result = new HashMap<QualifiedName, ValueType>();
for (PropertyDescriptor persistent : descriptor.state().properties()) {
if (persistent.valueType() instanceof ValueCompositeType) {
QualifiedName name = persistent.qualifiedName();
result.put(name, persistent.valueType());
}
}
return result;
}
use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.
the class AbstractCollectionSerializationTest method givenCollectionTypeWithBigDecimalAndNullElementWhenSerializingAndDeserializingExpectEquals.
@Test
public void givenCollectionTypeWithBigDecimalAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
String output = valueSerialization.serialize(bigDecimalCollection());
CollectionType collectionType = new CollectionType(Collection.class, new ValueType(BigDecimal.class));
Collection<BigDecimal> collection = valueSerialization.deserialize(collectionType, output);
assertEquals(bigDecimalCollection(), collection);
}
use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.
the class AbstractCollectionSerializationTest method givenCollectionTypeWithFloatAndNullElementWhenSerializingAndDeserializingExpectEquals.
@Test
public void givenCollectionTypeWithFloatAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
String output = valueSerialization.serialize(floatCollection());
CollectionType collectionType = new CollectionType(List.class, new ValueType(Float.class));
List<Float> list = valueSerialization.deserialize(collectionType, output);
assertEquals(floatCollection(), list);
}
use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.
the class AbstractCollectionSerializationTest method givenListOfMapStringStringAndNullElementWhenSerializingAndDeserializingExpectEquals.
@Test
public void givenListOfMapStringStringAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
String output = valueSerialization.serialize(stringListOfMaps());
ValueType stringType = new ValueType(String.class);
CollectionType collectionType = new CollectionType(List.class, new MapType(Map.class, stringType, stringType));
List<Map<String, String>> value = valueSerialization.deserialize(collectionType, output);
assertEquals(stringListOfMaps(), value);
}
use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.
the class ValueDeserializerAdapter method deserializeNodeValueComposite.
private <T> T deserializeNodeValueComposite(ValueType valueType, InputNodeType inputNode) throws Exception {
ValueCompositeType valueCompositeType = (ValueCompositeType) valueType;
Class<?> valueBuilderType = first(valueCompositeType.types());
String typeInfo = this.<String>getObjectFieldValue(inputNode, "_type", this.<String>buildDeserializeInputNodeFunction(new ValueType(String.class)));
TREE_PARSING_LOG.trace("In deserializeNodeValueComposite(), getObjectFieldValue( {} ) returned '{}'", inputNode, typeInfo);
if (typeInfo != null) {
ValueDescriptor valueDescriptor = valuesModule().valueDescriptor(typeInfo);
if (valueDescriptor == null) {
throw new ValueSerializationException("Specified value type could not be resolved: " + typeInfo);
}
valueCompositeType = valueDescriptor.valueType();
valueBuilderType = Class.forName(typeInfo);
if (!valueType.equals(valueCompositeType)) {
TREE_PARSING_LOG.debug("Overriding {} with {} as defined in _type field.", valueType, valueCompositeType);
}
}
return deserializeValueComposite(valueCompositeType, valueBuilderType, inputNode);
}
Aggregations