java.lang.Object
org.glassfish.grizzly.attributes.Attribute<T>
- Type Parameters:
T-
Class used to define dynamic typed attributes on
AttributeHolder instances. Storing attribute values in
AttributeHolder has two advantage comparing to Map storage: 1) Attribute value is typed, and could
be checked at compile time. 2) Access to Attribute value, if used with IndexedAttributeHolder, could
be as fast as access to array.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAttribute(AttributeBuilder builder, String name, int index, Supplier<T> initializer) protectedAttribute(AttributeBuilder builder, String name, int index, T defaultValue) -
Method Summary
Modifier and TypeMethodDescriptionget(AttributeHolder attributeHolder) Get attribute value, stored on theAttributeHolder.get(AttributeStorage storage) Get attribute value, stored on theAttributeStorage.intindex()Return attribute name, which is used as attribute key on indexedAttributeHolders.booleanisSet(AttributeHolder attributeHolder) Checks if this attribute is set on theAttributeHolder.booleanisSet(AttributeStorage storage) Checks if this attribute is set on theAttributeStorage.name()Return attribute name, which is used as attribute key on non-indexedAttributeHolders.peek(AttributeHolder attributeHolder) Get attribute value, stored on theAttributeHolder, the difference fromget(org.glassfish.grizzly.attributes.AttributeHolder)is that default value orSupplierwon't be invoked.peek(AttributeStorage storage) Get attribute value, stored on theAttributeStorage, the difference fromget(AttributeStorage)is that default value orSupplierwon't be invoked.remove(AttributeHolder attributeHolder) Remove attribute value, stored on theAttributeHolder.remove(AttributeStorage storage) Remove attribute value, stored on theAttributeStorage.voidset(AttributeHolder attributeHolder, T value) Set attribute value, stored on theAttributeHolder.voidset(AttributeStorage storage, T value) Set attribute value, stored on theAttributeStorage.toString()
-
Constructor Details
-
Attribute
-
Attribute
-
-
Method Details
-
toString
-
peek
Get attribute value, stored on theAttributeHolder, the difference fromget(org.glassfish.grizzly.attributes.AttributeHolder)is that default value orSupplierwon't be invoked.- Parameters:
attributeHolder-AttributeHolder.- Returns:
- attribute value
-
peek
Get attribute value, stored on theAttributeStorage, the difference fromget(AttributeStorage)is that default value orSupplierwon't be invoked.- Parameters:
storage-AttributeStorage.- Returns:
- attribute value
-
get
Get attribute value, stored on theAttributeHolder.- Parameters:
attributeHolder-AttributeHolder.- Returns:
- attribute value
-
get
Get attribute value, stored on theAttributeStorage.- Parameters:
storage-AttributeStorage.- Returns:
- attribute value
-
set
Set attribute value, stored on theAttributeHolder.- Parameters:
attributeHolder-AttributeHolder.value- attribute value to set.
-
set
Set attribute value, stored on theAttributeStorage.- Parameters:
storage-AttributeStorage.value- attribute value to set.
-
remove
Remove attribute value, stored on theAttributeHolder.- Parameters:
attributeHolder-AttributeHolder.- Returns:
- the previous value associated with the attribute
-
remove
Remove attribute value, stored on theAttributeStorage.- Parameters:
storage-AttributeStorage.
-
isSet
Checks if this attribute is set on theAttributeHolder. Returns true, if attribute is set, of false otherwise.- Parameters:
attributeHolder-AttributeHolder.- Returns:
- true, if attribute is set, of false otherwise.
-
isSet
Checks if this attribute is set on theAttributeStorage. Returns true, if attribute is set, of false otherwise.- Parameters:
storage-AttributeStorage.- Returns:
- true, if attribute is set, of false otherwise.
-
name
Return attribute name, which is used as attribute key on non-indexedAttributeHolders.- Returns:
- attribute name.
-
index
public int index()Return attribute name, which is used as attribute key on indexedAttributeHolders.- Returns:
- attribute indexed.
-