Class StructAccessExpression

java.lang.Object
nz.org.riskscape.engine.expr.StructAccessExpression
All Implemented Interfaces:
TypedExpression, org.opengis.filter.expression.Expression, org.opengis.filter.expression.PropertyName

public class StructAccessExpression extends Object implements org.opengis.filter.expression.PropertyName, TypedExpression

Access properties by path inside riskscape Tuples

# Thread Safety

This class is not thread-safe, but is probably safe to use in some specific circumstances. It is known not to work and generally perform poorly when a) the same expression is used to access tuples of different types b) that is done across different threads (which can cause IllegalArgumentExceptions to be thrown). In these cases, it's best to use the ExpressionRealizer to rebuild and expression or a filter against a specific struct and use this. It will perform quicker and fail fast in cases of type mismatch.

  • Field Details

  • Constructor Details

    • StructAccessExpression

      public StructAccessExpression(String propertyName)
    • StructAccessExpression

      public StructAccessExpression(String... segmentsParam)
    • StructAccessExpression

      public StructAccessExpression(List<String> segments)
  • Method Details

    • and

      public StructAccessExpression and(String additionalPath)

      Creates a new struct access expression by adding additionalPath to this one.

      Parameters:
      additionalPath - additional path element
      Returns:
      new struct access expression
    • 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
    • evaluate

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

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

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

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

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

      public List<String> getSegments()
    • getExpressionFor

      public nz.org.riskscape.problem.ResultOrProblems<StructMemberAccessExpression> getExpressionFor(nz.org.riskscape.engine.types.Struct sourceType)
    • getCachedExpression

      public StructMemberAccessExpression getCachedExpression()
      Returns:
      a possibly null StructMemberAccessExpression that has been built to make subsequent lookups faster
    • getNamespaceContext

      public NamespaceSupport getNamespaceContext()
      Specified by:
      getNamespaceContext in interface org.opengis.filter.expression.PropertyName
    • 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