/** * Encode feature properties by type, we do this way so we can handle the case were these * properties should be encoded as a list or as elements that appear multiple times. */ private void encodePropertiesByType( PropertyType parentType, PropertyType type, List<Property> properties) { PropertyDescriptor multipleType = isMultipleType(parentType, type); if (multipleType == null) { // simple JSON objects properties.forEach(this::encodeProperty); } else { // possible chained features that need to be encoded as a list List<Feature> chainedFeatures = getChainedFeatures(properties); if (chainedFeatures == null || chainedFeatures.isEmpty()) { // let's check if we are in the presence of linked features List<Map<NameImpl, String>> linkedFeatures = getLinkedFeatures(properties); if (!linkedFeatures.isEmpty()) { // encode linked features encodeLinkedFeatures(multipleType.getName().getLocalPart(), linkedFeatures); } else { // no chained or linked features just encode each property properties.forEach(this::encodeProperty); } } else { // chained features so we need to encode the chained features as an array encodeChainedFeatures(multipleType.getName().getLocalPart(), chainedFeatures); } } }