Class ReflectionMap.Builder<V>

java.lang.Object
org.apache.juneau.commons.reflect.ReflectionMap.Builder<V>
Type Parameters:
V - The type of values stored in this map.
Direct Known Subclasses:
DebugEnablementMap.Builder
Enclosing class:
ReflectionMap<V>

public static class ReflectionMap.Builder<V> extends Object
Builder for creating ReflectionMap instances.
Example:

ReflectionMap<String> map = ReflectionMap .create(String.class) .append("MyClass", "value1") .append("MyClass.myMethod", "value2") .build();

  • Constructor Details

    • Builder

      protected Builder()
      Constructor.
  • Method Details

    • append

      public ReflectionMap.Builder<V> append(String key, V value)
      Adds one or more mappings to this builder.

      This method accepts pattern strings that identify classes, methods, fields, or constructors, and associates them with the specified value. Multiple patterns can be specified in a single key using comma-delimited format.

      Example:

      Builder<String> builder = ReflectionMap.create(String.class); // Map a class builder.append("com.foo.MyClass", "classValue"); // Map a specific method builder.append("MyClass.myMethod(String,int)", "methodValue"); // Map multiple patterns at once builder.append("MyClass.field1, MyClass.field2, MyClass.field3", "fieldValue");

      Parameters:
      key - The mapping key pattern(s).
      Can be any of the following:
      • Fully qualified class name (e.g., "com.foo.MyClass")
      • Simple class name (e.g., "MyClass")
      • All classes wildcard (e.g., "*")
      • Method with signature (e.g., "com.foo.MyClass.myMethod(String,int)")
      • Method without signature (e.g., "MyClass.myMethod") - matches any signature
      • Field (e.g., "MyClass.myField")
      • Constructor (e.g., "MyClass(String,int)")
      • Comma-delimited list of any of the above (e.g., "MyClass, MyClass.method1, MyClass.field1")
      value - The value to associate with the matching reflection element(s).
      Can be null.
      Returns:
      This object.
      Throws:
      RuntimeException - If the key pattern is invalid or empty.
    • build

      public ReflectionMap<V> build()
      Builds a new ReflectionMap from the current state of this builder.

      Multiple calls to this method will create independent copies of the map.

      Returns:
      A new immutable ReflectionMap instance.