You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: immutable.md
+8-2
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ layout: page
8
8
9
9
Overview
10
10
--------
11
+
11
12
To reap the benefits of immutability in Java, we created an annotation processor
12
13
to easily create simple and consistent value objects. You can think of it as
13
14
[Guava's Immutable Collections](https://code.google.com/p/guava-libraries/wiki/ImmutableCollectionsExplained) but for regular objects.
@@ -30,12 +31,13 @@ services, and of good design in general. We feel proud to fill a gap in the area
30
31
See [sample generated code](/generated.html) for an example of the code generated by the processor,
31
32
or jump straight to the [features](/immutable.html#features)!
32
33
33
-
--------
34
34
Concepts
35
35
--------
36
36
37
37
<aname="abstract-value"></a>
38
+
38
39
### Abstract value type
40
+
39
41
An Abstract value type is a manually-written non-final (usually abstract) class or
40
42
interface (or even annotation type) that defines the value type and is annotated with the
41
43
`org.immutable.value.Value.Immutable` annotation.
@@ -44,7 +46,9 @@ It is strongly recommended that abstract value types not introduce visible mutab
44
46
Abstract value types are used as the source model for generated code. [Get started!](/getstarted.html).
45
47
46
48
<aname="attributes"></a>
49
+
47
50
### Attributes
51
+
48
52
An attribute holds a value that cannot be changed after the owning object is created.
49
53
The name "attribute" is used to intentionally distinguish the concept from "fields" or JavaBean "properties", and to imply a similarity with Java annotation attributes.
50
54
It is defined by an accessor method: A zero argument, non-`void`-returning Java method.
@@ -54,6 +58,7 @@ are non-`abstract` methods that have bodies that compute values.
54
58
Such accessors therefore require special annotations to distinguish them from regular methods.
55
59
56
60
### Immutable implementation class
61
+
57
62
A [Generated](/generated.html)`final` class that extends a manually-written [abstract value type](#abstract-value)
58
63
and implements all declared accessor methods as well as supporting fields, methods, constructors, and a builder class.
59
64
An immutable implementation class implements abstract attribute accessors
@@ -65,11 +70,12 @@ Immutable implementation classes are the primary (but not the only) source code
65
70
generated by the _Immutables_ annotation processor.
66
71
67
72
<aname="features"></a>
68
-
--------
73
+
69
74
Features
70
75
--------
71
76
72
77
### Value
78
+
73
79
The annotation processor works by using annotated abstract value types as a model to generate immutable implementations.
74
80
A generated implementation extends or implements an abstract value type. Classes don't have to be abstract if they don't define abstract accessor methods.
0 commit comments