K - Type of the keys contained in the MethodMappublic class AutoInstantiatingMethodMap<K> extends AbstractMethodMap<K>
| Constructor and Description |
|---|
AutoInstantiatingMethodMap(MapEntryKeyFactory<K> entryKeyFactory,
MethodCollectionFactory methodCollectionFactory,
java.lang.invoke.MethodHandles.Lookup lookup) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
invoke(K key,
ArgsFactory argsFactory)
Invokes the methodhandle contained in the methodhandleinfo mapped to the provided key with
arguments produced by the given argsfactory.
|
java.lang.Object |
invoke(K key,
java.lang.Class<?>[] constructorParameterTypes,
java.lang.Object[] constructorArgs,
ArgsFactory argsFactory)
Invokes the methodhandle contained in the methodhandleinfo mapped to the provided key with
the arguments produced by the given argsfactory.
|
java.lang.Object |
invoke(K key,
java.lang.Class<?>[] constructorParameterTypes,
java.lang.Object[] constructorArgs,
java.lang.Object... args)
Invokes the methodhandle contained in the methodhandleinfo mapped to the provided key with
the given arguments.
|
java.lang.Object |
invoke(K key,
java.lang.Object... args)
Invokes the methodhandle contained in the methodhandleinfo mapped to the provided key with
the given arguments.
|
protected java.lang.Object |
invoke(MethodHandleInfo methodHandleInfo,
ArgsFactory argsFactory)
Invokes the methodhandle contained in the provided methodhandleinfo with the arguments
produced by the provided argsfactory.
|
protected java.lang.Object |
invoke(MethodHandleInfo methodHandleInfo,
java.lang.Class<?>[] constructorParameterTypes,
java.lang.Object[] constructorArgs,
ArgsFactory argsFactory)
Invokes the methodhandle contained in the provided methodhandleinfo with the arguments
produced by the given argsfactory.
|
protected java.lang.Object |
invoke(MethodHandleInfo methodHandleInfo,
java.lang.Class<?>[] constructorParameterTypes,
java.lang.Object[] constructorArgs,
java.lang.Object... args)
Invokes the methodhandle contained in the provided methodhandleinfo with the given
arguments.
|
protected java.lang.Object |
invoke(MethodHandleInfo methodHandleInfo,
java.lang.Object... args)
Invokes the methodhandle contained in the provided methodhandleinfo with the provided
arguments.
|
java.lang.Object |
invoke(java.lang.Object... args)
Treats the first argument as the key, the remaining arguments as the methodhandle
arguments, and invokes the methodhandle contained in the methodhandleinfo
mapped to the provided key with the given arguments.
|
getMethodHandleInfoclear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuespublic AutoInstantiatingMethodMap(MapEntryKeyFactory<K> entryKeyFactory, MethodCollectionFactory methodCollectionFactory, java.lang.invoke.MethodHandles.Lookup lookup) throws DuplicateKeyException, MethodCollectionProductionException, java.lang.IllegalAccessException, MapEntryKeyProductionException
entryKeyFactory - factory used to generate keys for each of
the methods produced by
methodCollectionFactorymethodCollectionFactory - Produces a collection of methods that will be
included in this methodmap.lookup - the lookup object used to convert the produced
methods into methodhandlesDuplicateKeyException - If more than one of the same key is generated
for the entries of the methodmap.MethodCollectionProductionException - If the methodcollectionfactory fails to produce
a method collection.java.lang.IllegalAccessException - If MethodHandle lookup fails for any of the
produced methods.MapEntryKeyProductionException - If entry keys fail to be generated for any of
the produced methods.protected java.lang.Object invoke(MethodHandleInfo methodHandleInfo, java.lang.Class<?>[] constructorParameterTypes, java.lang.Object[] constructorArgs, java.lang.Object... args) throws java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, InvocationException
Attempts to instantiate an object with the provided constructor parameter types and arguments if the underlying method is non-static.
methodHandleInfo - the methodhandleinfo containing the methodhandle to be
invokedconstructorParameterTypes - the parameter types of the desired constructorconstructorArgs - the arguments to be passed to the desired constructorargs - the arguments to be passed to the methodhandlejava.lang.SecurityException - See the documentation for
Class.getConstructor(Class...).java.lang.NoSuchMethodException - See the documentation for
Class.getConstructor(Class...).java.lang.reflect.InvocationTargetException - See the documentation for
Constructor.newInstance(Object...).java.lang.IllegalArgumentException - See the documentation for
Constructor.newInstance(Object...).java.lang.IllegalAccessException - See the documentation for
Constructor.newInstance(Object...).java.lang.InstantiationException - See the documentation for
Constructor.newInstance(Object...).InvocationException - If methodhandle invocation fails.protected java.lang.Object invoke(MethodHandleInfo methodHandleInfo, java.lang.Class<?>[] constructorParameterTypes, java.lang.Object[] constructorArgs, ArgsFactory argsFactory) throws java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, ArgsProductionException, InvocationException
Attempts to instantiate an object with the provided constructor parameter types and arguments if the underlying method is non-static.
methodHandleInfo - the methodhandleinfo containing the methodhandle to
be invokedconstructorParameterTypes - the parameter types of the desired constructorconstructorArgs - the arguments to be passed to the desired constructorargsFactory - Produces the arguments that are passed to the methodhandle.java.lang.reflect.InvocationTargetException - See the documentation for
Constructor.newInstance(Object...).java.lang.IllegalArgumentException - See the documentation for
Constructor.newInstance(Object...).java.lang.IllegalAccessException - See the documentation for
Constructor.newInstance(Object...).java.lang.InstantiationException - See the documentation for
Constructor.newInstance(Object...).java.lang.SecurityException - See the documentation for
Class.getConstructor(Class...).java.lang.NoSuchMethodException - See the documentation for
Class.getConstructor(Class...).ArgsProductionException - If the argsfactory fails to produce arguments.InvocationException - If methodhandle invocation fails.protected java.lang.Object invoke(MethodHandleInfo methodHandleInfo, java.lang.Object... args) throws InvocationException
Convenience method for instantiating objects with the default constructor when the underlying method is non-static.
Equivalent to calling invoke(MethodHandleInfo, null, null, Object...)
invoke in class AbstractMethodMap<K>methodHandleInfo - the methodhandleinfo containing the methodhandle to be invokedargs - the arguments to be passed to the methodhandleInvocationException - If invocation fails.protected java.lang.Object invoke(MethodHandleInfo methodHandleInfo, ArgsFactory argsFactory) throws ArgsProductionException, InvocationException
Convenience method for instantiating objects with the default constructor when the underlying method is non-static.
Equivalent to calling invoke(MethodHandleInfo, null, null, ArgsFactory)
invoke in class AbstractMethodMap<K>methodHandleInfo - the methodhandleinfo containing the methodhandle to
be invokedargsFactory - Produces the arguments that are passed to the methodhandle.ArgsProductionException - If the argsfactory fails to produce arguments.InvocationException - If invocation fails.public java.lang.Object invoke(K key, java.lang.Class<?>[] constructorParameterTypes, java.lang.Object[] constructorArgs, java.lang.Object... args) throws java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, UnmappedKeyException, InvocationException
Attempts to instantiate an object with the provided constructor parameter types and arguments if the underlying method is non-static.
key - the key to which the desired methodhandleinfo is mappedconstructorParameterTypes - the parameter types of the desired constructorconstructorArgs - the arguments to be passed to the desired constructorargs - the arguments to be passed to the methodhandlejava.lang.reflect.InvocationTargetException - See the documentation for
Constructor.newInstance(Object...).java.lang.IllegalArgumentException - See the documentation for
Constructor.newInstance(Object...).java.lang.IllegalAccessException - See the documentation for
Constructor.newInstance(Object...).java.lang.InstantiationException - See the documentation for
Constructor.newInstance(Object...).java.lang.SecurityException - See the documentation for
Class.getConstructor(Class...).java.lang.NoSuchMethodException - See the documentation for
Class.getConstructor(Class...).UnmappedKeyException - If there is no methodhandleinfo associated with the
provided key.InvocationException - If methodhandle invocation fails.public java.lang.Object invoke(K key, java.lang.Class<?>[] constructorParameterTypes, java.lang.Object[] constructorArgs, ArgsFactory argsFactory) throws java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException, ArgsProductionException, UnmappedKeyException, InvocationException
Attempts to instantiate an object with the provided constructor parameter types and arguments if the underlying method is non-static.
key - the key to which the desired methodhandleinfo is mappedconstructorParameterTypes - the parameter types of the desired constructorconstructorArgs - the arguments to be passed to the desired constructorargsFactory - Produces the arguments that are passed to the methodhandle.java.lang.reflect.InvocationTargetException - See the documentation for
Constructor.newInstance(Object...).java.lang.IllegalArgumentException - See the documentation for
Constructor.newInstance(Object...).java.lang.IllegalAccessException - See the documentation for
Constructor.newInstance(Object...).java.lang.InstantiationException - See the documentation for
Constructor.newInstance(Object...).java.lang.SecurityException - See the documentation for
Class.getConstructor(Class...).java.lang.NoSuchMethodException - See the documentation for
Class.getConstructor(Class...).UnmappedKeyException - If there is no methodhandleinfo associated with the
provided key.ArgsProductionException - If the argsfactory fails to produce arguments.InvocationException - If methodhandle invocation fails.public java.lang.Object invoke(K key, java.lang.Object... args) throws UnmappedKeyException, InvocationException
Convenience method for instantiating objects with the default constructor when the underlying method in non-static.
Equivalent to calling invoke(Object, null, null, Object...)
invoke in class AbstractMethodMap<K>key - the key to which the desired methodhandleinfo is mappedargs - the arguments to be passed to the methodhandleUnmappedKeyException - If there is no methodhandleinfo associated with the provided
key.InvocationException - If invocation fails.public java.lang.Object invoke(K key, ArgsFactory argsFactory) throws UnmappedKeyException, ArgsProductionException, InvocationException
Convenience method for instantiating objects with the default constructor when the underlying method in non-static.
Equivalent to calling invoke(Object, null, null, ArgsFactory)
invoke in class AbstractMethodMap<K>key - the key to which the desired methodhandleinfo is mappedargsFactory - Produces the arguments that are passed to the methodhandle.java.lang.IllegalArgumentException - See the documentation for
Constructor.newInstance(Object...).java.lang.SecurityException - See the documentation for
Class.getConstructor(Class...).UnmappedKeyException - If there is no methodhandleinfo associated with the provided
key.ArgsProductionException - If the argsfactory fails to produce arguments.InvocationException - If invocation fails.public java.lang.Object invoke(java.lang.Object... args)
throws UnmappedKeyException,
InvocationException
Uses the default constructor for non-static methods.
invoke in class AbstractMethodMap<K>args - the key to which the desired methodhandleinfo is mapped and the
arguments to be passed to the methodhandlejava.lang.IllegalArgumentException - See the documentation for
Constructor.newInstance(Object...).java.lang.SecurityException - See the documentation for
Class.getConstructor(Class...).UnmappedKeyException - If there is no methodhandleinfo associated with the provided
key.InvocationException - If invocation fails.