Class AstUtils

java.lang.Object
org.springframework.expression.spel.ast.AstUtils

public abstract class AstUtils extends Object
Utility methods for use in the AST classes.
Since:
3.0.2
Author:
Andy Clement, Sam Brannen
  • Constructor Details

    • AstUtils

      public AstUtils()
  • Method Details

    • getAccessorsToTry

      public static <T extends TargetedAccessor> List<T> getAccessorsToTry(@Nullable Class<?> targetType, List<T> accessors)
      Determine the set of accessors that should be used to try to access an element on the specified target type.

      The accessors are considered to be in an ordered list; however, in the returned list any accessors that are exact matches for the input target type (as opposed to 'generic' accessors that could work for any type) are placed at the start of the list. In addition, if there are specific accessors that exactly name the class in question and accessors that name a specific class which is a supertype of the class in question, the latter are put at the end of the specific accessors set and will be tried after exactly matching accessors but before generic accessors.

      Parameters:
      targetType - the type upon which element access is being attempted
      accessors - the list of element accessors to process
      Returns:
      a list of accessors that should be tried in order to access the element on the specified target type, or an empty list if no suitable accessor could be found
      Since:
      6.2
    • getPropertyAccessorsToTry

      public static List<PropertyAccessor> getPropertyAccessorsToTry(@Nullable Class<?> targetType, List<PropertyAccessor> propertyAccessors)
      Determine the set of property accessors that should be used to try to access a property on the specified target type.

      The accessors are considered to be in an ordered list; however, in the returned list any accessors that are exact matches for the input target type (as opposed to 'generic' accessors that could work for any type) are placed at the start of the list. In addition, if there are specific accessors that exactly name the class in question and accessors that name a specific class which is a supertype of the class in question, the latter are put at the end of the specific accessors set and will be tried after exactly matching accessors but before generic accessors.

      Parameters:
      targetType - the type upon which property access is being attempted
      propertyAccessors - the list of property accessors to process
      Returns:
      a list of accessors that should be tried in order to access the property on the specified target type, or an empty list if no suitable accessor could be found
      See Also: