KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javolution > lang > Immutable


1 /*
2  * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
3  * Copyright (C) 2005 - Javolution (http://javolution.org/)
4  * All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software is
7  * freely granted, provided that this notice is preserved.
8  */

9 package javolution.lang;
10
11 /**
12  * <p> This interface identifies classes whose instances are not subject or
13  * susceptible to change or variation after creation. Once a class is
14  * declared immutable, any subclass must ensure immutability as well.</p>
15  *
16  * <p> {@link Immutable} objects can safely be used in a multi-threaded
17  * environment and <b>do not require defensive copying</b>.
18  * For example:[code]
19  * class Polygon implements Immutable {
20  * private List<Point2D> _vertices;
21  * public Polygon(List<Point2D> vertices) {
22  * _vertices = (vertices instanceof Immutable) ?
23  * vertices : // Safe, the vertices cannot be modified by the client.
24  * new FastTable<Point2D>(vertices); // Defensive copying required.
25  * }
26  * }[/code]</p>
27  * @see <a HREF="http://en.wikipedia.org/wiki/Immutable_object">
28  * Wikipedia: Immutable Object<a>
29  *
30  * @author <a HREF="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
31  * @version 3.7, February 6, 2006
32  */

33 public interface Immutable {
34
35    // Tagging interface, no method.
36

37 }
Popular Tags