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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations