mirror of https://github.com/apache/maven.git
[MNG-3400] Implement clone properly following Effective Java' book considerations
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@627932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
17d401df6c
commit
53e9189566
|
@ -80,6 +80,7 @@ import java.util.Stack;
|
||||||
* </ol>
|
* </ol>
|
||||||
*/
|
*/
|
||||||
public class MavenProject
|
public class MavenProject
|
||||||
|
implements Cloneable
|
||||||
{
|
{
|
||||||
public static final String EMPTY_PROJECT_GROUP_ID = "unknown";
|
public static final String EMPTY_PROJECT_GROUP_ID = "unknown";
|
||||||
|
|
||||||
|
@ -169,10 +170,14 @@ public class MavenProject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated use {@link #clone()}
|
* @deprecated use {@link #clone()} so subclasses can provide a copy of the same class
|
||||||
*/
|
*/
|
||||||
public MavenProject( MavenProject project )
|
public MavenProject( MavenProject project )
|
||||||
{
|
{
|
||||||
|
deepCopy( project );
|
||||||
|
}
|
||||||
|
|
||||||
|
private final void deepCopy(MavenProject project){
|
||||||
// disown the parent
|
// disown the parent
|
||||||
|
|
||||||
// copy fields
|
// copy fields
|
||||||
|
@ -1825,11 +1830,15 @@ public class MavenProject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws CloneNotSupportedException
|
||||||
* @since 2.0.9
|
* @since 2.0.9
|
||||||
*/
|
*/
|
||||||
public Object clone()
|
public Object clone()
|
||||||
|
throws CloneNotSupportedException
|
||||||
{
|
{
|
||||||
return new MavenProject( this );
|
MavenProject clone = (MavenProject) super.clone();
|
||||||
|
clone.deepCopy( this );
|
||||||
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue