public static class DynMethods.Builder
extends java.lang.Object
Constructor and Description |
---|
Builder(java.lang.String methodName) |
Modifier and Type | Method and Description |
---|---|
DynMethods.UnboundMethod |
build()
Returns the first valid implementation as a UnboundMethod or throws a RuntimeError if there
is none.
|
DynMethods.BoundMethod |
build(java.lang.Object receiver)
Returns the first valid implementation as a BoundMethod or throws a RuntimeError if there is
none.
|
DynMethods.UnboundMethod |
buildChecked()
Returns the first valid implementation as a UnboundMethod or throws a NoSuchMethodException
if there is none.
|
DynMethods.BoundMethod |
buildChecked(java.lang.Object receiver)
Returns the first valid implementation as a BoundMethod or throws a NoSuchMethodException if
there is none.
|
DynMethods.StaticMethod |
buildStatic()
Returns the first valid implementation as a StaticMethod or throws a RuntimeException if
there is none.
|
DynMethods.StaticMethod |
buildStaticChecked()
Returns the first valid implementation as a StaticMethod or throws a NoSuchMethodException if
there is none.
|
DynMethods.Builder |
ctorImpl(java.lang.Class<?> targetClass,
java.lang.Class<?>... argClasses) |
DynMethods.Builder |
ctorImpl(java.lang.String className,
java.lang.Class<?>... argClasses) |
DynMethods.Builder |
hiddenImpl(java.lang.Class<?> targetClass,
java.lang.Class<?>... argClasses)
Checks for a method implementation.
|
DynMethods.Builder |
hiddenImpl(java.lang.Class<?> targetClass,
java.lang.String methodName,
java.lang.Class<?>... argClasses)
Checks for a method implementation.
|
DynMethods.Builder |
hiddenImpl(java.lang.String className,
java.lang.Class<?>... argClasses)
Checks for an implementation, first finding the given class by name.
|
DynMethods.Builder |
hiddenImpl(java.lang.String className,
java.lang.String methodName,
java.lang.Class<?>... argClasses)
Checks for an implementation, first finding the given class by name.
|
DynMethods.Builder |
impl(java.lang.Class<?> targetClass,
java.lang.Class<?>... argClasses)
Checks for a method implementation.
|
DynMethods.Builder |
impl(java.lang.Class<?> targetClass,
java.lang.String methodName,
java.lang.Class<?>... argClasses)
Checks for a method implementation.
|
DynMethods.Builder |
impl(java.lang.String className,
java.lang.Class<?>... argClasses)
Checks for an implementation, first finding the given class by name.
|
DynMethods.Builder |
impl(java.lang.String className,
java.lang.String methodName,
java.lang.Class<?>... argClasses)
Checks for an implementation, first finding the given class by name.
|
DynMethods.Builder |
loader(java.lang.ClassLoader newLoader)
Set the
ClassLoader used to lookup classes by name. |
DynMethods.Builder |
orNoop()
If no implementation has been found, adds a NOOP method.
|
public DynMethods.Builder loader(java.lang.ClassLoader newLoader)
ClassLoader
used to lookup classes by name.
If not set, the current thread's ClassLoader is used.
newLoader
- a ClassLoaderpublic DynMethods.Builder orNoop()
Note: calls to impl will not match after this method is called!
public DynMethods.Builder impl(java.lang.String className, java.lang.String methodName, java.lang.Class<?>... argClasses)
className
- name of a classmethodName
- name of a method (different from constructor)argClasses
- argument classes for the methodClass.forName(String)
,
Class.getMethod(String, Class[])
public DynMethods.Builder impl(java.lang.String className, java.lang.Class<?>... argClasses)
The name passed to the constructor is the method name used.
className
- name of a classargClasses
- argument classes for the methodClass.forName(String)
,
Class.getMethod(String, Class[])
public DynMethods.Builder impl(java.lang.Class<?> targetClass, java.lang.String methodName, java.lang.Class<?>... argClasses)
targetClass
- a class instancemethodName
- name of a method (different from constructor)argClasses
- argument classes for the methodClass.forName(String)
,
Class.getMethod(String, Class[])
public DynMethods.Builder impl(java.lang.Class<?> targetClass, java.lang.Class<?>... argClasses)
The name passed to the constructor is the method name used.
targetClass
- a class instanceargClasses
- argument classes for the methodClass.forName(String)
,
Class.getMethod(String, Class[])
public DynMethods.Builder ctorImpl(java.lang.Class<?> targetClass, java.lang.Class<?>... argClasses)
public DynMethods.Builder ctorImpl(java.lang.String className, java.lang.Class<?>... argClasses)
public DynMethods.Builder hiddenImpl(java.lang.String className, java.lang.String methodName, java.lang.Class<?>... argClasses)
className
- name of a classmethodName
- name of a method (different from constructor)argClasses
- argument classes for the methodClass.forName(String)
,
Class.getMethod(String, Class[])
public DynMethods.Builder hiddenImpl(java.lang.String className, java.lang.Class<?>... argClasses)
The name passed to the constructor is the method name used.
className
- name of a classargClasses
- argument classes for the methodClass.forName(String)
,
Class.getMethod(String, Class[])
public DynMethods.Builder hiddenImpl(java.lang.Class<?> targetClass, java.lang.String methodName, java.lang.Class<?>... argClasses)
targetClass
- a class instancemethodName
- name of a method (different from constructor)argClasses
- argument classes for the methodClass.forName(String)
,
Class.getMethod(String, Class[])
public DynMethods.Builder hiddenImpl(java.lang.Class<?> targetClass, java.lang.Class<?>... argClasses)
The name passed to the constructor is the method name used.
targetClass
- a class instanceargClasses
- argument classes for the methodClass.forName(String)
,
Class.getMethod(String, Class[])
public DynMethods.UnboundMethod build()
DynMethods.UnboundMethod
with a valid implementationjava.lang.RuntimeException
- if no implementation was foundpublic DynMethods.BoundMethod build(java.lang.Object receiver)
receiver
- an Object to receive the method invocationDynMethods.BoundMethod
with a valid implementation and receiverjava.lang.IllegalStateException
- if the method is staticjava.lang.IllegalArgumentException
- if the receiver's class is incompatiblejava.lang.RuntimeException
- if no implementation was foundpublic DynMethods.UnboundMethod buildChecked() throws java.lang.NoSuchMethodException
DynMethods.UnboundMethod
with a valid implementationjava.lang.NoSuchMethodException
- if no implementation was foundpublic DynMethods.BoundMethod buildChecked(java.lang.Object receiver) throws java.lang.NoSuchMethodException
receiver
- an Object to receive the method invocationDynMethods.BoundMethod
with a valid implementation and receiverjava.lang.IllegalStateException
- if the method is staticjava.lang.IllegalArgumentException
- if the receiver's class is incompatiblejava.lang.NoSuchMethodException
- if no implementation was foundpublic DynMethods.StaticMethod buildStaticChecked() throws java.lang.NoSuchMethodException
DynMethods.StaticMethod
with a valid implementationjava.lang.IllegalStateException
- if the method is not staticjava.lang.NoSuchMethodException
- if no implementation was foundpublic DynMethods.StaticMethod buildStatic()
DynMethods.StaticMethod
with a valid implementationjava.lang.IllegalStateException
- if the method is not staticjava.lang.RuntimeException
- if no implementation was found