Class AbstractOperation

java.lang.Object
org.apache.sis.feature.AbstractIdentifiedType
org.apache.sis.feature.AbstractOperation
All Implemented Interfaces:
Serializable, BiFunction<AbstractFeature,org.opengis.parameter.ParameterValueGroup,Object>, Deprecable
Direct Known Subclasses:
EnvelopeOperation, GroupAsPolylineOperation, LinkOperation, StringJoinOperation

public abstract class AbstractOperation extends AbstractIdentifiedType implements BiFunction<AbstractFeature,org.opengis.parameter.ParameterValueGroup,Object>
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.
The value is computed, or the operation is executed, by apply(Feature, ParameterValueGroup). If the value is modifiable, new value can be set by call to Attribute.setValue(Object).
Warning: this class is experimental and may change after we gained more experience on this aspect of ISO 19109.
Since:
0.6
Version:
0.8
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • RESULT_PREFIX

      static final String RESULT_PREFIX
      The prefix for result identification entries in the identification map. This prefix is documented in FeatureOperations javadoc.
      See Also:
  • Constructor Details

  • Method Details

    • resultIdentification

      final Map<String,Object> resultIdentification(Map<String,?> identification)
      Returns a map that can be used for creating the getResult() type. This method can be invoked for subclass constructor with the user supplied map in argument. If the given map contains at least one key prefixed by "result.", then the values associated to those keys will be used.
      Parameters:
      identification - the map given by user to sub-class constructor.
    • getParameters

      public abstract org.opengis.parameter.ParameterDescriptorGroup getParameters()
      Returns a description of the input parameters.
      Returns:
      description of the input parameters.
    • getResult

      public abstract AbstractIdentifiedType getResult()
      Returns the expected result type, or null if none.
      Warning: In a future SIS version, the return type may be changed to org.opengis.feature.IdentifiedType. This change is pending GeoAPI revision.
      Returns:
      the type of the result, or null if none.
    • apply

      public abstract Object apply(AbstractFeature feature, org.opengis.parameter.ParameterValueGroup parameters)
      Executes the operation on the specified feature with the specified parameters. 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: 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).
      Warning: In a future SIS version, the parameter type and return value may be changed to org.opengis.feature.Feature and org.opengis.feature.Property respectively. This change is pending GeoAPI revision.
      Specified by:
      apply in interface BiFunction<AbstractFeature,org.opengis.parameter.ParameterValueGroup,Object>
      Parameters:
      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.
      Returns:
      the operation result, or null if this operation does not produce any result.
    • getDependencies

      public Set<String> getDependencies()
      Returns the names of feature properties that this operation needs for performing its task. This method does not resolve transitive dependencies, i.e. if a dependency is itself an operation having other dependencies, the returned set will contain the name of that operation but not the names of that operation dependencies (unless they are the same that the direct dependencies of this).
      Rational: this information is needed for writing the SELECT SQL statement to send to a database server. The requested columns will typically be all attributes declared in a FeatureType, but also any additional columns needed for the operation while not necessarily included in the FeatureType.
      The default implementation returns an empty set.
      Returns:
      the names of feature properties needed by this operation for performing its task.
    • hashCode

      public int hashCode()
      Returns a hash code value for this operation. The default implementation computes a hash code from the parameters descriptor and result type.
      Overrides:
      hashCode in class AbstractIdentifiedType
      Returns:
      the hash code for this type.
    • equals

      public boolean equals(Object obj)
      Compares this operation with the given object for equality. The default implementation compares the parameters descriptor and result type.
      Overrides:
      equals in class AbstractIdentifiedType
      Parameters:
      obj - the object to compare with this type.
      Returns:
      true if the given object is equal to this type.
    • toString

      public String toString()
      Returns a string representation of this operation. The returned string is for debugging purpose and may change in any future SIS version.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this operation for debugging purpose.
    • formatResultFormula

      void formatResultFormula(Appendable buffer) throws IOException
      Appends a string representation of the "formula" used for computing the result. The "formula" may be for example a link to another property.
      Parameters:
      buffer - where to format the "formula".
      Throws:
      IOException - if an error occurred while writing in buffer.
    • defaultFormula

      static void defaultFormula(org.opengis.parameter.ParameterDescriptorGroup parameters, Appendable buffer) throws IOException
      Default implementation of formatResultFormula(Appendable), to be used also for operations that are not instance of AbstractOperation.
      Throws:
      IOException
    • name

      private static String name(org.opengis.metadata.Identifier id)
      Returns a short string representation of the given identifier, or null if none.