Class ClassCopyProvider<T>
java.lang.Object
net.imglib2.loops.ClassCopyProvider<T>
Helper to create multiple copies of a class.
The copies of the class have individual copies of the byte code. The JIT compiler optimizes the class copies individually, which can increase performance.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Class<?>[]assumeConstructorSignature(Class<?> clazz) classForKey(Object key) private static booleanhasDefaultConstructor(Class<?> clazz) booleanReturns true if the given list of objects, matches the constructor signature provided toClassCopyProvider(Class, Class, Class[]).newInstanceForKey(Object key, Object... parameters) Returns an instance of a copy of the original class, that has been provided to the constructor.
-
Field Details
-
map
-
copier
-
signature
-
-
Constructor Details
-
ClassCopyProvider
public ClassCopyProvider(Class<? extends T> clazz, Class<T> interfaceOfClazz, Class<?>... constructorSignature) Create a ClassCopyProvider to make copy a a given class.- Parameters:
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 withnewInstanceForKey(Object, Object...)
-
-
Method Details
-
assumeConstructorSignature
-
hasDefaultConstructor
-
classForKey
-
matches
Returns true if the given list of objects, matches the constructor signature provided toClassCopyProvider(Class, Class, Class[]). -
newInstanceForKey
Returns an instance of a copy of the original class, that has been provided to the constructor.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.
- Parameters:
key- Instances created with the same key, share their byte code.parameters- Parameters that are passed to the constructor.
-