Class BindingBuilder

  • public class BindingBuilder
    extends java.lang.Object
    Build Bindings.

    Binding are immutable and can not be changed once constructed. A BindingBuilder accumulates some var/node pairs and, at the build step, chooses the most efficient Binding implementation.

       Binding binding = Binding.builder()
                            .add(var, value)
    The build() method can only be called once per binding constructed. A BindingBuilder can be reused but is not thread safe.


       BindingBuilder builder = Binding.builder(parent);
       for .... {
          for ( ... each variable ... ) {
              builder.add(var, node)
          Binding binding =;
          ... accumulate binding ...


       BindingBuilder builder = Binding.builder(parent);
       for .... {
          Binding binding =
                 .add(var1, node1)
                 .add(var2, node2)
                 .add(var3, node3)
          ... accumulate binding ...
    See also BindingFactory. When the number of var/node pairs is fixed and known, operations in BindingFactory directly create a binding without needing a builder.
    • Field Detail

      • noParent

        public static final Binding noParent
    • Method Detail

      • set

        public BindingBuilder set​(Var var,
                                  Node node)
        Accumulate (var,value) pairs. Allow binding in this level to be replaced (i.e. not in parent)
      • addAll

        public BindingBuilder addAll​(Binding other)
        Add all the (var, value) pairs from another binding
      • getOrSame

        public Node getOrSame​(Var var)
        Get or return the variable.
      • get

        public Node get​(Var var)
      • contains

        public boolean contains​(Var var)
      • isEmpty

        public boolean isEmpty()
      • vars1

        public java.util.Iterator<Var> vars1()
        Variables in the builder - does not include the parent.
      • reset

        public BindingBuilder reset()
        Reset the builder state, while keeping the parent
      • build

        public Binding build()
        Construct the binding. This can be called only once for a binding but the builder can be reused after a call to reset().
      • snapshot

        public Binding snapshot()
        Build a view of the current state.

        Do not modify the builder while this binding is in use. Changes to the builder make this view unstable. To create a finished binding, call build().

      • toString

        public java.lang.String toString()
        toString in class java.lang.Object