public class RawDataContainer extends java.lang.Object implements DataContainer
Constructor and Description |
---|
RawDataContainer()
Create a RawDataContainer.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear the container of all data.
|
java.util.Map<Key,java.lang.Object> |
getMap()
Return a Key - Value Map of the data in the container.
|
<T> T |
getUnsafe(Key<T> key)
Get data identified by the Key, or throw an exception.
|
<T> java.util.Optional<T> |
getValue(Key<T> key)
Get an Optional of the Value identified by the Key.
|
void |
putAll(DataContainer dataContainer)
Place all values from given DataContainer into this container.
|
<T> void |
putCachingSupplier(Key<T> key,
java.util.function.Supplier<T> supplier)
Place a caching data supplier inside the container.
|
<T> void |
putRawData(Key<T> key,
T obj)
Place your data inside the container.
|
<T> void |
putSupplier(Key<T> key,
java.util.function.Supplier<T> supplier)
Place a data supplier inside the container.
|
<T> boolean |
supports(Key<T> key)
Check if a Value with the given Key has been placed into the container.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFormatted, getFormattedUnsafe
public <T> void putRawData(Key<T> key, T obj)
DataContainer
What the container does with the object depends on the implementation.
putRawData
in interface DataContainer
T
- Type of the objectkey
- Key of type T that identifies the data and will be used later when the data needs to be fetched.obj
- object to storepublic <T> void putSupplier(Key<T> key, java.util.function.Supplier<T> supplier)
DataContainer
What the container does with the supplier depends on the implementation.
putSupplier
in interface DataContainer
T
- Type of the objectkey
- Key of type T that identifies the data and will be used later when the data needs to be fetched.supplier
- Supplier to storepublic <T> void putCachingSupplier(Key<T> key, java.util.function.Supplier<T> supplier)
DataContainer
If the supplier is called the value is cached according to the implementation of the container. What the container does with the supplier depends on the implementation.
putCachingSupplier
in interface DataContainer
T
- Type of the objectkey
- Key of type T that identifies the data and will be used later when the data needs to be fetched.supplier
- Supplier to storepublic <T> boolean supports(Key<T> key)
DataContainer
supports
in interface DataContainer
T
- Type of the object returned by the Value if it is present.key
- Key that identifies the data.public <T> java.util.Optional<T> getValue(Key<T> key)
DataContainer
It is recommended to check if the Optional is present as null values will be empty.
getValue
in interface DataContainer
T
- Type of the object returned by Valuekey
- Key that identifies the Valuepublic <T> T getUnsafe(Key<T> key)
DataContainer
It is recommended to use DataContainer.supports(Key)
before using this method.
getUnsafe
in interface DataContainer
T
- Type of the object returned by Valuekey
- Key that identifies the Valuepublic void putAll(DataContainer dataContainer)
DataContainer
putAll
in interface DataContainer
dataContainer
- Container with values.public void clear()
DataContainer
clear
in interface DataContainer
public java.util.Map<Key,java.lang.Object> getMap()
DataContainer
This method may call blocking methods if underlying implementation uses the given Suppliers.
getMap
in interface DataContainer