Javolution 6.0.0 java
|
Public Member Functions | |
T | value () |
An object capable of returning a value not subject or susceptible of change or variation. For example,
has a
value which is guaranteed to be constant (not modifiable by anybody). Classes implementing this interface do not need themselves to be unmodifiable. If the value and the class are the same, the ValueType sub-interface can be implemented.
[code] class Polygon extends Shape implements ValueType<Shape> { // extends Immutable<Shape> private List<Point2D> vertices; public Polygon(Immutable<List<Point2D>> vertices) { // Immutable<List> has a constant List value. this.vertices = vertices.value(); // No defensive copying required (vertices.value() is certified constant). } public Polygon value() { return this; } // As per ValueType contract. }[/code]
FastCollection/FastMap have direct support for immutable. [code] Polygon triangle = new Polygon(new FastTable<Point2D>().addAll(p1, p2, p3).toImmutable());[/code]
<T> | The type of the immutable constant value. |
Definition at line 38 of file Immutable.java.
T javolution.lang.Immutable< T >.value | ( | ) |
Returns the constant value held by this object.
Implemented in javolution.text.Text, javolution.text.CharSet, javolution.util.Index, javolution.xml.QName, and javolution.lang.ValueType< T >.