Class GuardedBinding

java.lang.Object
com.github.mustachejava.reflect.GuardedBinding
All Implemented Interfaces:
Binding

public class GuardedBinding extends Object implements Binding
Codes are bound to their variables through bindings. User: sam Date: 7/7/12 Time: 6:05 PM
  • Field Details

    • EMPTY_WRAPPERS

      private static final Wrapper[] EMPTY_WRAPPERS
    • logger

      private static Logger logger
    • debug

      private static boolean debug
    • oh

      private final ObjectHandler oh
    • tc

      private final TemplateContext tc
    • name

      private final String name
    • code

      private final Code code
    • previousSet

      private Set<Wrapper> previousSet
      The chances of a new guard every time is very low. Instead we will store previously used guards and try them all before creating a new one.
    • prevWrappers

      private volatile Wrapper[] prevWrappers
  • Constructor Details

  • Method Details

    • get

      public Object get(List<Object> scopes)
      Retrieve the first value in the stacks of scopes that matches the give name. The method wrappers are cached and guarded against the type or number of scopes changing. Methods will be found using the object handler, called here with another lookup on a guard failure and finally coerced to a final value based on the ObjectHandler you provide.
      Specified by:
      get in interface Binding
      Parameters:
      scopes - An array of scopes to interrogate from right to left.
      Returns:
      The value of the field or method
    • createAndGet

      private Object createAndGet(List<Object> scopes)
    • getWrapper

      protected Wrapper getWrapper(String name, List<Object> scopes)
    • logWarning

      public static void logWarning(String warning, String name, List<Object> scopes, TemplateContext tc)