|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
T - The type of the implementing object. For example, if String implemented this interface it would do so as Copyable<String>.public interface Copyable<T>
This interface is designed to be a replacement for Cloneable and
should rectify the problems that exist with it.
The following problems exist with Cloneable:
Object.clone() method is public,
so you can't clone instances of Cloneable without knowing
the concrete class type.
Object are hard to clone properly
if the intervening (grand)children do not implement Cloneable (and actually publicise Object.clone()).
Object.clone() predates generics, so it returns an Object rather than the correct type. Coupled with the fact that
casting a generified collection from Object is nigh-on impossible to
do correctly, this makes cloning collection classes hard.
| Method Summary | |
|---|---|
T |
getCopy()
Creates a deep copy of the current object and returns it. |
| Method Detail |
|---|
T getCopy()
throws CopyException
CopyException - if the copying encountered an exception.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||