Package org.apache.sis.feature
Class Features
Static methods working on features or attributes.
- Since:
- 0.5
Defined in the sis-feature module
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> AbstractAttribute<V>cast(AbstractAttribute<?> attribute, Class<V> valueClass) Casts the given attribute instance to the given parameterized type.static <V> DefaultAttributeType<V>cast(DefaultAttributeType<?> type, Class<V> valueClass) Casts the given attribute type to the given parameterized type.static DefaultFeatureTypefindCommonParent(Iterable<? extends DefaultFeatureType> types) Finds a feature type common to all given types, or returnsnullif none is found.getLinkTarget(AbstractIdentifiedType property) If the given property is a link, returns the name of the referenced property.static GenericNamegetValueTypeName(AbstractIdentifiedType property) Returns the name of the type of values that the given property can take.static Optional<DefaultAttributeType<?>>Returns the given type as anAttributeTypeby casting if possible, or by getting the result type of an operation.static voidvalidate(AbstractFeature feature) Ensures that all characteristics and property values in the given feature are valid.
-
Method Details
-
cast
public static <V> DefaultAttributeType<V> cast(DefaultAttributeType<?> type, Class<V> valueClass) throws ClassCastException Casts the given attribute type to the given parameterized type. An exception is thrown immediately if the given type does not have the expected value class.- Type Parameters:
V- the expected value class.- Parameters:
type- the attribute type to cast, ornull.valueClass- the expected value class.- Returns:
- the attribute type casted to the given value class, or
nullif the given type was null. - Throws:
ClassCastException- if the given attribute type does not have the expected value class.
-
cast
public static <V> AbstractAttribute<V> cast(AbstractAttribute<?> attribute, Class<V> valueClass) throws ClassCastException Casts the given attribute instance to the given parameterized type. An exception is thrown immediately if the given instance does not have the expected value class.- Type Parameters:
V- the expected value class.- Parameters:
attribute- the attribute instance to cast, ornull.valueClass- the expected value class.- Returns:
- the attribute instance casted to the given value class, or
nullif the given instance was null. - Throws:
ClassCastException- if the given attribute instance does not have the expected value class.
-
toAttribute
Returns the given type as anAttributeTypeby casting if possible, or by getting the result type of an operation. More specifically this method returns the first of the following types which apply:- If the given type is an instance of
AttributeType, then it is returned as-is. - If the given type is an instance of
Operationand theOperation.getResult() result typeis anAttributeType, then that result type is returned. - If the given type is an instance of
Operationand theOperation.getResult() result typeis another operation, then the above check is performed recursively.
- Parameters:
type- the data type to express as an attribute type.- Returns:
- the attribute type, or empty if this method cannot find any.
- Since:
- 1.1
- If the given type is an instance of
-
findCommonParent
Finds a feature type common to all given types, or returnsnullif none is found. The return value is either one of the given types, or a parent common to all types. A feature F is considered a common parent ifF.returnsisAssignableFrom(type)truefor all elements type in the given array.- Parameters:
types- types for which to find a common type, ornull.- Returns:
- a feature type which is assignable from all given types, or
nullif none. - Since:
- 1.0
- See Also:
-
getValueTypeName
Returns the name of the type of values that the given property can take. The type of value can be aClass, aFeatureTypeor anotherPropertyTypedepending on given argument:- If
propertyis anAttributeType, then this method gets the value class and maps that class to a name. - If
propertyis aFeatureAssociationRole, then this method gets the name of the value type. This methods can work even if the associatedFeatureTypeis not yet resolved. - If
propertyis anOperation, then this method returns the name of the result type.
- Parameters:
property- the property for which to get the name of value type.- Returns:
- the name of value type, or
nullif none. - Since:
- 0.8
- If
-
getLinkTarget
If the given property is a link, returns the name of the referenced property. A link is an operation created by a call toFeatureOperations.link(Map, PropertyType), in which case the value returned by this method is the name of thePropertyTypeargument which has been given to thatlink(…)method.- Parameters:
property- the property to test, ornullif none.- Returns:
- the referenced property name if
propertyis a link, or an empty value otherwise. - Since:
- 1.1
- See Also:
-
validate
Ensures that all characteristics and property values in the given feature are valid. An attribute is valid if it contains a number of values between the minimum and maximum number of occurrences (inclusive), all values are instances of the expected value class, and the attribute is compliant with any other restriction that the implementation may add.This method gets a quality report as documented in the
AbstractFeature.quality()method and verifies that all conformance tests pass. If at least oneConformanceResult.passattribute is false, then anInvalidPropertyValueExceptionis thrown. Otherwise this method returns doing nothing.- Parameters:
feature- the feature to validate, ornull.- Throws:
IllegalArgumentException- if the given feature is non-null and does not pass validation.- Since:
- 0.7
-