public final class CopyUtils extends Object
LifecycleElement
implementations.Constructor and Description |
---|
CopyUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
copy(Copyable obj)
Mix-in copy implementation for objects that implement the
Copyable interface} |
static boolean |
fieldHasAnnotation(Class<?> clazz,
String fieldName,
Class<? extends Annotation> annotationClass)
Determines whether the field of the given class has the given annotation specified
|
static <T> T |
getDeepCopy(T obj)
Get a deep copy of an object using cloning.
|
static Annotation |
getFieldAnnotation(Class<?> clazz,
String fieldName,
Class<? extends Annotation> annotationClass)
Returns annotation of the given type for the given field (if present)
|
static Map<String,Annotation> |
getFieldsWithAnnotation(Class<?> clazz,
Class<? extends Annotation> annotationClass)
Retrieves all field names for the given class that have the given annotation
|
static <T> T |
getShallowCopy(T obj)
Get a shallow copy (clone) of an object.
|
static boolean |
isCopyAvailable(Class<?> type)
Determine if deep copying is available for a type.
|
static boolean |
isDelay()
Determine whether or not to use a delayed copy proxy.
|
static <T> T |
unwrap(T obj)
Unwrap an object from any wrapper class or proxy it may be decorated with related to the copy
process.
|
public CopyUtils()
public static boolean isDelay()
When true, deep copy operations will be truncated where a copyable represented by an interfaces is specified by the field, array, list or map involved indicated. Rather than copy the object directly, a proxy wrapping the original will be placed, which when used will invoke the copy operation.
This value is controlled by the parameter "krad.uif.copyable.delay". By default, full deep copy will be used.
public static <T> T copy(Copyable obj)
Copyable
interface}T
- copyable typeobj
- The object to copy.public static boolean isCopyAvailable(Class<?> type)
type
- The type to check.getDeepCopy(Object)
may be expected to follow references to this
type. False if the type should not be deeply copied.public static <T> T getShallowCopy(T obj) throws CloneNotSupportedException
This method simplifies access to the clone() method.
T
- copyable typeobj
- The object to clone.CloneNotSupportedException
- If copying is not available on the object, or if thrown by
clone() itself. When isShallowCopyAvailable() returns true, then this exception is
not expected and may be considered an internal error.public static <T> T unwrap(T obj)
This method is a public utility passthrough for
DelayedCopyableHandler.getDelayedCopy(Copyable)
.
obj
- an object.public static <T> T getDeepCopy(T obj)
T
- copyable typeobj
- The object to get a deep copy of.public static Map<String,Annotation> getFieldsWithAnnotation(Class<?> clazz, Class<? extends Annotation> annotationClass)
clazz
- class to find field annotations forannotationClass
- class for annotation to findpublic static boolean fieldHasAnnotation(Class<?> clazz, String fieldName, Class<? extends Annotation> annotationClass)
clazz
- class containing the field to checkfieldName
- name of the field to checkannotationClass
- class for the annotation to look forpublic static Annotation getFieldAnnotation(Class<?> clazz, String fieldName, Class<? extends Annotation> annotationClass)
clazz
- class containing the field to checkfieldName
- name of the field to checkannotationClass
- class for the annotation to look forCopyright © 2005–2015 The Kuali Foundation. All rights reserved.