Class Bindings

java.lang.Object
com.google.errorprone.refaster.Bindings

public class Bindings extends Object
A type-safe binding environment mapping Bindings.Key<V> keys to values of type V.

Bindings are represented as a persistent linked chain. Adding a binding creates a new Bindings.Node pointing to the current head as its parent, and lookups traverse parent references towards the root, naturally shadowing earlier bindings for the same key. Forking a Bindings instance shares the underlying node chain with zero entry copying.

Author:
Louis Wasserman
  • Method Details

    • create

      public static Bindings create()
    • create

      public static Bindings create(Bindings bindings)
    • isEmpty

      public boolean isEmpty()
    • containsKey

      public boolean containsKey(Bindings.Key<?> key)
    • getBinding

      public <V> @Nullable V getBinding(Bindings.Key<V> key)
    • putBinding

      @CanIgnoreReturnValue public <V> V putBinding(Bindings.Key<V> key, V value)
    • clearBinding

      public void clearBinding(Bindings.Key<?> key)
    • forEach

      public void forEach(BiConsumer<? super Bindings.Key<?>, Object> action)
    • hasBindingForLocalVar

      public boolean hasBindingForLocalVar(@Nullable com.sun.tools.javac.code.Symbol symbol)
    • hasFreeIdentMatching

      public boolean hasFreeIdentMatching(Predicate<com.sun.tools.javac.tree.JCTree.JCExpression> predicate)
    • asMap

      public com.google.common.collect.ImmutableMap<Bindings.Key<?>, Object> asMap()
    • toString

      public String toString()
      Overrides:
      toString in class Object