Interface Operation

  • All Superinterfaces:
    IdentifiedType, PropertyType

    public interface Operation
    extends PropertyType
    Describes the behaviour of a feature type as a function or a method. Operations can:
    • Compute values from the attributes.
    • Perform actions that change the attribute values.
    Example: a mutator operation may raise the height of a dam. This changes may affect other properties like the watercourse and the reservoir associated with the dam.
    This Operation type is used for defining the required parameters and expected result.
    • Method Detail

      • apply

        Property apply​(Feature feature,
                       ParameterValueGroup parameters)
                throws FeatureOperationException
        Executes the operation on the specified feature with the specified parameters. The parameters argument should be an instance created like below, where the text in italic shall be replaced by operation-specific text:
         ParameterValueGroup p = operation.getParameters().createValue();
         p.parameter("a parameter 1").setValue(aValue1);
         p.parameter("a parameter 2").setValue(aValue2);
        The value returned by this method depends on the value returned by getResult():
        • If getResult() returns null, then this method should return null.
        • If getResult() returns an instance of AttributeType, then this method shall return an instance of Attribute and the Attribute.getType() == getResult() relation should hold.
        • If getResult() returns an instance of FeatureAssociationRole, then this method shall return an instance of FeatureAssociation and the FeatureAssociation.getRole() == getResult() relation should hold.
        Analogy with Java reflection
        if we compare Operation to Method in the Java language, then this method is equivalent to Method.invoke(Object, Object...). The Feature argument is equivalent to this in the Java language, and may be null if the operation does not need a feature instance (like static methods in the Java language).
        API note
        the method signature is compatible with BiFunction<Feature, ParameterValueGroup, Property> from the java.util.function package.
        feature - the feature on which to execute the operation. Can be null if the operation does not need feature instance.
        parameters - the parameters to use for executing the operation. Can be null if the operation does not take any parameters.
        the operation result, or null if this operation does not produce any result.
        FeatureOperationException - if the operation can not complete.