Class StringJoinOperation

All Implemented Interfaces:
Serializable, BiFunction<AbstractFeature,org.opengis.parameter.ParameterValueGroup,Object>, Deprecable

final class StringJoinOperation extends AbstractOperation
An operation concatenating the string representations of the values of multiple properties. This operation can be used for creating a compound key as a String that consists of two or more attribute values that uniquely identify a feature instance.

This operation supports both reading and writing. When setting a value on the attribute created by this operation, the value will be split and forwarded to each single attribute.

Since:
0.7
Version:
1.0
See Also:
  • Field Details

    • serialVersionUID

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

      static final char ESCAPE
      The character used for escaping occurrences of the delimiter inside a value.
      See Also:
    • EMPTY_PARAMS

      private static final org.opengis.parameter.ParameterDescriptorGroup EMPTY_PARAMS
      The parameter descriptor for the "String join" operation, which does not take any parameter.
    • attributeNames

      private final String[] attributeNames
      The name of the properties (attributes of operations producing attributes) from which to get the values to concatenate.
    • converters

      private final ObjectConverter<? super String,?>[] converters
      Converters for parsing strings as attribute values. Those converters will be used by StringJoinOperation.Result.setValue(String) while StringJoinOperation.Result.getValue() will use the inverse of those converters.

      Note: we store converters from string to value instead of the converse because the inverse conversion is often a simple call to Object.toString(), so there is a risk that some of the latter converters do not bother to remember their inverse.

    • dependencies

      private transient Set<String> dependencies
      The property names as an unmodifiable set, created when first needed.
    • resultType

      private final DefaultAttributeType<String> resultType
      The type of the result returned by the string concatenation operation.
    • prefix

      final String prefix
      The characters to use at the beginning of the concatenated string, or an empty string if none.
    • suffix

      final String suffix
      The characters to use at the end of the concatenated string, or an empty string if none.
    • delimiter

      final String delimiter
      The characters to use a delimiter between each single attribute value.
  • Constructor Details

  • Method Details

    • getParameters

      public org.opengis.parameter.ParameterDescriptorGroup getParameters()
      Returns an empty group of parameters since this operation does not require any parameter.
      Specified by:
      getParameters in class AbstractOperation
      Returns:
      empty parameter group.
    • getResult

      public AbstractIdentifiedType getResult()
      Returns the type of results computed by this operation, which is AttributeType<String>. The attribute type name depends on the value of "result.*" properties (if any) given at construction time.
      Specified by:
      getResult in class AbstractOperation
      Returns:
      an AttributeType<String>.
    • getDependencies

      public Set<String> getDependencies()
      Returns the names of feature properties that this operation needs for performing its task.
      Overrides:
      getDependencies in class AbstractOperation
      Returns:
      the names of feature properties needed by this operation for performing its task.
    • format

      static <S> Object format(ObjectConverter<S,?> converter, Object value)
      Formats the given value using the given converter. This method is a workaround for the presence of the first ? in ObjectConverter<?,?>: defining a separated method allows us to replace that <?> by <S>, thus allowing the compiler to verify consistency.
      Parameters:
      converter - the converter to use for formatting the given value.
      value - the value to format, or null.
    • apply

      public Property apply(AbstractFeature feature, org.opengis.parameter.ParameterValueGroup parameters)
      Returns the concatenation of property values of the given feature.
      Specified by:
      apply in interface BiFunction<AbstractFeature,org.opengis.parameter.ParameterValueGroup,Object>
      Specified by:
      apply in class AbstractOperation
      Parameters:
      feature - the feature on which to execute the operation.
      parameters - ignored (can be null).
      Returns:
      the concatenation of feature property values.
    • hashCode

      public int hashCode()
      Computes a hash-code value for this operation.
      Overrides:
      hashCode in class AbstractOperation
      Returns:
      the hash code for this type.
    • equals

      public boolean equals(Object obj)
      Compares this operation with the given object for equality.
      Overrides:
      equals in class AbstractOperation
      Parameters:
      obj - the object to compare with this type.
      Returns:
      true if the given object is equal to this type.
    • formatResultFormula

      void formatResultFormula(Appendable buffer) throws IOException
      Appends a string representation of the "formula" used for computing the result.
      Overrides:
      formatResultFormula in class AbstractOperation
      Parameters:
      buffer - where to format the "formula".
      Throws:
      IOException - if an error occurred while writing in buffer.