Top Description Fields Constructors Methods
org.glassfish.grizzly.attributes

public final Class Attribute<T>

extends Object
Class Inheritance
Imports
java.util.function.Supplier

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.

Field Summary

Modifier and TypeField and Description
private final int
attributeIndex

Attribute index in AttributeBuilder

private final AttributeBuilder
builder

AttributeBuilder, which was used to create this attribute

private final Supplier<T>
initializer

Attribute initializer, which will be called, if attribute is not set.

private final String
name

Attribute name

Constructor Summary

AccessConstructor and Description
protected
Attribute(final AttributeBuilder builder, final String name, final int index, final T defaultValue)

protected
Attribute(final AttributeBuilder builder, final String name, final int index, final Supplier<T> initializer)

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

attribute value
get
(final AttributeHolder attributeHolder)

Get attribute value, stored on the AttributeHolder.

public T

Returns:

attribute value
get
(final AttributeStorage storage)

Get attribute value, stored on the AttributeStorage.

private T
get0(final AttributeHolder attributeHolder, final Supplier<T> initializer)

public int

Returns:

attribute indexed.
index
()

Return attribute name, which is used as attribute key on indexed AttributeHolders.

public boolean

Returns:

true, if attribute is set, of false otherwise.
isSet
(final AttributeHolder attributeHolder)

Checks if this attribute is set on the AttributeHolder.

public boolean

Returns:

true, if attribute is set, of false otherwise.
isSet
(final AttributeStorage storage)

Checks if this attribute is set on the AttributeStorage.

public String

Returns:

attribute name.
name
()

Return attribute name, which is used as attribute key on non-indexed AttributeHolders.

public T

Returns:

attribute value
peek
(final AttributeHolder attributeHolder)

Get attribute value, stored on the AttributeHolder, the difference from get(org.glassfish.grizzly.attributes.AttributeHolder) is that default value or Supplier won't be invoked.

public T

Returns:

attribute value
peek
(final AttributeStorage storage)

Get attribute value, stored on the AttributeStorage, the difference from get(AttributeStorage) is that default value or Supplier won't be invoked.

public T

Returns:

the previous value associated with the attribute
remove
(final AttributeHolder attributeHolder)

Remove attribute value, stored on the AttributeHolder.

public T
remove(final AttributeStorage storage)

Remove attribute value, stored on the AttributeStorage.

public void
set(final AttributeHolder attributeHolder, final T
attribute value to set.
value
)

Set attribute value, stored on the AttributeHolder.

public void
set(final AttributeStorage storage, final T
attribute value to set.
value
)

Set attribute value, stored on the AttributeStorage.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attributeIndexback to summary
private final int attributeIndex

Attribute index in AttributeBuilder

builderback to summary
private final AttributeBuilder builder

AttributeBuilder, which was used to create this attribute

initializerback to summary
private final Supplier<T> initializer

Attribute initializer, which will be called, if attribute is not set.

nameback to summary
private final String name

Attribute name

Constructor Detail

Attributeback to summary
protected Attribute(final AttributeBuilder builder, final String name, final int index, final T defaultValue)
Attributeback to summary
protected Attribute(final AttributeBuilder builder, final String name, final int index, final Supplier<T> initializer)

Method Detail

getback to summary
public T get(final AttributeHolder attributeHolder)

Get attribute value, stored on the AttributeHolder.

Parameters
attributeHolder:AttributeHolder

AttributeHolder.

Returns:T

attribute value

getback to summary
public T get(final AttributeStorage storage)

Get attribute value, stored on the AttributeStorage.

Parameters
storage:AttributeStorage

AttributeStorage.

Returns:T

attribute value

get0back to summary
private T get0(final AttributeHolder attributeHolder, final Supplier<T> initializer)
Annotations
@SuppressWarnings:unchecked
indexback to summary
public int index()

Return attribute name, which is used as attribute key on indexed AttributeHolders.

Returns:int

attribute indexed.

isSetback to summary
public boolean isSet(final AttributeHolder attributeHolder)

Checks if this attribute is set on the AttributeHolder. Returns true, if attribute is set, of false otherwise.

Parameters
attributeHolder:AttributeHolder

AttributeHolder.

Returns:boolean

true, if attribute is set, of false otherwise.

isSetback to summary
public boolean isSet(final AttributeStorage storage)

Checks if this attribute is set on the AttributeStorage. Returns true, if attribute is set, of false otherwise.

Parameters
storage:AttributeStorage

AttributeStorage.

Returns:boolean

true, if attribute is set, of false otherwise.

nameback to summary
public String name()

Return attribute name, which is used as attribute key on non-indexed AttributeHolders.

Returns:String

attribute name.

peekback to summary
public T peek(final AttributeHolder attributeHolder)

Get attribute value, stored on the AttributeHolder, the difference from get(org.glassfish.grizzly.attributes.AttributeHolder) is that default value or Supplier won't be invoked.

Parameters
attributeHolder:AttributeHolder

AttributeHolder.

Returns:T

attribute value

peekback to summary
public T peek(final AttributeStorage storage)

Get attribute value, stored on the AttributeStorage, the difference from get(AttributeStorage) is that default value or Supplier won't be invoked.

Parameters
storage:AttributeStorage

AttributeStorage.

Returns:T

attribute value

removeback to summary
public T remove(final AttributeHolder attributeHolder)

Remove attribute value, stored on the AttributeHolder.

Parameters
attributeHolder:AttributeHolder

AttributeHolder.

Returns:T

the previous value associated with the attribute

Annotations
@SuppressWarnings:unchecked
removeback to summary
public T remove(final AttributeStorage storage)

Remove attribute value, stored on the AttributeStorage.

Parameters
storage:AttributeStorage

AttributeStorage.

setback to summary
public void set(final AttributeHolder attributeHolder, final T value)

Set attribute value, stored on the AttributeHolder.

Parameters
attributeHolder:AttributeHolder

AttributeHolder.

value:T

attribute value to set.

setback to summary
public void set(final AttributeStorage storage, final T value)

Set attribute value, stored on the AttributeStorage.

Parameters
storage:AttributeStorage

AttributeStorage.

value:T

attribute value to set.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override