@SuppressWarnings("unchecked")
	public static <V extends Serializable> V deepClone(V v){
    	if (v == null){
    		return null;
    	}
    	ObjectInputStream is =null; 
    	ByteArrayOutputStream baos = new ByteArrayOutputStream();
		try {
			ObjectOutputStream os = new ObjectOutputStream(baos);
			os.writeObject(v);
			is = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
			return (V)is.readObject();
		} catch (Exception e) {
			if (is != null){
				try {
					is.close();
				} catch (IOException e1) {
					throw new RuntimeException(e1);
				}
			}
		}
		return v;
    }
@ SuppressWarnings ( "unchecked" ) public static < V extends Serializable > V deepClone ( V v ) { if ( v == null ) { return null ; } ObjectInputStream is = null ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; try { ObjectOutputStream os = new ObjectOutputStream ( baos ) ; os . writeObject ( v ) ; is = new ObjectInputStream ( new ByteArrayInputStream ( baos . toByteArray ( ) ) ) ; return ( V ) is . readObject ( ) ; } catch ( Exception e ) { if ( is != null ) { try { is . close ( ) ; } catch ( IOException e1 ) { throw new RuntimeException ( e1 ) ; } } } return v ; }
Creates a deep clone of the object passed by serializing and deserializing it.
@param v Object to clone.
@return A deep clone of v on successful serializing and deserializing of v. On encounting any Serialization exception, v is return unmodified.