Class EnumBranch.Builder<A,E extends Enum<E>>

java.lang.Object
eu.bandm.tools.paisley.EnumBranch.Builder<A,E>
Type Parameters:
A - the target type of objects to match against
E - the enum type to index the branches
Enclosing class:
EnumBranch<A,E extends Enum<E>>

public static class EnumBranch.Builder<A,E extends Enum<E>> extends Object
Incremental builder.
  • Constructor Details

    • Builder

      public Builder(Class<E> cls)
      Creates a new empty builder.
      Parameters:
      cls - the enum class to use for keys
      Throws:
      NullPointerException - if cls is null
    • Builder

      public Builder(E key, Pattern<? super A> subpattern)
      Creates a new builder with a single branch.
      Parameters:
      key - the key of the branch
      subpattern - the subpattern of the branch
      Throws:
      NullPointerException - if key or subpattern is null
  • Method Details

    • put

      public EnumBranch.Builder<A,E> put(E key, Pattern<? super A> subpattern)
      Adds a new branch to this builder.

      This method uses Map.put(K, V) internally; if a branch with the given key already exists, it is overwritten.

      Parameters:
      key - the key for the new branch
      subpattern - the subpattern for the new branch
      Returns:
      this
      Throws:
      NullPointerException - if key or subpattern is null
    • clear

      public void clear()
      Removes all branches of this builder.
    • build

      public EnumBranch<A,E> build()
      Creates a new pattern with the current content of this builder.

      After pattern creation, this builder may be reused.

      Returns:
      a pattern with the same branches as the current content of this builder