Package io.undertow.util
Class AbstractAttachable
java.lang.Object
io.undertow.util.AbstractAttachable
- All Implemented Interfaces:
Attachable
- Direct Known Subclasses:
HttpServerExchange
A thing which can have named attachments.
- Author:
- David M. Lloyd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> voidaddToAttachmentList(AttachmentKey<AttachmentList<T>> key, T value) Add a value to a list-typed attachment key.protected Map<AttachmentKey<?>,Object> <T> TgetAttachment(AttachmentKey<T> key) Get an attachment value.<T> List<T>getAttachmentList(AttachmentKey<? extends List<T>> key) Gets a list attachment value.<T> TputAttachment(AttachmentKey<T> key, T value) Set an attachment value.<T> TremoveAttachment(AttachmentKey<T> key) Remove an attachment, returning its previous value.
-
Constructor Details
-
AbstractAttachable
public AbstractAttachable()
-
-
Method Details
-
getAttachment
Get an attachment value. If no attachment exists for this key,nullis returned.- Specified by:
getAttachmentin interfaceAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment key- Returns:
- the value, or
nullif there is none
-
getAttachmentList
Gets a list attachment value. If not attachment exists for this key an empty list is returned- Specified by:
getAttachmentListin interfaceAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment key- Returns:
- the value, or an empty list if there is none
-
putAttachment
Set an attachment value. If an attachment for this key was already set, return the original value. If the value being set isnull, the attachment key is removed.- Specified by:
putAttachmentin interfaceAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment keyvalue- the new value- Returns:
- the old value, or
nullif there was none
-
createAttachmentMap
-
removeAttachment
Remove an attachment, returning its previous value.- Specified by:
removeAttachmentin interfaceAttachable- Type Parameters:
T- the value type- Parameters:
key- the attachment key- Returns:
- the old value, or
nullif there was none
-
addToAttachmentList
Add a value to a list-typed attachment key. If the key is not mapped, add such a mapping.- Specified by:
addToAttachmentListin interfaceAttachable- Type Parameters:
T- the list value type- Parameters:
key- the attachment keyvalue- the value to add
-