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.

  • 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, a Struct, or the result will fail
      segments - 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 interface TypedExpression
    • getType

      public nz.org.riskscape.engine.types.Type getType()
    • setValue

      public void setValue(nz.org.riskscape.engine.Tuple object, Object toSet)

      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

      public Object evaluate(Object object)
      Specified by:
      evaluate in interface org.geotools.api.filter.expression.Expression
    • evaluate

      public <T> T evaluate(Object object, Class<T> context)
      Specified by:
      evaluate in interface org.geotools.api.filter.expression.Expression
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • accept

      public Object accept(org.geotools.api.filter.expression.ExpressionVisitor visitor, Object extraData)
      Specified by:
      accept in interface org.geotools.api.filter.expression.Expression
    • getPropertyName

      public String getPropertyName()
      Specified by:
      getPropertyName in interface org.geotools.api.filter.expression.PropertyName
    • getSegments

      public List<nz.org.riskscape.engine.types.Struct.StructMember> getSegments()
    • getNamespaceContext

      public NamespaceSupport getNamespaceContext()
      Specified by:
      getNamespaceContext in interface org.geotools.api.filter.expression.PropertyName
    • toExpression

      public nz.org.riskscape.rl.ast.Expression toExpression()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object