Class StringJoinOperation.ForFeature

java.lang.Object
org.apache.sis.internal.converter.SurjectiveConverter<Object,Object>
org.apache.sis.feature.StringJoinOperation.ForFeature
All Implemented Interfaces:
Serializable, Function<Object,Object>, ObjectConverter<Object,Object>
Enclosing class:
StringJoinOperation

private static final class StringJoinOperation.ForFeature extends SurjectiveConverter<Object,Object> implements Serializable
A pseudo-converter returning the identifier of a feature. This pseudo-converter is used in place of "real" converters in the StringJoinOperation.converters array when the property is an association to a feature instead of an attribute. This pseudo-converters is used as below: This is not a well-formed converter since its inverse() method does not fulfill the required semantic of ObjectConverter.inverse(), but this is okay for StringJoinOperation needs. This converter should never be accessible to users however.
  • Field Details

    • serialVersionUID

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

      final ObjectConverter<? super String,?> converter
      The "real" converter which would have been stored in the StringJoinOperation.converters array if the property was an attribute instead of an association. For formatting the feature identifier, we need to use the inverse of that converter.
  • Constructor Details

    • ForFeature

      ForFeature(ObjectConverter<? super String,?> converter)
      Creates a new wrapper over the given converter.
  • Method Details

    • inverse

      public ObjectConverter<Object,Object> inverse()
      Returns this for allowing StringJoinOperation.Result.getValue() to get this pseudo-converter. This is a violation of ObjectConverter contract since this pseudo-converter is not an identity converter. Direct uses of this pseudo-converter will need a instanceof check instead.
      Specified by:
      inverse in interface ObjectConverter<Object,Object>
      Overrides:
      inverse in class SurjectiveConverter<Object,Object>
      Returns:
      a converter for converting instances of T back to instances of S.
      See Also:
    • getSourceClass

      public Class<Object> getSourceClass()
      Description copied from interface: ObjectConverter
      Returns the type of objects to convert.
      Specified by:
      getSourceClass in interface ObjectConverter<Object,Object>
      Returns:
      the type of objects to convert.
    • getTargetClass

      public Class<Object> getTargetClass()
      Description copied from interface: ObjectConverter
      Returns the type of converted objects.
      Specified by:
      getTargetClass in interface ObjectConverter<Object,Object>
      Returns:
      the type of converted objects.
    • apply

      public Object apply(Object f)
      Description copied from interface: ObjectConverter
      Converts the given object from the source type S to the target type T. If the given object cannot be converted, then this method may either returns null or throws an exception, at implementation choice (except for injective functions, which must throw an exception - see the class Javadoc for more discussion about function properties).
      Example: in Apache SIS implementation, converters from String to Number distinguish two kinds of unconvertible objects:
      • Null or empty source string result in a null value to be returned.
      • All other kind of unparsable strings results in an exception to be thrown.
      In other words, the "" value is unconvertible but nevertheless considered as part of the converter domain, and is mapped to "no number". All other unparsable strings are considered outside the converter domain.
      Specified by:
      apply in interface Function<Object,Object>
      Specified by:
      apply in interface ObjectConverter<Object,Object>
      Parameters:
      f - the object to convert, or null.
      Returns:
      the converted object, or null.