public final class CopyObjectExtensions extends Object
CopyObjectExtensions provide methods for copy an original object to a given
destination object.| Constructor and Description |
|---|
CopyObjectExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static <ORIGINAL,DESTINATION> |
copy(ORIGINAL original,
DESTINATION destination)
A delegate method to
copyProperties(Object, Object) for copy the
given original object to the given destination object. |
static <ORIGINAL,DESTINATION> |
copyField(@NonNull Field field,
ORIGINAL original,
DESTINATION destination)
Copy the given original object to the given destination object.
|
static <ORIGINAL,DESTINATION> |
copyObject(ORIGINAL original,
DESTINATION destination)
Copy the given original object to the given destination object.
|
static <ORIGINAL,DESTINATION> |
copyObject(ORIGINAL original,
DESTINATION destination,
String... ignoreFields)
Copy the given original object to the given destination object.
|
static <T> T |
copyObject(T original)
Copy the given original object.
|
static <ORIGINAL,DESTINATION> |
copyProperties(ORIGINAL original,
DESTINATION destination)
Copy the given original object to the given destination object.
|
static <T> T |
copyProperties(T original)
Copy the given object and return a copy of it.
|
static <ORIGINAL,DESTINATION> |
copyPropertyWithReflection(ORIGINAL original,
DESTINATION destination,
String fieldName)
Copy the given original object to the given destination object.
|
static <T extends Serializable> |
copySerializedObject(T orig)
Copys the given Object and returns the copy from the object or null if the object can't be
serialized.
|
public static <T> T copyObject(@NonNull
T original)
throws IllegalAccessException,
InstantiationException,
ClassNotFoundException
T - the generic type of the given objectoriginal - the original objectIllegalAccessException - if the caller does not have access to the property accessor methodInstantiationException - Thrown if one of the following reasons: the class object
voidClassNotFoundException - is thrown if the class cannot be locatedpublic static <ORIGINAL,DESTINATION> DESTINATION copyObject(@NonNull
ORIGINAL original,
@NonNull
DESTINATION destination)
throws IllegalAccessException,
InstantiationException,
ClassNotFoundException
ORIGINAL - the generic type of the original object.DESTINATION - the generic type of the destination object.original - the original object.destination - the destination object.IllegalAccessException - if the caller does not have access to the property accessor methodInstantiationException - Thrown if one of the following reasons: the class object
voidClassNotFoundException - is thrown if the class cannot be locatedpublic static <ORIGINAL,DESTINATION> DESTINATION copyObject(@NonNull
ORIGINAL original,
@NonNull
DESTINATION destination,
String... ignoreFields)
throws IllegalAccessException,
InstantiationException,
ClassNotFoundException
ORIGINAL - the generic type of the original object.DESTINATION - the generic type of the destination object.original - the original object.destination - the destination object.ignoreFields - optional field names to ignoreIllegalAccessException - if the caller does not have access to the property accessor methodInstantiationException - Thrown if one of the following reasons: the class object
voidClassNotFoundException - is thrown if the class cannot be locatedpublic static <ORIGINAL,DESTINATION> boolean copyField(@NonNull
@NonNull Field field,
@NonNull
ORIGINAL original,
@NonNull
DESTINATION destination)
throws IllegalAccessException,
InstantiationException,
ClassNotFoundException
ORIGINAL - the generic type of the original object.DESTINATION - the generic type of the destination object.field - the fieldoriginal - the original object.destination - the destination object.IllegalAccessException - if the caller does not have access to the property accessor methodInstantiationException - Thrown if one of the following reasons: the class object
voidClassNotFoundException - is thrown if the class cannot be locatedpublic static <ORIGINAL,DESTINATION> DESTINATION copyPropertyWithReflection(ORIGINAL original,
DESTINATION destination,
String fieldName)
throws NoSuchFieldException,
SecurityException,
IllegalAccessException
ORIGINAL - the generic type of the original object.DESTINATION - the generic type of the destination object.original - the original object.destination - the destination object.fieldName - the field nameNoSuchFieldException - is thrown if no such field exists.SecurityException - is thrown if a security manager says no.IllegalAccessException - if the caller does not have access to the property accessor methodpublic static <ORIGINAL,DESTINATION> DESTINATION copy(ORIGINAL original,
DESTINATION destination)
throws IllegalAccessException,
InvocationTargetException,
IllegalArgumentException
copyProperties(Object, Object) for copy the
given original object to the given destination object.DESTINATION - the generic type of the destination object.ORIGINAL - the generic type of the original object.original - the original object.destination - the destination object.IllegalAccessException - if the caller does not have access to the property accessor methodInvocationTargetException - if the property accessor method throws an exceptionIllegalArgumentExceptionpublic static <ORIGINAL,DESTINATION> DESTINATION copyProperties(ORIGINAL original,
DESTINATION destination)
throws IllegalAccessException,
InvocationTargetException
BeanUtils.copyProperties(Object, Object)DESTINATION - the generic type of the destination object.ORIGINAL - the generic type of the original object.original - the original object.destination - the destination object.IllegalAccessException - if the caller does not have access to the property accessor methodInvocationTargetException - if the property accessor method throws an exceptionpublic static <T> T copyProperties(T original)
throws IllegalAccessException,
InvocationTargetException,
InstantiationException
BeanUtils.copyProperties(Object, Object) and create a new object for the returned
object.T - the generic type of the given object.original - the original object.IllegalAccessException - if the caller does not have access to the property accessor methodInvocationTargetException - if the property accessor method throws an exceptionInstantiationException - Thrown if one of the following reasons: the class object
voidpublic static <T extends Serializable> T copySerializedObject(T orig) throws IOException, ClassNotFoundException
T - the generic type of the given objectorig - The object to copy.IOException - Signals that an I/O exception has occurred.ClassNotFoundException - is thrown when a class is not found in the classloader or no definition for the
class with the specified name could be found.Copyright © 2015–2019 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.