Class DynMethods.Builder

java.lang.Object
org.apache.hadoop.util.dynamic.DynMethods.Builder
Enclosing class:
DynMethods

public static final class DynMethods.Builder extends Object
  • Constructor Details

    • Builder

      public Builder(String methodName)
  • Method Details

    • loader

      public DynMethods.Builder loader(ClassLoader classLoader)
      Set the ClassLoader used to lookup classes by name.

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

      Parameters:
      classLoader - a ClassLoader
      Returns:
      this Builder for method chaining
    • orNoop

      public DynMethods.Builder orNoop()
      If no implementation has been found, adds a NOOP method.

      Note: calls to impl will not match after this method is called!

      Returns:
      this Builder for method chaining
    • impl

      public DynMethods.Builder impl(String className, String methodName, Class<?>... argClasses)
      Checks for an implementation, first finding the given class by name.
      Parameters:
      className - name of a class
      methodName - name of a method (different from constructor)
      argClasses - argument classes for the method
      Returns:
      this Builder for method chaining
    • impl

      public DynMethods.Builder impl(String className, Class<?>... argClasses)
      Checks for an implementation, first finding the given class by name.

      The name passed to the constructor is the method name used.

      Parameters:
      className - name of a class
      argClasses - argument classes for the method
      Returns:
      this Builder for method chaining
    • impl

      public DynMethods.Builder impl(Class<?> targetClass, String methodName, Class<?>... argClasses)
      Checks for a method implementation.
      Parameters:
      targetClass - the class to check for an implementation
      methodName - name of a method (different from constructor)
      argClasses - argument classes for the method
      Returns:
      this Builder for method chaining
    • impl

      public DynMethods.Builder impl(Class<?> targetClass, Class<?>... argClasses)
      Checks for a method implementation.

      The name passed to the constructor is the method name used.

      Parameters:
      targetClass - the class to check for an implementation
      argClasses - argument classes for the method
      Returns:
      this Builder for method chaining
    • ctorImpl

      public DynMethods.Builder ctorImpl(Class<?> targetClass, Class<?>... argClasses)
    • ctorImpl

      public DynMethods.Builder ctorImpl(String className, Class<?>... argClasses)
    • hiddenImpl

      public DynMethods.Builder hiddenImpl(String className, String methodName, Class<?>... argClasses)
      Checks for an implementation, first finding the given class by name.
      Parameters:
      className - name of a class
      methodName - name of a method (different from constructor)
      argClasses - argument classes for the method
      Returns:
      this Builder for method chaining
    • hiddenImpl

      public DynMethods.Builder hiddenImpl(String className, Class<?>... argClasses)
      Checks for an implementation, first finding the given class by name.

      The name passed to the constructor is the method name used.

      Parameters:
      className - name of a class
      argClasses - argument classes for the method
      Returns:
      this Builder for method chaining
    • hiddenImpl

      public DynMethods.Builder hiddenImpl(Class<?> targetClass, String methodName, Class<?>... argClasses)
      Checks for a method implementation.
      Parameters:
      targetClass - the class to check for an implementation
      methodName - name of a method (different from constructor)
      argClasses - argument classes for the method
      Returns:
      this Builder for method chaining
    • hiddenImpl

      public DynMethods.Builder hiddenImpl(Class<?> targetClass, Class<?>... argClasses)
      Checks for a method implementation.

      The name passed to the constructor is the method name used.

      Parameters:
      targetClass - the class to check for an implementation
      argClasses - argument classes for the method
      Returns:
      this Builder for method chaining
    • buildChecked

      public DynMethods.UnboundMethod buildChecked() throws NoSuchMethodException
      Returns the first valid implementation as a UnboundMethod or throws a NoSuchMethodException if there is none.
      Returns:
      a DynMethods.UnboundMethod with a valid implementation
      Throws:
      NoSuchMethodException - if no implementation was found
    • build

      public DynMethods.UnboundMethod build()
      Returns the first valid implementation as a UnboundMethod or throws a RuntimeError if there is none.
      Returns:
      a DynMethods.UnboundMethod with a valid implementation
      Throws:
      RuntimeException - if no implementation was found
    • buildChecked

      public DynMethods.BoundMethod buildChecked(Object receiver) throws NoSuchMethodException
      Returns the first valid implementation as a BoundMethod or throws a NoSuchMethodException if there is none.
      Parameters:
      receiver - an Object to receive the method invocation
      Returns:
      a DynMethods.BoundMethod with a valid implementation and receiver
      Throws:
      IllegalStateException - if the method is static
      IllegalArgumentException - if the receiver's class is incompatible
      NoSuchMethodException - if no implementation was found
    • build

      public DynMethods.BoundMethod build(Object receiver)
      Returns the first valid implementation as a BoundMethod or throws a RuntimeError if there is none.
      Parameters:
      receiver - an Object to receive the method invocation
      Returns:
      a DynMethods.BoundMethod with a valid implementation and receiver
      Throws:
      IllegalStateException - if the method is static
      IllegalArgumentException - if the receiver's class is incompatible
      RuntimeException - if no implementation was found
    • buildStaticChecked

      public DynMethods.StaticMethod buildStaticChecked() throws NoSuchMethodException
      Returns the first valid implementation as a StaticMethod or throws a NoSuchMethodException if there is none.
      Returns:
      a DynMethods.StaticMethod with a valid implementation
      Throws:
      IllegalStateException - if the method is not static
      NoSuchMethodException - if no implementation was found
    • buildStatic

      public DynMethods.StaticMethod buildStatic()
      Returns the first valid implementation as a StaticMethod or throws a RuntimeException if there is none.
      Returns:
      a DynMethods.StaticMethod with a valid implementation
      Throws:
      IllegalStateException - if the method is not static
      RuntimeException - if no implementation was found