Java Utililty Methods Object Clone

List of utility methods to do Object Clone

Description

The list of methods to do Object Clone are organized into topic(s).

Method

StackTraceElement[]cloneStackTrace(Throwable aException)
clone Stack Trace
StackTraceElement[] stack = aException.getStackTrace();
StackTraceElement[] newStack = new StackTraceElement[stack.length];
for (int i = 0; i < newStack.length; i++) {
    StackTraceElement element = stack[i];
    newStack[i] = new StackTraceElement(element.getClassName(), element.getMethodName(),
            element.getFileName(), element.getLineNumber());
return newStack;
...
ObjectcopyIfNecessary(final Object val)
copy If Necessary
if (val instanceof Map) {
    return deepCopy((Map<String, ?>) val);
} else if (val instanceof List) {
    return deepCopy((List<?>) val);
} else {
    return val;