...
The clone()
method returns a copy of the original object that reflects the state of the original object at the moment of cloning. This new object can be used without exposing the original object. Because the caller holds the only reference to the newly cloned instance, the instance fields cannot be changed without the caller's cooperation. This use of the clone()
method allows the class to remain securely mutable. (See rule "OBJ08OBJ04-J. Provide mutable classes with copy functionality to allow passing instances to untrusted code safely.")
The Point
class is declared final
to prevent subclasses from overriding the clone()
method. This enables the class to be suitably used without any inadvertent modifications of the original object. This solution also complies with rule "OBJ08OBJ04-J. Provide mutable classes with copy functionality to allow passing instances to untrusted code safely."
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="725949a421fdbf60-8d7dcd96-4a754310-b8fb92c6-b5142614aef11700c28fd7ac"><ac:plain-text-body><![CDATA[ | [[Bloch 2008 | AA. Bibliography#Bloch 08]] | Item 13: Minimize the accessibility of classes and members | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="112b626e4eb500d6-3f175af8-44ec4d49-bed391c3-3018ec54d7366f915d6ee4eb"><ac:plain-text-body><![CDATA[ | [[Core Java 2004 | AA. Bibliography#Core Java 04]] | Chapter 6 | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8b7010e479cb7300-f02f7cd1-40d74c3f-925fb312-74e3573ad2e9c065b7f3d324"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§4.12.4 "final Variables" | http://java.sun.com/docs/books /jls/third_edition/html/typesValues.html#4.12.4] ]]></ac:plain-text-body></ac:structured-macro> |
| ||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6a0e2e7b12d8d8c0-f1363a4c-4bbd42ca-bf61860d-3a2170dad530f794aee943d9"><ac:plain-text-body><![CDATA[ | [[Mettler 2010B | AA. Bibliography#Mettler 2010B]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
...