Search in sources :

Example 1 with PersistedDataArray

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

the class BooleanTypeHandler method deserializeCollection.

@Override
public List<Boolean> deserializeCollection(PersistedData data, DeserializationContext context) {
    if (data.isArray()) {
        PersistedDataArray array = data.getAsArray();
        List<Boolean> result = Lists.newArrayListWithCapacity(array.size());
        for (PersistedData item : array) {
            if (item.isBoolean()) {
                result.add(item.getAsBoolean());
            } else {
                result.add(null);
            }
        }
        return result;
    }
    return Lists.newArrayList();
}
Also used : PersistedDataArray(org.terasology.persistence.typeHandling.PersistedDataArray) PersistedData(org.terasology.persistence.typeHandling.PersistedData)

Example 2 with PersistedDataArray

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

the class DoubleTypeHandler method deserializeCollection.

@Override
public List<Double> deserializeCollection(PersistedData data, DeserializationContext context) {
    if (data.isArray()) {
        PersistedDataArray array = data.getAsArray();
        List<Double> result = Lists.newArrayListWithCapacity(array.size());
        for (PersistedData item : array) {
            if (item.isNumber()) {
                result.add(item.getAsDouble());
            } else {
                result.add(null);
            }
        }
        return result;
    }
    return Lists.newArrayList();
}
Also used : PersistedDataArray(org.terasology.persistence.typeHandling.PersistedDataArray) PersistedData(org.terasology.persistence.typeHandling.PersistedData)

Example 3 with PersistedDataArray

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

the class FloatTypeHandler method deserializeCollection.

@Override
public List<Float> deserializeCollection(PersistedData data, DeserializationContext context) {
    if (data.isArray()) {
        PersistedDataArray array = data.getAsArray();
        List<Float> result = Lists.newArrayListWithCapacity(array.size());
        for (PersistedData item : array) {
            if (item.isNumber()) {
                result.add(item.getAsFloat());
            } else {
                result.add(null);
            }
        }
        return result;
    }
    return Lists.newArrayList();
}
Also used : PersistedDataArray(org.terasology.persistence.typeHandling.PersistedDataArray) PersistedData(org.terasology.persistence.typeHandling.PersistedData)

Example 4 with PersistedDataArray

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

the class IntTypeHandler method deserializeCollection.

@Override
public List<Integer> deserializeCollection(PersistedData data, DeserializationContext context) {
    if (data.isArray()) {
        PersistedDataArray array = data.getAsArray();
        List<Integer> result = Lists.newArrayListWithCapacity(array.size());
        for (PersistedData item : array) {
            if (item.isNumber()) {
                result.add(item.getAsInteger());
            } else {
                result.add(null);
            }
        }
        return result;
    }
    return Lists.newArrayList();
}
Also used : PersistedDataArray(org.terasology.persistence.typeHandling.PersistedDataArray) PersistedData(org.terasology.persistence.typeHandling.PersistedData)

Example 5 with PersistedDataArray

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

the class LongTypeHandler method deserializeCollection.

@Override
public List<Long> deserializeCollection(PersistedData data, DeserializationContext context) {
    if (data.isArray()) {
        PersistedDataArray array = data.getAsArray();
        List<Long> result = Lists.newArrayListWithCapacity(array.size());
        for (PersistedData item : array) {
            if (item.isNumber()) {
                result.add(item.getAsLong());
            } else {
                result.add(null);
            }
        }
        return result;
    }
    return Lists.newArrayList();
}
Also used : PersistedDataArray(org.terasology.persistence.typeHandling.PersistedDataArray) PersistedData(org.terasology.persistence.typeHandling.PersistedData)

Aggregations

PersistedDataArray (org.terasology.persistence.typeHandling.PersistedDataArray)8 PersistedData (org.terasology.persistence.typeHandling.PersistedData)6 TIntList (gnu.trove.list.TIntList)1 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 Vector3i (org.terasology.math.geom.Vector3i)1