Class AttachableDelegate<K,V>
java.lang.Object
io.foldright.inspectablewrappers.utils.AttachableDelegate<K,V>
- All Implemented Interfaces:
Attachable<K,V>
A simple
Attachable delegate implementation.
Note:
As the attachments are stored in hash map(threadsafe ConcurrentHashMap),
the implementation of the key type must meet the requirements of the hash map, which means that
a stable hash code and the ability to compare equality using equals() must be implemented.
- Author:
- Jerry Lee (oldratlee at gmail dot com), Yang Fang (snoop dot fy at gmail dot com), Zava Xu (zava dot kid at gmail dot com)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAttachment_(K key) Gets the attachment value for the given key.voidsetAttachment_(K key, V value) Sets an attachment.
-
Constructor Details
-
AttachableDelegate
public AttachableDelegate()
-
-
Method Details
-
setAttachment_
Sets an attachment.- Specified by:
setAttachment_in interfaceAttachable<K,V> - Parameters:
key- the attachment keyvalue- the attachment value- Throws:
NullPointerException- if any arguments is null
-
getAttachment_
Gets the attachment value for the given key.- Specified by:
getAttachment_in interfaceAttachable<K,V> - Parameters:
key- the attachment key- Returns:
- return the attachment value, or
nullif contains no attachment for the key - Throws:
NullPointerException- if key argument is nullClassCastException- if the return value is not type<V>- See Also:
-