Class AssociationValue<V>

Type Parameters:
V - the type of value computed by the expression.
All Implemented Interfaces:
Serializable, Function<AbstractFeature,V>, Expression<AbstractFeature,V>, Optimization.OnExpression<AbstractFeature,V>, FeatureExpression<AbstractFeature,V>, ValueReference<AbstractFeature,V>

final class AssociationValue<V> extends LeafExpression<AbstractFeature,V> implements ValueReference<AbstractFeature,V>, Optimization.OnExpression<AbstractFeature,V>
Expression whose value is computed by retrieving the value indicated by the provided path. This is used for value reference given by x-path such as "a/b/c". The last element of the path (the tip) is evaluated by a PropertyValue.
Since:
1.2
Version:
1.2
See Also:
  • Field Details

    • serialVersionUID

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

      private final String[] path
      Path to the property from which to retrieve the value. Each element in the array is an argument to give in a call to Feature.getProperty(String). This array should be considered read-only because it may be shared.
    • accessor

      private final PropertyValue<V> accessor
      Expression to use for evaluating the property value after the last element of the path.
  • Constructor Details

    • AssociationValue

      AssociationValue(List<String> path, PropertyValue<V> accessor)
      Creates a new expression retrieving values from a property at the given path.
      Parameters:
      path - components of the path before the property evaluated by accessor.
      accessor - expression to use for evaluating the property value after the last element of the path.
    • AssociationValue

      private AssociationValue(String[] path, PropertyValue<V> accessor)
      Creates a new expression retrieving values from a property at the given path. This constructor is used for creating new expression with the same path than a previous expression but a different accessor.
      Parameters:
      path - components of the path, not cloned (we share arrays).
      accessor - expression to use for evaluating the property value after the last element of the path.
  • Method Details

    • getFunctionName

      public final org.opengis.util.ScopedName getFunctionName()
      Description copied from interface: Expression
      Returns the name of the function to be called.
      Specified by:
      getFunctionName in interface Expression<AbstractFeature,V>
      Returns:
      name of the function to be called.
    • getChildren

      protected final Collection<?> getChildren()
      For Node.toString() implementation.
      Specified by:
      getChildren in class Node
      Returns:
      the children of this node, or an empty collection if none.
    • getXPath

      public final String getXPath()
      Returns the name of the property whose value will be returned by the Expression.apply(Object) method.
      Specified by:
      getXPath in interface ValueReference<AbstractFeature,V>
    • apply

      public V apply(AbstractFeature instance)
      Returns the value of the property at the path given at construction time. Path components should be feature associations. If this is not the case, this method silently returns null.
      Specified by:
      apply in interface Expression<AbstractFeature,V>
      Specified by:
      apply in interface Function<AbstractFeature,V>
      Parameters:
      feature - the feature from which to get a value, or null.
      Returns:
      value for the property identified by the XPath (may be null).
    • optimize

      public Expression<AbstractFeature,V> optimize(Optimization optimization)
      If at least one evaluated property is a link, replaces this expression by more direct references to the target properties. This is needed for better SQL WHERE clause in database queries.
      Specified by:
      optimize in interface Optimization.OnExpression<AbstractFeature,V>
      Parameters:
      optimization - the simplifications or optimizations to apply on this expression.
      Returns:
      the simplified or optimized expression, or this if no optimization has been applied.
    • toValueType

      public final <N> Expression<AbstractFeature,N> toValueType(Class<N> target)
      Returns an expression that provides values as instances of the specified class.
      Specified by:
      toValueType in interface Expression<AbstractFeature,V>
      Type Parameters:
      N - compile-time value of type.
      Parameters:
      target - desired type of expression results.
      Returns:
      expression doing the same operation this this expression but with results of the specified type.
    • expectedType

      public PropertyTypeBuilder expectedType(DefaultFeatureType valueType, FeatureTypeBuilder addTo)
      Provides the expected type of values produced by this expression when a feature of the given type is evaluated.
      Specified by:
      expectedType in interface FeatureExpression<AbstractFeature,V>
      Parameters:
      valueType - the type of features to be evaluated by the given expression.
      addTo - where to add the type of properties evaluated by the given expression.
      Returns:
      builder of the added property, or null if this method cannot add a property.
      Throws:
      IllegalArgumentException - if this method cannot determine the property type for the given feature type.
    • hashCode

      public int hashCode()
      Returns a hash code value for this association.
      Overrides:
      hashCode in class Node
    • equals

      public boolean equals(Object obj)
      Compares this value reference with the given object for equality.
      Overrides:
      equals in class Node
      Parameters:
      obj - the other object to compare with this node.
      Returns:
      whether the two object are equal.