MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / cloneArrayList

Method cloneArrayList

ij/src/main/java/ij/gui/Plot.java:4940–4952  ·  view source on GitHub ↗

A clone of an array list one level deeper than a shallow clone. The clone() method of the objects in the list must be accessible

(ArrayList src)

Source from the content-addressed store, hash-verified

4938 /** A clone of an array list one level deeper than a shallow clone.
4939 * The clone() method of the objects in the list must be accessible */
4940 private ArrayList cloneArrayList(ArrayList src) {
4941 ArrayList dest = (ArrayList)(src.clone()); //shallow clone
4942 Class[] noClasses = new Class[0];
4943 Object[] noObjects = new Object[0];
4944 for (int i=0; i<dest.size(); i++) {
4945 Object o = dest.get(i);
4946 if (o != null) try {
4947 Method cloneMethod = o.getClass().getMethod("clone", noClasses);
4948 dest.set(i, cloneMethod.invoke(o, noObjects));
4949 } catch (Exception e) {}
4950 }
4951 return dest;
4952 }
4953
4954 /** Converts old (pre-1.52i) type codes for the PlotObjects to the new ones, which can be used as masks */
4955 void updateType() {

Callers 1

deepCloneMethod · 0.95

Calls 6

getMethodMethod · 0.80
invokeMethod · 0.80
cloneMethod · 0.65
sizeMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected