Interface FeatureExpression<R,V>

Type Parameters:
R - the type of resources (e.g. Feature) used as inputs.
V - the type of values computed by the expression.
All Superinterfaces:
Expression<R,V>, Function<R,V>
All Known Implementing Classes:
ArithmeticFunction, ArithmeticFunction.Add, ArithmeticFunction.Divide, ArithmeticFunction.Multiply, ArithmeticFunction.Subtract, AssociationValue, ConvertFunction, FunctionWithSRID, GeometryConstructor, GeometryParser, LeafExpression, LeafExpression.Literal, LeafExpression.Transformed, OneGeometry, OneGeometry.WithArgument, PropertyValue, PropertyValue.AsObject, PropertyValue.CastedAndConverted, PropertyValue.Converted, SpatialFunction, ST_FromBinary, ST_FromText, ST_Point, ST_Transform, TwoGeometries, TwoGeometries.WithArgument

public interface FeatureExpression<R,V> extends Expression<R,V>
OGC expressions or other functions operating on feature instances. This interface adds an additional method, expectedType(FeatureType, FeatureTypeBuilder), for fetching in advance the expected type of expression results.

This is an experimental interface which may be removed in any future version.

Since:
1.0
Version:
1.2
  • Method Details

    • getValueClass

      default Class<?> getValueClass()
      Returns the type of values computed by this expression, or Object.class if unknown.
      Returns:
      the type of values computed by this expression.
    • expectedType

      Provides the expected type of values produced by this expression when a feature of the given type is evaluated. The resulting type shall describe a "static" property, i.e. it can be an AttributeType or a org.opengis.feature.FeatureAssociationRole but not an org.opengis.feature.Operation.
      Parameters:
      valueType - the type of features to be evaluated by the given expression.
      addTo - where to add the type of properties evaluated by this expression.
      Returns:
      builder of the added property, or null if this method cannot add a property.
      Throws:
      IllegalArgumentException - if this method can operate only on some feature types and the given type is not one of them.
    • castOrCopy

      static FeatureExpression<?,?> castOrCopy(Expression<?,?> candidate)
      Tries to cast or convert the given expression to a FeatureExpression. If the given expression cannot be casted, then this method creates a copy provided that the expression is one of the following type:
      1. Literal.
      2. ValueReference, assuming that the expression expects feature instances.
      Otherwise this method returns null. It is caller's responsibility to verify if this method returns null and to throw an exception in such case. We leave that responsibility to the caller because (s)he may be able to provide better error messages.
      Parameters:
      candidate - the expression to cast or copy. Can be null.
      Returns:
      the given expression as a feature expression, or null if it cannot be casted or converted.