@Immutable public abstract class Attributes extends Object implements ReadableAttributes
The keys are AttributeKeys and the values are Object instances that match the type of
the provided key.
Null keys will be silently dropped.
Note: The behavior of null-valued attributes is undefined, and hence strongly discouraged.
| Modifier and Type | Class and Description |
|---|---|
static class |
Attributes.Builder
Enables the creation of an
Attributes instance with an arbitrary number of key-value
pairs. |
| Constructor and Description |
|---|
Attributes() |
| Modifier and Type | Method and Description |
|---|---|
static Attributes |
empty()
Returns a
Attributes instance with no attributes. |
void |
forEach(AttributeConsumer consumer)
Iterates over all the key-value pairs of attributes contained by this instance.
|
<T> T |
get(AttributeKey<T> key) |
V |
get(K key) |
boolean |
isEmpty() |
static Attributes.Builder |
newBuilder()
Returns a new
Attributes.Builder instance for creating arbitrary Attributes. |
static Attributes.Builder |
newBuilder(ReadableAttributes attributes)
Returns a new
Attributes.Builder instance from ReadableAttributes. |
static <T> Attributes |
of(AttributeKey<T> key,
T value)
Returns a
Attributes instance with a single key-value pair. |
static <T,U> Attributes |
of(AttributeKey<T> key1,
T value1,
AttributeKey<U> key2,
U value2)
Returns a
Attributes instance with two key-value pairs. |
static <T,U,V> Attributes |
of(AttributeKey<T> key1,
T value1,
AttributeKey<U> key2,
U value2,
AttributeKey<V> key3,
V value3)
Returns a
Attributes instance with three key-value pairs. |
static <T,U,V,W> Attributes |
of(AttributeKey<T> key1,
T value1,
AttributeKey<U> key2,
U value2,
AttributeKey<V> key3,
V value3,
AttributeKey<W> key4,
W value4)
Returns a
Attributes instance with four key-value pairs. |
static <T,U,V,W,X> |
of(AttributeKey<T> key1,
T value1,
AttributeKey<U> key2,
U value2,
AttributeKey<V> key3,
V value3,
AttributeKey<W> key4,
W value4,
AttributeKey<X> key5,
X value5)
Returns a
Attributes instance with five key-value pairs. |
static <T,U,V,W,X,Y> |
of(AttributeKey<T> key1,
T value1,
AttributeKey<U> key2,
U value2,
AttributeKey<V> key3,
V value3,
AttributeKey<W> key4,
W value4,
AttributeKey<X> key5,
X value5,
AttributeKey<Y> key6,
Y value6)
Returns a
Attributes instance with the given key-value pairs. |
int |
size() |
abstract Attributes.Builder |
toBuilder()
Returns a new
Attributes.Builder instance populated with the data of this Attributes. |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisEmpty, sizepublic <T> T get(AttributeKey<T> key)
get in interface ReadableAttributespublic void forEach(AttributeConsumer consumer)
ReadableAttributesforEach in interface ReadableAttributespublic static Attributes empty()
Attributes instance with no attributes.public static <T> Attributes of(AttributeKey<T> key, T value)
Attributes instance with a single key-value pair.public static <T,U> Attributes of(AttributeKey<T> key1, T value1, AttributeKey<U> key2, U value2)
Attributes instance with two key-value pairs. Order of the keys is not
preserved. Duplicate keys will be removed.public static <T,U,V> Attributes of(AttributeKey<T> key1, T value1, AttributeKey<U> key2, U value2, AttributeKey<V> key3, V value3)
Attributes instance with three key-value pairs. Order of the keys is not
preserved. Duplicate keys will be removed.public static <T,U,V,W> Attributes of(AttributeKey<T> key1, T value1, AttributeKey<U> key2, U value2, AttributeKey<V> key3, V value3, AttributeKey<W> key4, W value4)
Attributes instance with four key-value pairs. Order of the keys is not
preserved. Duplicate keys will be removed.public static <T,U,V,W,X> Attributes of(AttributeKey<T> key1, T value1, AttributeKey<U> key2, U value2, AttributeKey<V> key3, V value3, AttributeKey<W> key4, W value4, AttributeKey<X> key5, X value5)
Attributes instance with five key-value pairs. Order of the keys is not
preserved. Duplicate keys will be removed.public static <T,U,V,W,X,Y> Attributes of(AttributeKey<T> key1, T value1, AttributeKey<U> key2, U value2, AttributeKey<V> key3, V value3, AttributeKey<W> key4, W value4, AttributeKey<X> key5, X value5, AttributeKey<Y> key6, Y value6)
Attributes instance with the given key-value pairs. Order of the keys is not
preserved. Duplicate keys will be removed.public static Attributes.Builder newBuilder()
Attributes.Builder instance for creating arbitrary Attributes.public static Attributes.Builder newBuilder(ReadableAttributes attributes)
Attributes.Builder instance from ReadableAttributes.public abstract Attributes.Builder toBuilder()
Attributes.Builder instance populated with the data of this Attributes.public int size()
public boolean isEmpty()
@Nullable public V get(K key)