Skip to content

Commit

Permalink
Make it easier to override clone in subclasses
Browse files Browse the repository at this point in the history
created the cloned object using the class of the sourced object to allow
classes that extend RegisteredServiceImpl to only need to track their
own attributes in the clone method
  • Loading branch information
frett committed Oct 12, 2011
1 parent ac80309 commit df298d8
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ public int getEvaluationOrder() {
}

public Object clone() throws CloneNotSupportedException {
final RegisteredServiceImpl registeredServiceImpl = new RegisteredServiceImpl();
final RegisteredServiceImpl registeredServiceImpl;
try {
registeredServiceImpl = this.getClass().newInstance();
} catch (final Exception e) {
throw new CloneNotSupportedException("error creating new object");
}

registeredServiceImpl.setAllowedAttributes(this.allowedAttributes);
registeredServiceImpl.setAllowedToProxy(this.allowedToProxy);
Expand Down

0 comments on commit df298d8

Please sign in to comment.