public class ClassCopyProvider<T> extends Object
The copies of the class have individual copies of the byte code. The JIT compiler optimizes the class copies individually, which can increase performance.
Constructor and Description |
---|
ClassCopyProvider(Class<? extends T> clazz,
Class<T> interfaceOfClazz,
Class<?>... constructorSignature)
Create a ClassCopyProvider to make copy a a given class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
matches(Object... parameters)
Returns true if the given list of objects,
matches the constructor signature provided to
ClassCopyProvider(Class, Class, Class[]) . |
T |
newInstanceForKey(Object key,
Object... parameters)
Returns an instance of a copy of the original class, that has been provided to the constructor.
|
public ClassCopyProvider(Class<? extends T> clazz, Class<T> interfaceOfClazz, Class<?>... constructorSignature)
clazz
- Class to be copied.interfaceOfClazz
- Interface that's implemented by the clazz. A class copies can only be used
through this interface.constructorSignature
- Constructor signature to be used
when creating a new instance with newInstanceForKey(java.lang.Object, java.lang.Object...)
public boolean matches(Object... parameters)
ClassCopyProvider(Class, Class, Class[])
.public T newInstanceForKey(Object key, Object... parameters)
Note: The returned object isn't an instance of the original class.
Class.isInstance(Object)
and "instanceof" will return false.
And ClassCastException might occur if this is ignored.
The returned instance has a copy of the byte code of the original class. This byte code is independently optimised by the JIT compiler. The JIT compiler will optimise the byte code, if it's only used in a specific use case. If used wisely a performance increase is the consequence.
key
- Instances created with the same key, share their byte code.parameters
- Parameters that are passed to the constructor.Copyright © 2015–2022 ImgLib2. All rights reserved.