@Test public void testGetFieldOptionsMulti() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); PropertyName thisProperty = ff.property("."); Filter restriction = ff.or( ff.equal(thisProperty, ff.literal("a"), true), ff.equal(thisProperty, ff.literal("b"), true)); AttributeDescriptor descriptor = buildDescriptorWithRestriction(restriction); assertEquals(Arrays.asList("a", "b"), FeatureTypes.getFieldOptions(descriptor)); }
public static List<?> getFieldOptions(PropertyDescriptor descriptor) { PropertyType type = descriptor.getType(); List<Object> options = null; while (type != null) { for (Filter f : type.getRestrictions()) { List<Object> currentOptions = null; boolean foundOptionsPattern = true; if (f == null) { continue; } if (f instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) f); if (value != null) { currentOptions = Collections.singletonList(value); } else { continue; } } else if (f instanceof Or) { Or or = (Or) f; currentOptions = new ArrayList<>(); for (Filter child : or.getChildren()) { if (child instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) child); if (value != null) { currentOptions.add(value); } else { foundOptionsPattern = false; continue; } } else { foundOptionsPattern = false; } } } if (foundOptionsPattern) { if (options != null) { options.retainAll(currentOptions); } else { options = currentOptions; } } } type = type.getSuper(); } return options != null && !options.isEmpty() ? options : null; }
FeatureTypes { public static List<?> getFieldOptions(PropertyDescriptor descriptor) { PropertyType type = descriptor.getType(); List<Object> options = null; while (type != null) { for (Filter f : type.getRestrictions()) { List<Object> currentOptions = null; boolean foundOptionsPattern = true; if (f == null) { continue; } if (f instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) f); if (value != null) { currentOptions = Collections.singletonList(value); } else { continue; } } else if (f instanceof Or) { Or or = (Or) f; currentOptions = new ArrayList<>(); for (Filter child : or.getChildren()) { if (child instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) child); if (value != null) { currentOptions.add(value); } else { foundOptionsPattern = false; continue; } } else { foundOptionsPattern = false; } } } if (foundOptionsPattern) { if (options != null) { options.retainAll(currentOptions); } else { options = currentOptions; } } } type = type.getSuper(); } return options != null && !options.isEmpty() ? options : null; } }
FeatureTypes { public static List<?> getFieldOptions(PropertyDescriptor descriptor) { PropertyType type = descriptor.getType(); List<Object> options = null; while (type != null) { for (Filter f : type.getRestrictions()) { List<Object> currentOptions = null; boolean foundOptionsPattern = true; if (f == null) { continue; } if (f instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) f); if (value != null) { currentOptions = Collections.singletonList(value); } else { continue; } } else if (f instanceof Or) { Or or = (Or) f; currentOptions = new ArrayList<>(); for (Filter child : or.getChildren()) { if (child instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) child); if (value != null) { currentOptions.add(value); } else { foundOptionsPattern = false; continue; } } else { foundOptionsPattern = false; } } } if (foundOptionsPattern) { if (options != null) { options.retainAll(currentOptions); } else { options = currentOptions; } } } type = type.getSuper(); } return options != null && !options.isEmpty() ? options : null; }  }
FeatureTypes { public static List<?> getFieldOptions(PropertyDescriptor descriptor) { PropertyType type = descriptor.getType(); List<Object> options = null; while (type != null) { for (Filter f : type.getRestrictions()) { List<Object> currentOptions = null; boolean foundOptionsPattern = true; if (f == null) { continue; } if (f instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) f); if (value != null) { currentOptions = Collections.singletonList(value); } else { continue; } } else if (f instanceof Or) { Or or = (Or) f; currentOptions = new ArrayList<>(); for (Filter child : or.getChildren()) { if (child instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) child); if (value != null) { currentOptions.add(value); } else { foundOptionsPattern = false; continue; } } else { foundOptionsPattern = false; } } } if (foundOptionsPattern) { if (options != null) { options.retainAll(currentOptions); } else { options = currentOptions; } } } type = type.getSuper(); } return options != null && !options.isEmpty() ? options : null; }  static Filter createLengthRestriction(int length); static int getFieldLength(PropertyDescriptor descriptor); static List<?> getFieldOptions(PropertyDescriptor descriptor); static Filter createFieldOptions(Collection<?> options); static SimpleFeatureType transform(
            SimpleFeatureType schema, CoordinateReferenceSystem crs); static SimpleFeatureType transform(
            SimpleFeatureType schema, CoordinateReferenceSystem crs, boolean forceOnlyMissing); static SimpleFeature transform(
            SimpleFeature feature, SimpleFeatureType schema, MathTransform transform); static SimpleFeatureType newFeatureType(
            AttributeDescriptor[] types,
            String name,
            URI ns,
            boolean isAbstract,
            SimpleFeatureType[] superTypes); static SimpleFeatureType newFeatureType(
            AttributeDescriptor[] types,
            String name,
            URI ns,
            boolean isAbstract,
            SimpleFeatureType[] superTypes,
            AttributeDescriptor defaultGeometry); static SimpleFeatureType newFeatureType(
            AttributeDescriptor[] types,
            String name,
            URI ns,
            boolean isAbstract,
            SimpleFeatureType[] superTypes,
            GeometryDescriptor defaultGeometry); static SimpleFeatureType newFeatureType(
            AttributeDescriptor[] types, String name, URI ns, boolean isAbstract); static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns); static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name); static List<FeatureType> getAncestors(FeatureType featureType); static boolean matches(FeatureType featureType, Name name); static boolean isDecendedFrom(FeatureType featureType, URI namespace, String typeName); static boolean isDecendedFrom(FeatureType featureType, FeatureType isParentType); static boolean equals(SimpleFeatureType typeA, SimpleFeatureType typeB); static boolean equalsExact(SimpleFeatureType typeA, SimpleFeatureType typeB); static boolean equals(List attributesA, List attributesB); static boolean equalsExact(List attributesA, List attributesB); static boolean equals(
            AttributeDescriptor attributesA[], AttributeDescriptor attributesB[]); static boolean equalsExact(
            AttributeDescriptor attributesA[], AttributeDescriptor attributesB[]); static boolean equalsAncestors(SimpleFeatureType typeA, SimpleFeatureType typeB); static Set ancestors(SimpleFeatureType featureType); static boolean equals(AttributeDescriptor a, AttributeDescriptor b); static boolean equalsExact(AttributeDescriptor a, AttributeDescriptor b); static boolean equalsId(SimpleFeatureType typeA, SimpleFeatureType typeB); }
