use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.
the class AbstractCollectionSerializationTest method givenIterableTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals.
@Test
public void givenIterableTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
String output = valueSerialization.serialize(Iterables.iterable(byteCollection().toArray()));
CollectionType collectionType = new CollectionType(List.class, new ValueType(Byte.class));
List<Byte> list = valueSerialization.deserialize(collectionType, output);
assertEquals(byteCollection(), list);
}
use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.
the class AbstractCollectionSerializationTest method givenCollectionTypeWithShortAndNullElementWhenSerializingAndDeserializingExpectEquals.
@Test
public void givenCollectionTypeWithShortAndNullElementWhenSerializingAndDeserializingExpectEquals() throws Exception {
String output = valueSerialization.serialize(shortCollection());
CollectionType collectionType = new CollectionType(List.class, new ValueType(Short.class));
List<Short> list = valueSerialization.deserialize(collectionType, output);
assertEquals(shortCollection(), list);
}
use of org.qi4j.api.type.ValueType in project qi4j-sdk by Qi4j.
the class GaeEntityState method propertyValueOf.
@Override
public Object propertyValueOf(QualifiedName stateName) {
String uri = stateName.toURI();
Object value = entity.getProperty(uri);
if (value instanceof Text) {
value = ((Text) value).getValue();
}
ValueType type = valueTypes.get(stateName);
if (value != null && type != null) {
try {
value = valueSerialization.deserialize(type, value.toString());
} catch (ValueSerializationException e) {
String message = "\nqualifiedName: " + stateName + "\n stateName: " + stateName.name() + "\n uri: " + uri + "\n type: " + type + "\n value: " + value + "\n";
InternalError error = new InternalError(message);
error.initCause(e);
throw error;
}
}
System.out.println("getProperty( " + stateName + " ) --> " + uri + "=" + value);
return value;
}
Aggregations