Package adams.core
Class ObjectCopyHelper
- java.lang.Object
-
- adams.core.ObjectCopyHelper
-
public class ObjectCopyHelper extends Object
Helper class for copying objects.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classObjectCopyHelper.CopyTypeHow to copy an object.
-
Constructor Summary
Constructors Constructor Description ObjectCopyHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TcopyObject(ObjectCopyHelper.CopyType type, T source)Makes a copy of an object.static <T> TcopyObject(T source)Makes a copy of an object.static <T> T[]copyObjects(ObjectCopyHelper.CopyType type, T[] source)Makes a copy of the objects.static <T> T[]copyObjects(T[] source)Makes a copy of the objects.static ObjectCopyHelper.CopyTypecopyType(Object source)Determines how to copy an object.protected static <T> TcreateCopy(ObjectCopyHelper.CopyType type, T source)Makes a copy of the object.static ObjectnewInstance(Class cls)Creates a new instance of the given class.static ObjectnewInstance(String cls)Creates a new instance of the given class.
-
-
-
Field Detail
-
LOGGER
protected static Logger LOGGER
for logging.
-
-
Method Detail
-
copyType
public static ObjectCopyHelper.CopyType copyType(Object source)
Determines how to copy an object.- Parameters:
source- the object to inspect, cannot be null- Returns:
- the copy type
-
copyObject
public static <T> T copyObject(T source)
Makes a copy of an object.- Parameters:
source- the object to copy- Returns:
- a copy of the source object
- See Also:
copyObjects(CopyType, Object[])
-
copyObject
public static <T> T copyObject(ObjectCopyHelper.CopyType type, T source)
Makes a copy of an object.- Parameters:
type- the copy type to use, null to automatically determinesource- the object to copy- Returns:
- a copy of the source object
- See Also:
copyObjects(CopyType, Object[])
-
copyObjects
public static <T> T[] copyObjects(T[] source)
Makes a copy of the objects.- Parameters:
source- the objects to copy- Returns:
- a copy of the source objects
- See Also:
copyObjects(CopyType, Object[])
-
copyObjects
public static <T> T[] copyObjects(ObjectCopyHelper.CopyType type, T[] source)
Makes a copy of the objects.- Parameters:
type- the copy type to use, null to automatically determinesource- the objects to copy- Returns:
- a copy of the source objects
- See Also:
OptionUtils.shallowCopy(adams.core.option.OptionHandler, boolean),CloneHandler.getClone(),ClassManager.deepCopy(Object),ObjectCopyHelper.CopyType
-
createCopy
protected static <T> T createCopy(ObjectCopyHelper.CopyType type, T source)
Makes a copy of the object.- Parameters:
type- the copy type to use, null to automatically determinesource- the object to copy- Returns:
- a copy of the source object
- See Also:
OptionUtils.shallowCopy(adams.core.option.OptionHandler, boolean),CloneHandler.getClone(),ClassManager.deepCopy(Object),ObjectCopyHelper.CopyType
-
newInstance
public static Object newInstance(String cls) throws Exception
Creates a new instance of the given class.- Parameters:
cls- the class to create an instance from- Returns:
- the object, null if failed
- Throws:
Exception- if instantiation fails
-
-