Coverage Report - org.geotoolkit.util.Cloneable
 
Classes in this File Line Coverage Branch Coverage Complexity
Cloneable
N/A
N/A
1
 
 1  
 /*
 2  
  *    Geotoolkit.org - An Open Source Java GIS Toolkit
 3  
  *    http://www.geotoolkit.org
 4  
  *
 5  
  *    (C) 2009-2012, Open Source Geospatial Foundation (OSGeo)
 6  
  *    (C) 2009-2012, Geomatys
 7  
  *
 8  
  *    This library is free software; you can redistribute it and/or
 9  
  *    modify it under the terms of the GNU Lesser General Public
 10  
  *    License as published by the Free Software Foundation;
 11  
  *    version 2.1 of the License.
 12  
  *
 13  
  *    This library is distributed in the hope that it will be useful,
 14  
  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 15  
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16  
  *    Lesser General Public License for more details.
 17  
  */
 18  
 package org.geotoolkit.util;
 19  
 
 20  
 
 21  
 /**
 22  
  * Indicates that it is legal to make a field-for-field copy of instances of implementing classes.
 23  
  * A cloneable class implements the J2SE's {@link java.lang.Cloneable} standard interface and
 24  
  * additionally overrides the {@link Object#clone()} method with public access.
 25  
  * <p>
 26  
  * Because the {@link Object#clone()} method has protected access, containers wanting to clone
 27  
  * theirs elements need to 1) use Java reflection (which is less efficient than standard method
 28  
  * calls), or 2) cast every elements to a specific type like {@link java.util.Date} (which may
 29  
  * require a large amount of "{@code if (x instanceof y)}" checks if arbitrary classes are
 30  
  * allowed). This {@code Cloneable} interface had a third alternative: checks only for this
 31  
  * interface instead of a list of particular cases.
 32  
  * <p>
 33  
  * Implementors of cloneable classes may consider implementing this interface, but this is not
 34  
  * mandatory. A large amount of independent classes like {@link java.util.Date} will continue to
 35  
  * ignore this interface, so no rule can be enforced anyway. However this interface may help the
 36  
  * work of containers in some case. For example a container may checks for this interface first,
 37  
  * and uses Java reflection as a fallback.
 38  
  *
 39  
  * @author Martin Desruisseaux (IRD)
 40  
  * @version 3.01
 41  
  *
 42  
  * @see java.lang.Cloneable
 43  
  * @see <A HREF="http://developer.java.sun.com/developer/bugParade/bugs/4098033.html">&quot;<cite>Cloneable
 44  
  *      doesn't define <code>clone()</code></cite>&quot; on Sun's bug parade</A>
 45  
  *
 46  
  * @since 3.01 (derived from GeoAPI 1.0)
 47  
  * @module
 48  
  */
 49  
 public interface Cloneable extends java.lang.Cloneable {
 50  
     /**
 51  
      * Creates and returns a copy of this object.
 52  
      * The precise meaning of "copy" may depend on the class of the object.
 53  
      *
 54  
      * @return A copy of this object.
 55  
      *
 56  
      * @see Object#clone
 57  
      */
 58  
     Object clone();
 59  
 }