/** * @return the {@code FieldType} associated to the provided binding, or * {@link FieldType#UNKNOWN} if no {@code FieldType} relates to the argument attribute * type. */ public static FieldType forBinding(@Nullable Class<?> binding) { if (binding == null || Void.class.equals(binding)) { return NULL; } // try a hash lookup first FieldType fieldType = BINDING_MAPPING.get(binding); if (fieldType != null) { return fieldType; } // not in the map, lets check one by one anyways // beware for this to work properly FieldTypes for super classes must be defined _after_ // any subclass (i.e. Point before Geometry) for (FieldType t : values()) { Class<?> fieldTypeBinding = t.getBinding(); if (null != fieldTypeBinding && fieldTypeBinding.isAssignableFrom(binding)) { return t; } } return UNKNOWN; }
/** * @return the {@code FieldType} associated to the provided binding, or * {@link FieldType#UNKNOWN} if no {@code FieldType} relates to the argument attribute * type. */ public static FieldType forBinding(@Nullable Class<?> binding) { if (binding == null || Void.class.equals(binding)) { return NULL; } // try a hash lookup first FieldType fieldType = BINDING_MAPPING.get(binding); if (fieldType != null) { return fieldType; } // not in the map, lets check one by one anyways // beware for this to work properly FieldTypes for super classes must be defined _after_ // any subclass (i.e. Point before Geometry) for (FieldType t : values()) { if (t.getBinding() != null && t.getBinding().isAssignableFrom(binding)) { return t; } } return UNKNOWN; }
private List<Object> createValuesAllSupportedTypes() { FieldType[] types = FieldType.values(); List<Object> values = new ArrayList<>(); for (FieldType ft : types) { if (ft != FieldType.UNKNOWN) { values.add(RevObjectTestUtil.sampleValue(ft)); } } return values; }
public @Test final void createFeatureTypeAllSupportedAttributeTypes() { FieldType[] fieldTypes = FieldType.values(); StringBuilder typeSpec = new StringBuilder(); for (FieldType ft : fieldTypes) { if (typeSpec.length() > 0) { typeSpec.append(','); } if (ft != FieldType.NULL && ft != FieldType.UNKNOWN) { typeSpec.append(ft + "_type:").append(ft.getBinding().getName()); } } final String spec = typeSpec.toString(); final RevFeatureType revFType = testCreateFeatureType(id1, spec); for (FieldType ft : fieldTypes) { if (ft == FieldType.NULL || ft == FieldType.UNKNOWN) { continue; } String attName = ft + "_type"; PropertyDescriptor descriptor = revFType.type().getDescriptor(attName); assertNotNull(descriptor); assertEquals(attName, ft.getBinding(), descriptor.getType().getBinding()); } }
List<Object> attributeSampleValues = new ArrayList<>(); final FieldType[] fieldTypes = FieldType.values(); for (FieldType ft : fieldTypes) { if (ft == FieldType.NULL) {