I
- the input argument type for the resolved functionsR
- the return type for the resolved functions@InterfaceAudience.Private public final class ReflectedFunctionCache<I,R> extends Object
getAndCallByName(String, Object)
should have handling for null return values.
An instance is created for a specified baseClass (i.e. Filter), argClass (i.e. byte[]), and static methodName to call. These are used to resolve a Function which delegates to that static method, if it is found.
Modifier and Type | Field and Description |
---|---|
private Class<I> |
argClass |
private Class<R> |
baseClass |
private ClassLoader |
classLoader |
private ConcurrentMap<String,Function<I,? extends R>> |
lambdasByClass |
private static org.slf4j.Logger |
LOG |
private String |
methodName |
Constructor and Description |
---|
ReflectedFunctionCache(Class<R> baseClass,
Class<I> argClass,
String staticMethodName) |
Modifier and Type | Method and Description |
---|---|
R |
getAndCallByName(String className,
I argument)
Get and execute the Function for the given className, passing the argument to the function and
returning the result.
|
private Function<I,? extends R> |
loadFunction(String className) |
private R |
notFound(I argument)
In order to use computeIfAbsent, we can't store nulls in our cache.
|
private static final org.slf4j.Logger LOG
private final ConcurrentMap<String,Function<I,? extends R>> lambdasByClass
private final String methodName
private final ClassLoader classLoader
@Nullable public R getAndCallByName(String className, I argument)
className
- the full name of the class to lookupargument
- the argument to pass to the function, if found.private Function<I,? extends R> loadFunction(String className)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.