Interface DataContainer
- All Known Implementing Classes:
AnalysisContainer
,DynamicDataContainer
,PlayerContainer
,RawDataContainer
,SupplierDataContainer
Key
objects.
Implementations should mainly be concerned on how the data given to it is stored. Retrieval has some details that should be followed.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the container of all data.default <T> String
getFormatted
(Key<T> key, Formatter<Optional<T>> formatter) Get formatted Value identified by the Key.default <T> String
getFormattedUnsafe
(Key<T> key, Formatter<T> formatter) Get formatted Value identified by the Key, or throw an exception.getMap()
Return a Key - Value Map of the data in the container.<T> T
Get data identified by the Key, or throw an exception.<T> Optional<T>
Get an Optional of the Value identified by the Key.default List<?>
handleList
(List<?> list) default Map<?,
?> void
putAll
(DataContainer dataContainer) Place all values from given DataContainer into this container.<T> void
putCachingSupplier
(Key<T> key, 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, Supplier<T> supplier) Place a data supplier inside the container.<T> boolean
Check if a Value with the given Key has been placed into the container.
-
Method Details
-
mapToNormalMap
-
handleList
-
handleMap
-
putRawData
Place your data inside the container.What the container does with the object depends on the implementation.
- Type Parameters:
T
- Type of the object- Parameters:
key
- Key of type T that identifies the data and will be used later when the data needs to be fetched.obj
- object to store
-
putSupplier
Place a data supplier inside the container.What the container does with the supplier depends on the implementation.
- Type Parameters:
T
- Type of the object- Parameters:
key
- Key of type T that identifies the data and will be used later when the data needs to be fetched.supplier
- Supplier to store
-
putCachingSupplier
Place a caching data supplier inside the container.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.
- Type Parameters:
T
- Type of the object- Parameters:
key
- Key of type T that identifies the data and will be used later when the data needs to be fetched.supplier
- Supplier to store
-
supports
Check if a Value with the given Key has been placed into the container.- Type Parameters:
T
- Type of the object returned by the Value if it is present.- Parameters:
key
- Key that identifies the data.- Returns:
- true if found, false if not.
-
getValue
Get an Optional of the Value identified by the Key.It is recommended to check if the Optional is present as null values will be empty.
- Type Parameters:
T
- Type of the object returned by Value- Parameters:
key
- Key that identifies the Value- Returns:
- Optional of the object if the key is registered and key matches the type of the object. Otherwise empty.
-
getUnsafe
Get data identified by the Key, or throw an exception.It is recommended to use
supports(Key)
before using this method.- Type Parameters:
T
- Type of the object returned by Value- Parameters:
key
- Key that identifies the Value- Returns:
- the value
- Throws:
IllegalArgumentException
- If the key is not supported.
-
getFormatted
Get formatted Value identified by the Key.- Type Parameters:
T
- Type of the object returned by Value- Parameters:
key
- Key that identifies the Valueformatter
- Formatter for the Optional returned bygetValue(Key)
- Returns:
- Optional of the object if the key is registered and key matches the type of the object. Otherwise empty.
-
getFormattedUnsafe
Get formatted Value identified by the Key, or throw an exception.It is recommended to use
supports(Key)
before using this method.- Type Parameters:
T
- Type of the object returned by Value- Parameters:
key
- Key that identifies the Valueformatter
- Formatter for the value- Returns:
- the value
- Throws:
IllegalArgumentException
- If the key is not supported.
-
putAll
Place all values from given DataContainer into this container.- Parameters:
dataContainer
- Container with values.
-
clear
void clear()Clear the container of all data. -
getMap
Return a Key - Value Map of the data in the container.This method may call blocking methods if underlying implementation uses the given Suppliers.
- Returns:
- Map: Key - Object
-