Interface ValueResolver

All Superinterfaces:
Resolver, WithPriority
All Known Implementing Classes:
NamedArgument.SetValueResolver, ReflectionValueResolver, ValueResolvers.ArrayResolver, ValueResolvers.CollectionResolver, ValueResolvers.EqualsResolver, ValueResolvers.ListResolver, ValueResolvers.LogicalAndResolver, ValueResolvers.LogicalOrResolver, ValueResolvers.MapEntryResolver, ValueResolvers.MapperResolver, ValueResolvers.MapResolver, ValueResolvers.MinusResolver, ValueResolvers.ModResolver, ValueResolvers.NumberValueResolver, ValueResolvers.OrEmptyResolver, ValueResolvers.OrResolver, ValueResolvers.PlusResolver, ValueResolvers.RawResolver, ValueResolvers.ThisResolver, ValueResolvers.TrueResolver

public interface ValueResolver extends Resolver, WithPriority
Value resolvers are used when evaluating expressions.

First the resolvers that apply to the given EvalContext are filtered. Then the resolver with highest priority is used to resolve the data. If a Results.NotFound object is returned then the next available resolver is used instead. However, null return value is considered a valid result.

See Also:
  • Method Details

    • getPriority

      default int getPriority()
      Value resolvers with higher priority take precedence.
      Specified by:
      getPriority in interface WithPriority
      Returns:
      the priority value
    • appliesTo

      default boolean appliesTo(EvalContext context)
      Parameters:
      context -
      Returns:
      true if this resolver applies to the given context
    • getCachedResolver

      default ValueResolver getCachedResolver(EvalContext context)
      When appliesTo(EvalContext) returns true for a specific EvalContext and the subsequent invocation of Resolver.resolve(EvalContext) does not return
      invalid reference
      Results#NotFound
      the value resolver returned from this method is cached for the specific part of an expression.

      By default, the resolver itself is cached. However, it is also possible to return an optimized version.

      Parameters:
      context -
      Returns:
      the resolver that should be cached
    • getSupportedProperties

      default Set<String> getSupportedProperties()
      Returns the set of property names supported by this value resolver for code completion in the Qute debugger.

      These properties are suggested when evaluating expressions on a base object. For example, if the user invokes completion at myList.|, the evaluation context will be initialized with myList as the base object, and appliesTo will be called with that context. Only if it returns true will the properties from this set be proposed.

      Completion examples:

      • "length" → inserts as-is: myList.length|
      • "size" → inserts as-is: myList.size|

      Example:

      
       @Override
       public Set<String> getSupportedProperties() {
           return Set.of("length", "size");
       }
       
      Returns:
      a set of supported property names to be shown in the debugger's code completion
    • getSupportedMethods

      default Set<String> getSupportedMethods()
      Returns the set of method signatures supported by this value resolver for code completion in the Qute debugger.

      These methods are suggested when evaluating expressions on a base object. For example, if the user invokes completion at myList.|, the evaluation context will be initialized with myList as the base object, and appliesTo will be called with that context. Only if it returns true will the methods from this set be proposed.

      Completion examples:

      • "take(index)" → inserts as-is: myList.take(index)|
      • "takeLast(${index})" → inserts with the parameter selected: myList.takeLast(|[index])

      The ${param} syntax indicates that the debugger selects the parameter so the user can type it immediately.

      Example:

      
       @Override
       public Set<String> getSupportedMethods() {
           return Set.of("take(index)", "takeLast(${index})");
       }
       
      Returns:
      a set of supported method signatures to be shown in the debugger's code completion
    • builder

      static ValueResolverBuilder builder()
      Returns:
      a new builder
    • matchClass

      static boolean matchClass(EvalContext ctx, Class<?> clazz)