public class SimpleAttachable extends Object implements Attachable
Attachable
which may be used as a base class or on a standalone basis.
This class is thread safe, as all methods are synchronized.
Constructor and Description |
---|
SimpleAttachable() |
Modifier and Type | Method and Description |
---|---|
<T> void |
addToAttachmentList(AttachmentKey<AttachmentList<T>> key,
T value)
Add a value to a list-typed attachment key.
|
Collection<AttachmentKey<?>> |
attachmentKeys() |
<T> T |
getAttachment(AttachmentKey<T> key)
Get an attachment value.
|
<T> List<T> |
getAttachmentList(AttachmentKey<? extends List<T>> key)
Gets a list attachment value.
|
boolean |
hasAttachment(AttachmentKey<?> key)
Check if an attachment exists for this key.
|
<T> T |
putAttachment(AttachmentKey<T> key,
T value)
Set an attachment value.
|
<T> T |
removeAttachment(AttachmentKey<T> key)
Remove an attachment, returning its previous value.
|
public boolean hasAttachment(AttachmentKey<?> key)
hasAttachment
in interface Attachable
key
- the attachment keyfalse
if there is nonepublic <T> T getAttachment(AttachmentKey<T> key)
null
is returned.getAttachment
in interface Attachable
T
- the value typekey
- the attachment keynull
if there is nonepublic <T> List<T> getAttachmentList(AttachmentKey<? extends List<T>> key)
getAttachmentList
in interface Attachable
T
- the value typekey
- the attachment keypublic <T> T putAttachment(AttachmentKey<T> key, T value)
null
, the attachment key is removed.putAttachment
in interface Attachable
T
- the value typekey
- the attachment keyvalue
- the new valuenull
if there was nonepublic <T> T removeAttachment(AttachmentKey<T> key)
removeAttachment
in interface Attachable
T
- the value typekey
- the attachment keynull
if there was nonepublic <T> void addToAttachmentList(AttachmentKey<AttachmentList<T>> key, T value)
addToAttachmentList
in interface Attachable
T
- the list value typekey
- the attachment keyvalue
- the value to addpublic Collection<AttachmentKey<?>> attachmentKeys()
Copyright © 2023 JBoss by Red Hat. All rights reserved.