01: /*
02: * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
03: * Copyright (C) 2005 - Javolution (http://javolution.org/)
04: * All rights reserved.
05: *
06: * Permission to use, copy, modify, and distribute this software is
07: * freely granted, provided that this notice is preserved.
08: */
09: 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: // No method (tagging interface).
36:
37: }
|