Top Description Methods
io.undertow.util

public Interface Attachable

Known Direct Subinterfaces
io.undertow.client.ClientExchange
Known Direct Implementers
io.undertow.protocols.http2.Http2Channel, io.undertow.server.handlers.sse.ServerSentEventConnection, io.undertow.util.AbstractAttachable
Imports
java.util.List

A thing which can have named attachments.
Author
David M. Lloyd

Method Summary

Modifier and TypeMethod and Description
public <
the list value type
T
>
void
addToAttachmentList(AttachmentKey<AttachmentList<T>>
the attachment key
key
,
T
the value to add
value
)

Add a value to a list-typed attachment key.

public <
the value type
T
>
T

Returns:

the value, or null if there is none
getAttachment
(AttachmentKey<T>
the attachment key
key
)

Get an attachment value.

public <
the value type
T
>
List<T>

Returns:

the value, or an empty list if there is none
getAttachmentList
(AttachmentKey<? extends List<T>>
the attachment key
key
)

Gets a list attachment value.

public <
the value type
T
>
T

Returns:

the old value, or null if there was none
putAttachment
(AttachmentKey<T>
the attachment key
key
,
T
the new value
value
)

Set an attachment value.

public <
the value type
T
>
T

Returns:

the old value, or null if there was none
removeAttachment
(AttachmentKey<T>
the attachment key
key
)

Remove an attachment, returning its previous value.

Method Detail

addToAttachmentListback to summary
public <T> void addToAttachmentList(AttachmentKey<AttachmentList<T>> key, T value)

Add a value to a list-typed attachment key. If the key is not mapped, add such a mapping.

Parameters
<T>
the list value type
key:AttachmentKey<AttachmentList<T>>

the attachment key

value:T

the value to add

getAttachmentback to summary
public <T> T getAttachment(AttachmentKey<T> key)

Get an attachment value. If no attachment exists for this key, null is returned.

Parameters
<T>
the value type
key:AttachmentKey<T>

the attachment key

Returns:T

the value, or null if there is none

getAttachmentListback to summary
public <T> List<T> getAttachmentList(AttachmentKey<? extends List<T>> key)

Gets a list attachment value. If not attachment exists for this key an empty list is returned

Parameters
<T>
the value type
key:AttachmentKey<? extends List<T>>

the attachment key

Returns:List<T>

the value, or an empty list if there is none

putAttachmentback to summary
public <T> T putAttachment(AttachmentKey<T> key, T value)

Set an attachment value. If an attachment for this key was already set, return the original value. If the value being set is null, the attachment key is removed.

Parameters
<T>
the value type
key:AttachmentKey<T>

the attachment key

value:T

the new value

Returns:T

the old value, or null if there was none

removeAttachmentback to summary
public <T> T removeAttachment(AttachmentKey<T> key)

Remove an attachment, returning its previous value.

Parameters
<T>
the value type
key:AttachmentKey<T>

the attachment key

Returns:T

the old value, or null if there was none