Package org.terasology.persistence.typeHandling

Examples of org.terasology.persistence.typeHandling.DeserializationContext


        when(serializationContext.createNull()).thenReturn(nullData);
        EnumTypeHandler<TestEnum> handler = new EnumTypeHandler<>(TestEnum.class);
        PersistedData serializedNull = handler.serialize(null, serializationContext);
        assertEquals(nullData, serializedNull);

        DeserializationContext deserializationContext = mock(DeserializationContext.class);
        TestEnum deserializedValue = handler.deserialize(nullData, deserializationContext);
        assertEquals(null, deserializedValue);
    }
View Full Code Here


        when(serializationContext.create(TestEnum.NON_NULL.toString())).thenReturn(data);
        EnumTypeHandler<TestEnum> handler = new EnumTypeHandler<>(TestEnum.class);
        PersistedData serializedNonNull = handler.serialize(TestEnum.NON_NULL, serializationContext);
        assertEquals(data, serializedNonNull);

        DeserializationContext deserializationContext = mock(DeserializationContext.class);
        TestEnum deserializedValue = handler.deserialize(data, deserializationContext);
        assertEquals(TestEnum.NON_NULL, deserializedValue);
    }
View Full Code Here


    private <T extends Component> Component deserializeOnto(Component targetComponent, EntityData.Component componentData,
                                                            ComponentMetadata<T> componentMetadata, FieldSerializeCheck<Component> fieldCheck) {
        Serializer serializer = typeSerializationLibrary.getSerializerFor(componentMetadata);
        DeserializationContext context = new ProtobufDeserializationContext(typeSerializationLibrary);
        Map<FieldMetadata<?, ?>, PersistedData> dataMap = Maps.newHashMapWithExpectedSize(componentData.getFieldCount());
        for (EntityData.NameValue field : componentData.getFieldList()) {
            FieldMetadata<?, ?> fieldInfo = null;
            if (field.hasNameIndex()) {
                fieldInfo = componentMetadata.getField(field.getNameIndex());
View Full Code Here

TOP

Related Classes of org.terasology.persistence.typeHandling.DeserializationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.