Revision 2489
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/lang/Cloneable.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* gvSIG. Desktop Geographic Information System. |
3 | 3 |
* |
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
|
4 |
* Copyright (C) 2007-2021 gvSIG Association.
|
|
5 | 5 |
* |
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
... | ... | |
26 | 26 |
/** |
27 | 27 |
* {@link java.lang.Cloneable} extension to define the |
28 | 28 |
* {@link java.lang.Cloneable#clone()} as a public method. |
29 |
*
|
|
30 |
* @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
|
|
29 |
* |
|
30 |
* @author gvSIG Team
|
|
31 | 31 |
*/ |
32 | 32 |
public interface Cloneable extends java.lang.Cloneable { |
33 | 33 |
|
34 |
/** |
|
35 |
* Creates a copy of the object. |
|
36 |
* |
|
37 |
* @see {@link Object#clone()}. |
|
38 |
* |
|
39 |
* @return a copy of the object |
|
40 |
* @throws CloneNotSupportedException if the instance of the object cannot |
|
41 |
* be cloned. As this is extending {@link java.lang.Cloneable} so |
|
42 |
* its sure it implements it, so this exception may be used for problems |
|
43 |
* on specific object instances. |
|
44 |
*/ |
|
45 |
Object clone() throws CloneNotSupportedException; |
|
34 |
public static Object cloneQuietly(Object x) { |
|
35 |
if (x instanceof Cloneable) { |
|
36 |
try { |
|
37 |
return ((Cloneable)x).clone(); |
|
38 |
} catch (CloneNotSupportedException ex) { |
|
39 |
return null; |
|
40 |
} |
|
41 |
} |
|
42 |
return null; |
|
43 |
} |
|
46 | 44 |
|
47 |
} |
|
45 |
public static Object cloneQuietly(Cloneable x) { |
|
46 |
if (x == null) { |
|
47 |
return null; |
|
48 |
} |
|
49 |
try { |
|
50 |
return x.clone(); |
|
51 |
} catch (CloneNotSupportedException ex) { |
|
52 |
return null; |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* Creates a copy of the object. |
|
58 |
* |
|
59 |
* @see {@link Object#clone()}. |
|
60 |
* |
|
61 |
* @return a copy of the object |
|
62 |
* @throws CloneNotSupportedException if the instance of the object cannot |
|
63 |
* be cloned. As this is extending {@link java.lang.Cloneable} so its sure |
|
64 |
* it implements it, so this exception may be used for problems on specific |
|
65 |
* object instances. |
|
66 |
*/ |
|
67 |
public Object clone() throws CloneNotSupportedException; |
|
68 |
|
|
69 |
} |
Also available in: Unified diff