use of org.polymap.core.style.model.feature.NoValue in project polymap4-core by Polymap4.
the class StyleCompositeSerializer method handle.
protected <V> Iterable<RuleModifier<V, S>> handle(Property<StylePropertyValue<V>> prop) {
StylePropertyValue<V> styleProp = prop.get();
// no value -> nothing to modify
if (styleProp == null || styleProp instanceof NoValue) {
return singletonList(new NoValueRuleModifier());
} else // ConstantValue
if (styleProp instanceof ConstantValue) {
Expression expr = ff.literal(((ConstantValue) styleProp).value());
return singletonList(new SimpleRuleModifier(expr));
} else // AttributeValue
if (styleProp instanceof AttributeValue) {
String attributeName = (String) ((AttributeValue) styleProp).attributeName.get();
Expression expr = ff.property(attributeName);
return singletonList(new SimpleRuleModifier(expr));
} else // FilterMappedValues
if (styleProp instanceof FilterMappedValues) {
List<Mapped<Filter, Object>> values = ((FilterMappedValues) styleProp).values();
return FluentIterable.from(values).transform(mapped -> new SimpleRuleModifier(ff.literal(mapped.value()), mapped.key()));
} else // ScaleMappedValues
if (styleProp instanceof ScaleMappedValues) {
List<Mapped<ScaleRange, Object>> values = ((ScaleMappedValues) styleProp).values();
return FluentIterable.from(values).transform(mapped -> new SimpleRuleModifier(ff.literal(mapped.value()), mapped.key().min.get(), mapped.key().max.get()));
} else {
throw new RuntimeException("Unhandled StylePropertyValue type: " + styleProp.getClass().getSimpleName());
}
}
Aggregations