make SerializationUtils.clone() type-safe
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@989199 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
52bea417c5
commit
c3e3feeaa1
|
@ -77,8 +77,9 @@ public class SerializationUtils {
|
|||
* @return the cloned object
|
||||
* @throws SerializationException (runtime) if the serialization fails
|
||||
*/
|
||||
public static Object clone(Serializable object) {
|
||||
return deserialize(serialize(object));
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Serializable> T clone(T object) {
|
||||
return (T) deserialize(serialize(object));
|
||||
}
|
||||
|
||||
// Serialize
|
||||
|
|
|
@ -340,7 +340,7 @@ public class SerializationUtilsTest extends TestCase {
|
|||
//-----------------------------------------------------------------------
|
||||
|
||||
public void testClone() throws Exception {
|
||||
Object test = SerializationUtils.clone(iMap);
|
||||
HashMap<?, ?> test = SerializationUtils.clone(iMap);
|
||||
assertNotNull(test);
|
||||
assertTrue(test instanceof HashMap<?,?>);
|
||||
assertTrue(test != iMap);
|
||||
|
|
Loading…
Reference in New Issue