Class Features


  • public final class Features
    extends Static
    Static methods working on features or attributes.
    Since:
    0.5

    Defined in the sis-feature module

    • Method Detail

      • 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, or null.
        value­Class - the expected value class.
        Returns:
        the attribute type casted to the given value class, or null if the given type was null.
        Throws:
        Class­Cast­Exception - 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, or null.
        value­Class - the expected value class.
        Returns:
        the attribute instance casted to the given value class, or null if the given instance was null.
        Throws:
        Class­Cast­Exception - if the given attribute instance does not have the expected value class.
      • getValueTypeName

        public static GenericName getValueTypeName​(AbstractIdentifiedType property)
        Returns the name of the type of values that the given property can take. The type of value can be a Class, a Feature­Type or another Property­Type depending on given argument:
        • If property is an Attribute­Type, then this method gets the value class and maps that class to a name.
        • If property is a Feature­Association­Role, then this method gets the name of the value type. This methods can work even if the associated Feature­Type is not yet resolved.
        • If property is an Operation, 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 null if none.
        Since:
        0.8
      • validate

        public static void validate​(AbstractFeature feature)
                             throws IllegalArgumentException
        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 Abstract­Feature​.quality() method and verifies that all conformance tests pass. If at least one Conformance­Result​.pass attribute is false, then an Invalid­Property­Value­Exception is thrown. Otherwise this method returns doing nothing.

        Parameters:
        feature - the feature to validate, or null.
        Throws:
        Illegal­Argument­Exception - if the given feature is non-null and does not pass validation.
        Since:
        0.7