Class AbstractCopier<A>
java.lang.Object
com.github.benmanes.caffeine.jcache.copy.AbstractCopier<A>
- All Implemented Interfaces:
Copier
- Direct Known Subclasses:
JavaSerializationCopier
A skeleton implementation where subclasses provide the serialization strategy. Serialization is
not performed if the type is a known immutable, an array of known immutable types, or specially
handled by a known cloning strategy.
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> TarrayCopy(T object) protected booleancanDeeplyCopy(Class<?> clazz) Returns if the class has a known deep copy strategy.<T> Tcopy(T object, ClassLoader classLoader) Returns a deep copy of the object.private <T> TdeepCopy(T object) protected abstract Objectdeserialize(A data, ClassLoader classLoader) Deserializes the data using the provided classloader.private booleanisArrayOfImmutableTypes(Class<?> clazz) protected booleanisImmutable(Class<?> clazz) Returns if the class is an immutable type and does not need to be copied.protected <T> Troundtrip(T object, ClassLoader classLoader) Performs the serialization and deserialization, returning the copied object.protected abstract ASerializes the object.
-
Field Details
-
JAVA_DEEP_COPY
-
JAVA_IMMUTABLE
-
immutableClasses
-
deepCopyStrategies
-
-
Constructor Details
-
AbstractCopier
protected AbstractCopier() -
AbstractCopier
-
-
Method Details
-
javaImmutableClasses
-
javaDeepCopyStrategies
-
copy
Description copied from interface:CopierReturns a deep copy of the object. -
isImmutable
Returns if the class is an immutable type and does not need to be copied.- Parameters:
clazz- the class of the object being copied- Returns:
- if the class is an immutable type and does not need to be copied
-
canDeeplyCopy
Returns if the class has a known deep copy strategy.- Parameters:
clazz- the class of the object being copied- Returns:
- if the class has a known deep copy strategy
-
isArrayOfImmutableTypes
- Returns:
- if the class represents an array of immutable values.
-
arrayCopy
private static <T> T arrayCopy(T object) - Returns:
- a shallow copy of the array.
-
deepCopy
private <T> T deepCopy(T object) - Returns:
- a deep copy of the object.
-
roundtrip
Performs the serialization and deserialization, returning the copied object.- Type Parameters:
T- the type of object being copied- Parameters:
object- the object to serializeclassLoader- the classloader to create the instance with- Returns:
- the deserialized object
-
serialize
-
deserialize
Deserializes the data using the provided classloader.- Parameters:
data- the serialized bytesclassLoader- the classloader to create the instance with- Returns:
- the deserialized object
-