Package org.jboss.as.server.deployment
Class SimpleAttachable
- java.lang.Object
-
- org.jboss.as.server.deployment.SimpleAttachable
-
- All Implemented Interfaces:
Attachable
- Direct Known Subclasses:
ModuleSpecification,ResourceRoot
public class SimpleAttachable extends Object implements Attachable
A simple implementation ofAttachablewhich may be used as a base class or on a standalone basis.This class is thread safe, as all methods are synchronized.
- Author:
- David M. Lloyd
-
-
Constructor Summary
Constructors Constructor Description SimpleAttachable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> voidaddToAttachmentList(AttachmentKey<AttachmentList<T>> key, T value)Add a value to a list-typed attachment key.Set<AttachmentKey<?>>attachmentKeys()<T> TgetAttachment(AttachmentKey<T> key)Get an attachment value.<T> List<T>getAttachmentList(AttachmentKey<? extends List<T>> key)Gets a list attachment value.booleanhasAttachment(AttachmentKey<?> key)Check if an attachment exists for this key.<T> TputAttachment(AttachmentKey<T> key, T value)Set an attachment value.<T> TremoveAttachment(AttachmentKey<T> key)Remove an attachment, returning its previous value.
-
-
-
Method Detail
-
hasAttachment
public boolean hasAttachment(AttachmentKey<?> key)
Check if an attachment exists for this key.- Specified by:
hasAttachmentin interfaceAttachable- Parameters:
key- the attachment key- Returns:
falseif there is none
-
getAttachment
public <T> T getAttachment(AttachmentKey<T> key)
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
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- 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
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 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
-
removeAttachment
public <T> T removeAttachment(AttachmentKey<T> key)
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
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.- Specified by:
addToAttachmentListin interfaceAttachable- Type Parameters:
T- the list value type- Parameters:
key- the attachment keyvalue- the value to add
-
attachmentKeys
public Set<AttachmentKey<?>> attachmentKeys()
-
-