Javolution 6.0.0 java
javolution.lang.Immutable< T > Interface Template Reference
Inheritance diagram for javolution.lang.Immutable< T >:
[legend]

Public Member Functions

value ()
 

Detailed Description

An object capable of returning a value not subject or susceptible of change or variation. For example,

Immutable<List>>

has a

List

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]

Author
Jean-Marie Dautelle
Version
6.0, July 21, 2013
Parameters
<T>The type of the immutable constant value.
See also
Wikipedia: Immutable Object @see javolution.util.FastCollection::toImmutable

Definition at line 38 of file Immutable.java.

Member Function Documentation

◆ value()

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 >.


The documentation for this interface was generated from the following file: