Type#addMetadata(TypeMetadata). Metadata associated to a type can also be removed,
typically using Type#dropMetadata(Class). To drop all metadata from a given type,
the Type#baseType() method can also be used. This can be useful when comparing two
using reference equality (see also Type#equalsIgnoreMetadata(Type)).
There are no constraints on how a type metadata should be defined. Typically, a type
metadata will be defined as a small record, storing additional information (see ConstantValue).
In other cases, type metadata can be mutable and support complex state transitions
(see Annotations).
The only invariant the implementation requires is that there must be one metadata of a given kind attached to a type, as this makes accessing and dropping metadata simpler. If clients wish to store multiple metadata values that are logically related, they should define a metadata type that collects such values in e.g. a list.
| Modifier and Type | Class and Description |
|---|---|
| public static record | TypeMetadata.
A type metadata object holding type annotations. |
| public static record | TypeMetadata.
A type metadata holding a constant value. |
| Modifier and Type | Field and Description |
|---|---|
| private final ListBuffer | annotationBuffer
Record Component accessed by annotationBuffer(). |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public ListBuffer | |
| pack-priv List | |
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| annotationBuffer | back to summary |
|---|---|
| private final ListBuffer<Attribute. Record Component accessed by annotationBuffer(). | |
| Annotations | back to summary |
|---|---|
| pack-priv Annotations() | |
| Annotations | back to summary |
|---|---|
| pack-priv Annotations(List<Attribute. | |
| Annotations | back to summary |
|---|---|
| public Annotations(ListBuffer<Attribute. | |
| annotationBuffer | back to summary |
|---|---|
| public ListBuffer Record Component getter of annotationBuffer. | |
| annotations | back to summary |
|---|---|
| pack-priv List | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Object |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| public Object |
| value | back to summary |
|---|---|
| private final Object value Record Component accessed by value(). | |
| ConstantValue | back to summary |
|---|---|
| public ConstantValue(Object value) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| value | back to summary |
|---|---|
| public Object value() Record Component getter of value. | |