Package org.apache.sis.filter
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.filter.LeafExpression
LeafExpression.Literal<R,
V>, LeafExpression.Transformed<R, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PropertyValue<V>
Expression to use for evaluating the property value after the last element of the path.private final String[]
Path to the property from which to retrieve the value.private static final long
For cross-version compatibility. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
AssociationValue
(String[] path, PropertyValue<V> accessor) Creates a new expression retrieving values from a property at the given path.(package private)
AssociationValue
(List<String> path, PropertyValue<V> accessor) Creates a new expression retrieving values from a property at the given path. -
Method Summary
Modifier and TypeMethodDescriptionapply
(AbstractFeature instance) Returns the value of the property at the path given at construction time.boolean
Compares this value reference with the given object for equality.expectedType
(DefaultFeatureType valueType, FeatureTypeBuilder addTo) Provides the expected type of values produced by this expression when a feature of the given type is evaluated.protected final Collection<?>
ForNode.toString()
implementation.final org.opengis.util.ScopedName
Returns the name of the function to be called.final String
getXPath()
Returns the name of the property whose value will be returned by theExpression.apply(Object)
method.int
hashCode()
Returns a hash code value for this association.optimize
(Optimization optimization) If at least one evaluated property is a link, replaces this expression by more direct references to the target properties.final <N> Expression<AbstractFeature,
N> toValueType
(Class<N> target) Returns an expression that provides values as instances of the specified class.Methods inherited from class org.apache.sis.filter.LeafExpression
getParameters
Methods inherited from class org.apache.sis.internal.filter.Node
createName, createType, getGeometryLibrary, symbol, toGeometryWrapper, toString, unwrap, warning
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sis.filter.Expression
getParameters
Methods inherited from interface org.apache.sis.internal.feature.FeatureExpression
getValueClass
Methods inherited from interface org.apache.sis.filter.Optimization.OnExpression
recreate
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
path
Path to the property from which to retrieve the value. Each element in the array is an argument to give in a call toFeature.getProperty(String)
. This array should be considered read-only because it may be shared. -
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 byaccessor
.accessor
- expression to use for evaluating the property value after the last element of the path.
-
AssociationValue
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 interfaceExpression<AbstractFeature,
V> - Returns:
- name of the function to be called.
-
getChildren
ForNode.toString()
implementation.- Specified by:
getChildren
in classNode
- Returns:
- the children of this node, or an empty collection if none.
-
getXPath
Returns the name of the property whose value will be returned by theExpression.apply(Object)
method.- Specified by:
getXPath
in interfaceValueReference<AbstractFeature,
V>
-
apply
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 returnsnull
.- Specified by:
apply
in interfaceExpression<AbstractFeature,
V> - Specified by:
apply
in interfaceFunction<AbstractFeature,
V> - Parameters:
feature
- the feature from which to get a value, ornull
.- Returns:
- value for the property identified by the XPath (may be
null
).
-
optimize
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 interfaceOptimization.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
Returns an expression that provides values as instances of the specified class.- Specified by:
toValueType
in interfaceExpression<AbstractFeature,
V> - Type Parameters:
N
- compile-time value oftype
.- Parameters:
target
- desired type of expression results.- Returns:
- expression doing the same operation this this expression but with results of the specified type.
-
expectedType
Provides the expected type of values produced by this expression when a feature of the given type is evaluated.- Specified by:
expectedType
in interfaceFeatureExpression<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. -
equals
Compares this value reference with the given object for equality.
-