Mercurial Hosting > luan
comparison src/luan/DeepCloner.java @ 126:0149bdf98fd8
add ThreadLib
git-svn-id: https://luan-java.googlecode.com/svn/trunk@127 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 06 Jun 2014 14:16:38 +0000 |
parents | 7c08b611125d |
children |
comparison
equal
deleted
inserted
replaced
125:0cd559a16758 | 126:0149bdf98fd8 |
---|---|
26 if( rtn == null ) { | 26 if( rtn == null ) { |
27 rtn = obj.clone(); | 27 rtn = obj.clone(); |
28 cloned.put(obj,rtn); | 28 cloned.put(obj,rtn); |
29 for( int i=0; i<rtn.length; i++ ) { | 29 for( int i=0; i<rtn.length; i++ ) { |
30 @SuppressWarnings("unchecked") | 30 @SuppressWarnings("unchecked") |
31 T t = (T)get(rtn[i]); | 31 T t = get(rtn[i]); |
32 rtn[i] = t; | 32 rtn[i] = t; |
33 } | 33 } |
34 } | 34 } |
35 return rtn; | 35 return rtn; |
36 } | 36 } |
37 | 37 |
38 public Object get(Object obj) { | 38 public <T> T get(T obj) { |
39 if( !(obj instanceof DeepCloneable) ) | 39 if( !(obj instanceof DeepCloneable) ) |
40 return obj; | 40 return obj; |
41 @SuppressWarnings("unchecked") | 41 @SuppressWarnings("unchecked") |
42 DeepCloneable dc = deepClone((DeepCloneable)obj); | 42 T dc = (T)deepClone((DeepCloneable)obj); |
43 return dc; | 43 return dc; |
44 } | 44 } |
45 } | 45 } |