Class DynConstructors.Builder

java.lang.Object
org.apache.iceberg.common.DynConstructors.Builder
Enclosing class:
DynConstructors

public static class DynConstructors.Builder extends Object
Builder for resolving a constructor from candidate implementations.
  • Constructor Details

    • Builder

      public Builder(Class<?> baseClass)
      Constructs a builder for the given base class.
      Parameters:
      baseClass - the base class used in error messages when no constructor is found
    • Builder

      public Builder()
      Constructs a builder with no base class.
  • Method Details

    • loader

      public DynConstructors.Builder loader(ClassLoader newLoader)
      Set the ClassLoader used to lookup classes by name.

      If not set, the current thread's ClassLoader is used.

      Parameters:
      newLoader - a ClassLoader
      Returns:
      this Builder for method chaining
    • impl

      public DynConstructors.Builder impl(String className, Class<?>... types)
      Checks for an implementation, first finding the class by name.
      Parameters:
      className - name of a class
      types - the constructor argument types
      Returns:
      this Builder for method chaining
    • impl

      public <T> DynConstructors.Builder impl(Class<T> targetClass, Class<?>... types)
      Checks for an implementation.
      Type Parameters:
      T - the type of the target class
      Parameters:
      targetClass - a class instance
      types - the constructor argument types
      Returns:
      this Builder for method chaining
    • hiddenImpl

      public DynConstructors.Builder hiddenImpl(String className, Class<?>... types)
      Checks for a hidden implementation, first finding the class by name.
      Parameters:
      className - name of a class
      types - the constructor argument types
      Returns:
      this Builder for method chaining
    • hiddenImpl

      public <T> DynConstructors.Builder hiddenImpl(Class<T> targetClass, Class<?>... types)
      Checks for a hidden implementation.
      Type Parameters:
      T - the type of the target class
      Parameters:
      targetClass - a class instance
      types - the constructor argument types
      Returns:
      this Builder for method chaining
    • buildChecked

      public <C> DynConstructors.Ctor<C> buildChecked() throws NoSuchMethodException
      Returns the first valid constructor as a DynConstructors.Ctor or throws a NoSuchMethodException if there is none.
      Type Parameters:
      C - Java class constructed by the constructor
      Returns:
      a DynConstructors.Ctor with a valid implementation
      Throws:
      NoSuchMethodException - if no implementation was found
    • build

      public <C> DynConstructors.Ctor<C> build()
      Returns the first valid constructor as a DynConstructors.Ctor or throws a RuntimeException if there is none.
      Type Parameters:
      C - Java class constructed by the constructor
      Returns:
      a DynConstructors.Ctor with a valid implementation
      Throws:
      RuntimeException - if no implementation was found