Package org.apache.sis.filter
Class ConvertFunction<R,S,V>
java.lang.Object
org.apache.sis.internal.filter.Node
org.apache.sis.filter.UnaryFunction<R,S>
org.apache.sis.filter.ConvertFunction<R,S,V>
- Type Parameters:
R
- the type of resources (e.g.Feature
) used as inputs.S
- the type of value computed by the wrapped exception. This is the type to convert.V
- the type of value computed by this expression. This is the type after conversion.
- All Implemented Interfaces:
Serializable
,Function<R,
,V> Expression<R,
,V> Optimization.OnExpression<R,
,V> FeatureExpression<R,
V>
final class ConvertFunction<R,S,V>
extends UnaryFunction<R,S>
implements FeatureExpression<R,V>, Optimization.OnExpression<R,V>
Expression whose results are converted to a different type.
- Since:
- 1.1
- Version:
- 1.2
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.filter.UnaryFunction
UnaryFunction.IsNil<R>, UnaryFunction.IsNull<R>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectConverter<? super S,
? extends V> The converter to use.private static final org.opengis.util.ScopedName
Name of this expression.private static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.filter.UnaryFunction
expression
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ConvertFunction
(ConvertFunction<R, S, V> original, Expression<? super R, ? extends S> expression) Creates a new converted expression after optimization.(package private)
ConvertFunction
(Expression<? super R, ? extends S> expression, Class<S> source, Class<V> target) Creates a new converted expression. -
Method Summary
Modifier and TypeMethodDescriptionEvaluates the expression for producing a result of the given type.expectedType
(DefaultFeatureType valueType, FeatureTypeBuilder addTo) Provides the type of values produced by this expression when a feature of the given type is evaluated.protected Collection<?>
Returns the singleton expression tested by this operator together with the source and target classes.org.opengis.util.ScopedName
Returns an identification of this operation.Returns the type of values computed by this expression.Expression<R,
V> recreate
(Expression<? super R, ?>[] effective) Creates a new expression of the same type than this expression, but with optimized parameters.<N> Expression<R,
N> toValueType
(Class<N> target) Returns an expression doing the same evaluation than this method, but returning results as values of the specified type.Methods inherited from class org.apache.sis.filter.UnaryFunction
getExpressions, getParameters
Methods inherited from class org.apache.sis.internal.filter.Node
createName, createType, equals, getGeometryLibrary, hashCode, 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.filter.Optimization.OnExpression
optimize
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
NAME
private static final org.opengis.util.ScopedName NAMEName of this expression. -
converter
The converter to use.
-
-
Constructor Details
-
ConvertFunction
Creates a new converted expression.- Parameters:
expression
- the expression providing source values.source
- the type of value produced by given expressiontarget
- the desired type for the expression result.- Throws:
UnconvertibleObjectException
- if no converter is found.
-
ConvertFunction
private ConvertFunction(ConvertFunction<R, S, V> original, Expression<? super R, ? extends S> expression) Creates a new converted expression after optimization.- Parameters:
expression
- the expression providing source values.- Throws:
UnconvertibleObjectException
- if no converter is found.
-
-
Method Details
-
recreate
Creates a new expression of the same type than this expression, but with optimized parameters.- Specified by:
recreate
in interfaceOptimization.OnExpression<R,
S> - Parameters:
effective
- the expressions to use as a replacement of this expression parameters.- Returns:
- the new expression, or
this
if unsupported.
-
getFunctionName
public org.opengis.util.ScopedName getFunctionName()Returns an identification of this operation.- Specified by:
getFunctionName
in interfaceExpression<R,
S> - Returns:
- name of the function to be called.
-
getChildren
Returns the singleton expression tested by this operator together with the source and target classes.- Overrides:
getChildren
in classUnaryFunction<R,
S> - Returns:
- the children of this node, or an empty collection if none.
-
apply
Evaluates the expression for producing a result of the given type. If this method cannot produce a value of the given type, then it returnsnull
. This implementation evaluates the expression in the default way, then tries to convert the result to the target type. -
getValueClass
Returns the type of values computed by this expression.- Specified by:
getValueClass
in interfaceFeatureExpression<R,
S> - Returns:
- the type of values computed by this expression.
-
expectedType
Provides the type of values produced by this expression when a feature of the given type is evaluated. May returnnull
if the type cannot be determined.- Specified by:
expectedType
in interfaceFeatureExpression<R,
S> - 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.
-
toValueType
Returns an expression doing the same evaluation than this method, but returning results as values of the specified type. The result may bethis
.- Specified by:
toValueType
in interfaceExpression<R,
S> - 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.
- Throws:
ClassCastException
- if the specified type is not a target type supported by implementation.
-