explain why it is safe to suppress the cast warning on SerializationUtils.clone()
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@989390 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
782e48d8e0
commit
ed894291a7
|
@ -77,9 +77,15 @@ public class SerializationUtils {
|
|||
* @return the cloned object
|
||||
* @throws SerializationException (runtime) if the serialization fails
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Serializable> T clone(T object) {
|
||||
return (T) deserialize(serialize(object));
|
||||
/*
|
||||
* when we serialize and deserialize an object,
|
||||
* it is reasonable to assume the deserialized object
|
||||
* is of the same type as the original serialized object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
final T result = (T) deserialize(serialize(object));
|
||||
return result;
|
||||
}
|
||||
|
||||
// Serialize
|
||||
|
|
Loading…
Reference in New Issue