FeatureTypes { public static List<?> getFieldOptions(PropertyDescriptor descriptor) { PropertyType type = descriptor.getType(); List<Object> options = null; while (type != null) { for (Filter f : type.getRestrictions()) { List<Object> currentOptions = null; boolean foundOptionsPattern = true; if (f == null) { continue; } if (f instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) f); if (value != null) { currentOptions = Collections.singletonList(value); } else { continue; } } else if (f instanceof Or) { Or or = (Or) f; currentOptions = new ArrayList<>(); for (Filter child : or.getChildren()) { if (child instanceof PropertyIsEqualTo) { Object value = getOption((PropertyIsEqualTo) child); if (value != null) { currentOptions.add(value); } else { foundOptionsPattern = false; continue; } } else { foundOptionsPattern = false; } } } if (foundOptionsPattern) { if (options != null) { options.retainAll(currentOptions); } else { options = currentOptions; } } } type = type.getSuper(); } return options != null && !options.isEmpty() ? options : null; }  static Filter createLengthRestriction(int length); static int getFieldLength(PropertyDescriptor descriptor); static List<?> getFieldOptions(PropertyDescriptor descriptor); static Filter createFieldOptions(Collection<?> options); static SimpleFeatureType transform(
            SimpleFeatureType schema, CoordinateReferenceSystem crs); static SimpleFeatureType transform(
            SimpleFeatureType schema, CoordinateReferenceSystem crs, boolean forceOnlyMissing); static SimpleFeature transform(
            SimpleFeature feature, SimpleFeatureType schema, MathTransform transform); static SimpleFeatureType newFeatureType(
            AttributeDescriptor[] types,
            String name,
            URI ns,
            boolean isAbstract,
            SimpleFeatureType[] superTypes); static SimpleFeatureType newFeatureType(
            AttributeDescriptor[] types,
            String name,
            URI ns,
            boolean isAbstract,
            SimpleFeatureType[] superTypes,
            AttributeDescriptor defaultGeometry); static SimpleFeatureType newFeatureType(
            AttributeDescriptor[] types,
            String name,
            URI ns,
            boolean isAbstract,
            SimpleFeatureType[] superTypes,
            GeometryDescriptor defaultGeometry); static SimpleFeatureType newFeatureType(
            AttributeDescriptor[] types, String name, URI ns, boolean isAbstract); static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns); static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name); static List<FeatureType> getAncestors(FeatureType featureType); static boolean matches(FeatureType featureType, Name name); static boolean isDecendedFrom(FeatureType featureType, URI namespace, String typeName); static boolean isDecendedFrom(FeatureType featureType, FeatureType isParentType); static boolean equals(SimpleFeatureType typeA, SimpleFeatureType typeB); static boolean equalsExact(SimpleFeatureType typeA, SimpleFeatureType typeB); static boolean equals(List attributesA, List attributesB); static boolean equalsExact(List attributesA, List attributesB); static boolean equals(
            AttributeDescriptor attributesA[], AttributeDescriptor attributesB[]); static boolean equalsExact(
            AttributeDescriptor attributesA[], AttributeDescriptor attributesB[]); static boolean equalsAncestors(SimpleFeatureType typeA, SimpleFeatureType typeB); static Set ancestors(SimpleFeatureType featureType); static boolean equals(AttributeDescriptor a, AttributeDescriptor b); static boolean equalsExact(AttributeDescriptor a, AttributeDescriptor b); static boolean equalsId(SimpleFeatureType typeA, SimpleFeatureType typeB); static final URI DEFAULT_NAMESPACE; static final SimpleFeatureType ABSTRACT_FEATURE_TYPE; static final NameImpl DEFAULT_TYPENAME; static final int ANY_LENGTH; static final SimpleFeatureType EMPTY; }