Java Object Clone cloneCloneNotSupportedObject(final T obj, final boolean deep)

Here you can find the source of cloneCloneNotSupportedObject(final T obj, final boolean deep)

Description

clone Clone Not Supported Object

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
    protected static <T> T cloneCloneNotSupportedObject(final T obj, final boolean deep) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    @SuppressWarnings("unchecked")
    protected static <T> T cloneCloneNotSupportedObject(final T obj, final boolean deep) {
        if (obj instanceof String) {
            return obj;
        } else if (obj instanceof Byte) {
            return (T) new Byte((Byte) obj);
        } else if (obj instanceof Short) {
            return (T) new Short((Short) obj);
        } else if (obj instanceof Integer) {
            return (T) new Integer((Integer) obj);
        } else if (obj instanceof Long) {
            return (T) new Long((Long) obj);
        } else if (obj instanceof Float) {
            return (T) new Float((Float) obj);
        } else if (obj instanceof Double) {
            return (T) new Double((Double) obj);
        } else if (obj instanceof Boolean) {
            return (T) new Boolean((Boolean) obj);
        } else if (obj instanceof Character) {
            return (T) new Character((Character) obj);
        }/*from w  w w  .  java  2 s.com*/
        return null;
    }
}

Related

  1. clone(Object value)
  2. clone(String name, String type, int pos)
  3. clone(T array)
  4. clone_obj_array(Object source)
  5. cloneClass(Class clazz)
  6. cloneShort(Short sOriginal)
  7. cloneStackTrace(Throwable aException)
  8. copyIfNecessary(final Object val)