Search in sources :

Example 1 with ByteArrayTypeHandler

use of org.terasology.persistence.typeHandling.coreTypes.ByteArrayTypeHandler in project Terasology by MovingBlocks.

the class BytesTypeHandlerTest method byteArraySerializeDeserialize.

@Test
void byteArraySerializeDeserialize() {
    byte[] expectedObj = new byte[] { (byte) 0xFF };
    PersistedBytes data = serialize(expectedObj, new ByteArrayTypeHandler());
    Assertions.assertEquals(expectedObj, data.getAsBytes());
    byte[] obj = deserialize(data, new ByteArrayTypeHandler());
    Assertions.assertEquals(expectedObj, obj);
}
Also used : ByteArrayTypeHandler(org.terasology.persistence.typeHandling.coreTypes.ByteArrayTypeHandler) PersistedBytes(org.terasology.persistence.typeHandling.inMemory.PersistedBytes) Test(org.junit.jupiter.api.Test)

Example 2 with ByteArrayTypeHandler

use of org.terasology.persistence.typeHandling.coreTypes.ByteArrayTypeHandler in project Terasology by MovingBlocks.

the class TypeHandlerLibrary method populateBuiltInHandlers.

static void populateBuiltInHandlers(TypeHandlerLibrary typeHandlerLibrary) {
    typeHandlerLibrary.addTypeHandler(Boolean.class, new BooleanTypeHandler());
    typeHandlerLibrary.addTypeHandler(Boolean.TYPE, new BooleanTypeHandler());
    typeHandlerLibrary.addTypeHandler(Byte.class, new ByteTypeHandler());
    typeHandlerLibrary.addTypeHandler(Byte.TYPE, new ByteTypeHandler());
    typeHandlerLibrary.addTypeHandler(Character.class, new CharacterTypeHandler());
    typeHandlerLibrary.addTypeHandler(Character.TYPE, new CharacterTypeHandler());
    typeHandlerLibrary.addTypeHandler(Double.class, new DoubleTypeHandler());
    typeHandlerLibrary.addTypeHandler(Double.TYPE, new DoubleTypeHandler());
    typeHandlerLibrary.addTypeHandler(Float.class, new FloatTypeHandler());
    typeHandlerLibrary.addTypeHandler(Float.TYPE, new FloatTypeHandler());
    typeHandlerLibrary.addTypeHandler(Integer.class, new IntTypeHandler());
    typeHandlerLibrary.addTypeHandler(Integer.TYPE, new IntTypeHandler());
    typeHandlerLibrary.addTypeHandler(Long.class, new LongTypeHandler());
    typeHandlerLibrary.addTypeHandler(Long.TYPE, new LongTypeHandler());
    typeHandlerLibrary.addTypeHandler(String.class, new StringTypeHandler());
    typeHandlerLibrary.addTypeHandler(Number.class, new NumberTypeHandler());
    typeHandlerLibrary.addTypeHandler(Locale.class, new LocaleTypeHandler());
    typeHandlerLibrary.addTypeHandlerFactory(new ArrayTypeHandlerFactory());
    typeHandlerLibrary.addTypeHandler(byte[].class, new ByteArrayTypeHandler());
    typeHandlerLibrary.addTypeHandlerFactory(new EnumTypeHandlerFactory());
    typeHandlerLibrary.addTypeHandlerFactory(new MapTypeHandlerFactory());
}
Also used : DoubleTypeHandler(org.terasology.persistence.typeHandling.coreTypes.DoubleTypeHandler) ObjectFieldMapTypeHandlerFactory(org.terasology.persistence.typeHandling.coreTypes.factories.ObjectFieldMapTypeHandlerFactory) MapTypeHandlerFactory(org.terasology.persistence.typeHandling.coreTypes.factories.MapTypeHandlerFactory) ArrayTypeHandlerFactory(org.terasology.persistence.typeHandling.coreTypes.factories.ArrayTypeHandlerFactory) ByteTypeHandler(org.terasology.persistence.typeHandling.coreTypes.ByteTypeHandler) LocaleTypeHandler(org.terasology.persistence.typeHandling.coreTypes.LocaleTypeHandler) CharacterTypeHandler(org.terasology.persistence.typeHandling.coreTypes.CharacterTypeHandler) BooleanTypeHandler(org.terasology.persistence.typeHandling.coreTypes.BooleanTypeHandler) LongTypeHandler(org.terasology.persistence.typeHandling.coreTypes.LongTypeHandler) StringTypeHandler(org.terasology.persistence.typeHandling.coreTypes.StringTypeHandler) ByteArrayTypeHandler(org.terasology.persistence.typeHandling.coreTypes.ByteArrayTypeHandler) IntTypeHandler(org.terasology.persistence.typeHandling.coreTypes.IntTypeHandler) FloatTypeHandler(org.terasology.persistence.typeHandling.coreTypes.FloatTypeHandler) EnumTypeHandlerFactory(org.terasology.persistence.typeHandling.coreTypes.factories.EnumTypeHandlerFactory) NumberTypeHandler(org.terasology.persistence.typeHandling.coreTypes.NumberTypeHandler)

Aggregations

ByteArrayTypeHandler (org.terasology.persistence.typeHandling.coreTypes.ByteArrayTypeHandler)2 Test (org.junit.jupiter.api.Test)1 BooleanTypeHandler (org.terasology.persistence.typeHandling.coreTypes.BooleanTypeHandler)1 ByteTypeHandler (org.terasology.persistence.typeHandling.coreTypes.ByteTypeHandler)1 CharacterTypeHandler (org.terasology.persistence.typeHandling.coreTypes.CharacterTypeHandler)1 DoubleTypeHandler (org.terasology.persistence.typeHandling.coreTypes.DoubleTypeHandler)1 FloatTypeHandler (org.terasology.persistence.typeHandling.coreTypes.FloatTypeHandler)1 IntTypeHandler (org.terasology.persistence.typeHandling.coreTypes.IntTypeHandler)1 LocaleTypeHandler (org.terasology.persistence.typeHandling.coreTypes.LocaleTypeHandler)1 LongTypeHandler (org.terasology.persistence.typeHandling.coreTypes.LongTypeHandler)1 NumberTypeHandler (org.terasology.persistence.typeHandling.coreTypes.NumberTypeHandler)1 StringTypeHandler (org.terasology.persistence.typeHandling.coreTypes.StringTypeHandler)1 ArrayTypeHandlerFactory (org.terasology.persistence.typeHandling.coreTypes.factories.ArrayTypeHandlerFactory)1 EnumTypeHandlerFactory (org.terasology.persistence.typeHandling.coreTypes.factories.EnumTypeHandlerFactory)1 MapTypeHandlerFactory (org.terasology.persistence.typeHandling.coreTypes.factories.MapTypeHandlerFactory)1 ObjectFieldMapTypeHandlerFactory (org.terasology.persistence.typeHandling.coreTypes.factories.ObjectFieldMapTypeHandlerFactory)1 PersistedBytes (org.terasology.persistence.typeHandling.inMemory.PersistedBytes)1