Package nz.org.riskscape.engine.expr
Class StructMemberAccessExpression
java.lang.Object
nz.org.riskscape.engine.expr.StructMemberAccessExpression
- All Implemented Interfaces:
TypedExpression
,org.geotools.api.filter.expression.Expression
,org.geotools.api.filter.expression.PropertyName
public class StructMemberAccessExpression
extends Object
implements org.geotools.api.filter.expression.PropertyName, TypedExpression
Access properties inside riskscape values using struct member lookups which gives consistent access times.
-
Field Summary
Fields inherited from interface org.geotools.api.filter.expression.Expression
NIL
-
Constructor Summary
ConstructorDescriptionStructMemberAccessExpression
(boolean nullableResult, List<nz.org.riskscape.engine.types.Struct.StructMember> segments) StructMemberAccessExpression
(boolean nullableResult, nz.org.riskscape.engine.types.Struct.StructMember... segmentsParam) -
Method Summary
Modifier and TypeMethodDescriptionstatic nz.org.riskscape.problem.ResultOrProblems<StructMemberAccessExpression>
Construct a StructMemberAccessExpression that will access the given type, using the path expression broken down in to a list of segments.protected boolean
boolean
<T> T
nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.types.Type>
evaluateType
(nz.org.riskscape.engine.types.Type sourceType) The riskscape type this expression will return as aValue
nz.org.riskscape.engine.types.Struct
List<nz.org.riskscape.engine.types.Struct.StructMember>
nz.org.riskscape.engine.types.Type
getType()
int
hashCode()
void
Use this expression to set a value to a tuple, rather than fetch it.nz.org.riskscape.rl.ast.Expression
toString()
-
Constructor Details
-
StructMemberAccessExpression
public StructMemberAccessExpression(boolean nullableResult, nz.org.riskscape.engine.types.Struct.StructMember... segmentsParam) -
StructMemberAccessExpression
public StructMemberAccessExpression(boolean nullableResult, List<nz.org.riskscape.engine.types.Struct.StructMember> segments)
-
-
Method Details
-
build
public static nz.org.riskscape.problem.ResultOrProblems<StructMemberAccessExpression> build(nz.org.riskscape.engine.types.Type sourceType, List<String> segments) Construct a StructMemberAccessExpression that will access the given type, using the path expression broken down in to a list of segments.
- Parameters:
sourceType
- the type of thing being accessed, should be, or wrap, aStruct
, or the result will failsegments
- the list of attributes to traverse when accessing a property. If these properties don't exist on the given type, and it's child types, then the result will fail.
-
getRootStruct
public nz.org.riskscape.engine.types.Struct getRootStruct()- Returns:
- the struct that owns the first path segment in this expression. All tuples given to this expression's evaluate methods must have the same struct object as this of bad things will happen.
-
evaluateType
public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.types.Type> evaluateType(nz.org.riskscape.engine.types.Type sourceType) Description copied from interface:TypedExpression
The riskscape type this expression will return as a
Value
- Specified by:
evaluateType
in interfaceTypedExpression
-
getType
public nz.org.riskscape.engine.types.Type getType() -
setValue
Use this expression to set a value to a tuple, rather than fetch it. This method is not type-safe in the sense that it allows you to set a invariant value to the tuple - it is on you to check it before it goes in.
If a child tuple is null along the way, it will be created using the type found in this member's root struct
- Parameters:
object
- target tuple to modify.toSet
- a value to set to the tuple (or one of its children)- Throws:
IllegalArgumentException
- if tuple not of the exact same type used to build this expression
-
evaluate
- Specified by:
evaluate
in interfaceorg.geotools.api.filter.expression.Expression
-
evaluate
- Specified by:
evaluate
in interfaceorg.geotools.api.filter.expression.Expression
-
toString
-
accept
public Object accept(org.geotools.api.filter.expression.ExpressionVisitor visitor, Object extraData) - Specified by:
accept
in interfaceorg.geotools.api.filter.expression.Expression
-
getPropertyName
- Specified by:
getPropertyName
in interfaceorg.geotools.api.filter.expression.PropertyName
-
getSegments
-
getNamespaceContext
- Specified by:
getNamespaceContext
in interfaceorg.geotools.api.filter.expression.PropertyName
-
toExpression
public nz.org.riskscape.rl.ast.Expression toExpression() -
equals
-
canEqual
-
hashCode
public int hashCode()
-