- Type Parameters:
K- keyV- value
- All Known Subinterfaces:
ContentOnlyData<K,,V> DataWrapper<K,,V> SAOData<O>,SAODataWrapper<O>,SOData,SODataWrapper
- All Known Implementing Classes:
SAOContentOnlyDataListImpl,SAODataListImpl,SAODataMapImpl,SAODataWrapperImpl,SODataListImpl,SODataMapImpl,SODataWrapperImpl
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a newEntry.voidAdds a newEntry.default booleanaddIfNotNull(K key, V value) Adds a newEntryif given value is notnull.default booleanaddIfOptionalExists(K key, @NotNull OptionalValue<? extends V> optionalValue) default VaddOrReplace(K key, V value) default <C extends V,R>
booleanconvertAndProcessIfContained(K key, @NotNull Converter<C, R> converter, @NotNull Consumer<R> consumer) If an entry with given key exists, it will beconvertedby givenconverter, then processed by givenconsumerandtruewill be returned.
If an entry with given key does not exists,falsewill be returned.convertAndProcessIfContainedAndRequireNotNull(K key, Converter<C, R> converter, @NotNull Consumer<R> consumer, ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) If an entry with given key exists and it's value is notnull, it will be cast toAbstractData, converted toAbstractDataand then processed by given consumer andtruewill be returned.default <C,R> boolean convertAndProcessListIfContained(K key, @NotNull Converter<C, R> converter, @NotNull Consumer<List<R>> consumer) If an entry with givenkeyexists, it will be cast to aListand every element cast toAbstractDataconvertedtoAbstractData.convertWithExceptionAndProcessIfContained(K key, @NotNull ExceptionConverter<C, R, E> converter, @NotNull Consumer<R> consumer) If an entry with given key exists, it will beconvertedby givenconverter, then processed by givenconsumerandtruewill be returned.
If an entry with given key does not exists,falsewill be returned.convertWithExceptionAndProcessIfContainedAndRequireNotNull(K key, ExceptionConverter<C, R, F> converter, @NotNull Consumer<R> consumer, ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) If an entry with given key exists and it's value is notnull, it will be cast toAbstractData, converted toAbstractDataand then processed by given consumer andtruewill be returned.default <C,R, E extends Throwable>
booleanconvertWithExceptionAndProcessListIfContained(K key, @NotNull ExceptionConverter<C, R, E> converter, @NotNull Consumer<List<R>> consumer) If an entry with givenkeyexists, it will be cast to aListand every element cast toAbstractDataconvertedtoAbstractData.default Vdefault Vdefault Vdefault <C extends V,R>
RgetAndConvert(K key, @NotNull Converter<C, R> converter) The value returned byget(Object)with given key must be of typeAbstractDataornull.
If the value returned byget(Object)with given key isnull,Converter.convert(Object)withnullis called!default <C extends V,R>
RgetAndConvert(K key, @NotNull Converter<C, R> converter, R defaultObject) default <C extends V,R>
RgetAndConvertOrDefault(K key, @NotNull Converter<C, R> converter, R defaultObject, R defaultObjectIfNull) default <C extends V,R>
RgetAndConvertOrDefaultBoth(K key, @NotNull Converter<C, R> converter, R defaultObject) getAndConvertWithException(K key, @NotNull ExceptionConverter<C, R, E> converter) The value returned byget(Object)with given key must be of typeAbstractDataornull.
If the value returned byget(Object)with given key isnull,ExceptionConverter.convert(Object)withnull.getAndConvertWithException(K key, @NotNull ExceptionConverter<C, R, E> converter, R defaultObject) getAndRequireNotNull(K key, @NotNull ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) Getsthe value with given key and returns it, if the value is notnull.getAndRequireNotNullAndConvert(K key, @NotNull Converter<C, R> converter, @NotNull ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) Getsthe value with given key and casts it toAbstractData.getAndRequireNotNullAndConvertWithException(K key, @NotNull ExceptionConverter<C, R, F> converter, @NotNull ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) Getsthe value with given key and casts it toAbstractData.default <C extends V>
Cdefault <C extends V>
Cdefault <C extends V>
CgetAsAndRequireNotNull(K key, @NotNull ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) getContainer(K key) default AbstractData<K,V> getData()default <C,R> @Nullable ArrayList<R> getListAndConvert(K key, @NotNull Converter<C, R> converter) default <C,R> @Nullable ArrayList<R> getListAndConvertAndFreeMemory(K key, @NotNull Converter<C, R> converter) Each element from the implementations - returned bygetList(Object)with given key - will be set tonull, after it has been converted and stored in the implementations that will be returned.getListAndConvertWithException(K key, @NotNull ExceptionConverter<C, R, E> converter) getListAndConvertWithExceptionAndFreeMemory(K key, @NotNull ExceptionConverter<C, R, E> converter) Each element from the implementations - returned bygetList(Object)with given key - will be set tonull, after it has been converted and stored in the implementations that will be returned.default <E extends Exception>
bytegetNumberAsByte(K key, @NotNull ValueFactory<K, Byte, E> valueFactory) default <E extends Exception>
doublegetNumberAsDouble(K key, @NotNull ValueFactory<K, Double, E> valueFactory) default <E extends Exception>
floatgetNumberAsFloat(K key, @NotNull ValueFactory<K, Float, E> valueFactory) default <E extends Exception>
intgetNumberAsInt(K key, @NotNull ValueFactory<K, Integer, E> valueFactory) default <E extends Exception>
longgetNumberAsLong(K key, @NotNull ValueFactory<K, Long, E> valueFactory) default <E extends Exception>
shortgetNumberAsShort(K key, @NotNull ValueFactory<K, Short, E> valueFactory) default <C> @NotNull OptionalValue<C>getOptionalValue(K key) default <C,R> @NotNull OptionalValue<R> getOptionalValueAndConvert(K key, @NotNull Converter<C, R> converter) default <C,R, E extends Exception>
@NotNull OptionalValue<R>getOptionalValueAndConvertWithException(K key, @NotNull ExceptionConverter<C, R, E> converter) default VgetOrDefault(K key, V defaultObject) default VgetOrDefault(K key, V defaultObject, V defaultObjectIfNull) default VgetOrDefaultBoth(K key, V defaultObject) default @NotNull ParseTypeHow thisAbstractDatashould be parsedbooleanisEmpty()default <C extends V>
booleanprocessIfContained(K key, @NotNull Consumer<C> consumer) If an entry with given key exists, it will be processed by given consumer andtruewill be returned.
If an entry with given key does not exists,falsewill be returned.processIfContainedAndRequireNotNull(K key, @NotNull Consumer<C> consumer, ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) If an entry with given key exists and it's value is notnull, it will be processed by given consumer andtruewill be returned.default <C extends V>
booleanprocessIfNotNull(K key, @NotNull Consumer<C> consumer) default booleanprocessListIfContained(K key, @NotNull Consumer<List<Object>> consumer) If an entry with key exists, it will be cast to aListand then processed by givenconsumerandtruewill be returned.RemovesEntrywith given key.intsize()default @NotNull StringBuilderWrites thisAbstractDatato aStringBuilder.default <T extends Record>
TConverts thisAbstractDatato givenrecordClass.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Field Details
-
PARSER
-
-
Method Details
-
add
Adds a newEntry.
This method might not check, if a
Entrywith given key already exits. Depending on the implementation, this might even override existing mappings (for ExampleSODataMapImpl).- Parameters:
key- keyvalue- value- Returns:
trueif a newEntrywas added,falseotherwise
-
addIfNotNull
Adds a newEntryif given value is notnull.
This method might not check, if a
Entrywith given key already exits. Depending on the implementation, this might even override existing mappings (for ExampleSODataMapImpl).- Parameters:
key- keyvalue- value- Returns:
trueif a newEntrywas added,falseotherwise
-
addIfOptionalExists
default boolean addIfOptionalExists(@NotNull K key, @NotNull @NotNull OptionalValue<? extends V> optionalValue) Adds a newEntrywith givenkeyandOptionalValue.get()if givenoptionalValueexists.
This method might not check, if a
Entrywith givenkeyalready exits. Depending on the implementation, this might even override existing mappings (for ExampleSODataMapImpl).- Parameters:
key-AbstractDatakeyoptionalValue-OptionalValue- Returns:
trueif a newEntrywas added,falseotherwise
-
addOrReplace
-
addEntry
Adds a newEntry.
This method might not check, if a
Entrywith given key already exits (depending on the implementation)- Parameters:
entry- entry to add
-
remove
Removes
Entrywith given key. If no such entry exists nothing happens.- Parameters:
key- key for the entry to remove- Returns:
- the removed
Entryornullif no entry was removed.
-
getEntry
-
getOptionalValue
- Type Parameters:
C- type tp cast to- Parameters:
key-key- Returns:
OptionalValue- Throws:
ClassCastException- if the value for given key is not of typeAbstractData.
-
getOptionalValueAndConvert
@NotNull default <C,R> @NotNull OptionalValue<R> getOptionalValueAndConvert(@NotNull K key, @NotNull @NotNull Converter<C, R> converter) - Type Parameters:
C- type tp cast toR- type your converter converts to- Parameters:
key-keyconverter-Converterto convert fromAbstractDatatoAbstractData.- Returns:
OptionalValue- Throws:
ClassCastException- if the value for given key is not of typeAbstractData.
-
getOptionalValueAndConvertWithException
@NotNull default <C,R, @NotNull OptionalValue<R> getOptionalValueAndConvertWithExceptionE extends Exception> (@NotNull K key, @NotNull @NotNull ExceptionConverter<C, R, throws EE> converter) - Type Parameters:
C- type tp cast toR- type your converter converts toE-Exceptionyour converter may throw- Parameters:
key-keyconverter-Converterto convert fromAbstractDatatoAbstractData.- Returns:
OptionalValue- Throws:
E- by your converterClassCastException- if the value for given key is not of typeAbstractData.
-
getContainer
-
get
Getsvaluefor given key or- Parameters:
key-keydefaultObject-AbstractDatadefault object to return, if noEntryfor given key exists.defaultObjectIfNull-AbstractDatadefault object to return, ifvaluefor given key isnull.- Returns:
valuefor given key or a default value as specified above.
-
getOrDefault
@Contract("_, !null, !null -> !null") @Nullable default V getOrDefault(@NotNull K key, @Nullable V defaultObject, @Nullable V defaultObjectIfNull) - See Also:
-
getOrDefaultBoth
@Contract("_, !null -> !null") @Nullable default V getOrDefaultBoth(@NotNull K key, @Nullable V defaultObject) - Parameters:
key-keydefaultObject-AbstractDatadefault object to return, if noEntryfor given key exists or value isnull- Returns:
valuefor given key or defaultObject if noEntryfor given key exists or value isnull.- See Also:
-
get
- Parameters:
key-keydefaultObject-AbstractDatadefault object to return, if noEntryfor given key exists.- Returns:
valuefor given key or a defaultObject if noEntrywith given key exists.
-
getOrDefault
- See Also:
-
get
-
getAs
@Contract("_, !null, !null -> !null") @Nullable default <C extends V> C getAs(@NotNull K key, @Nullable C defaultObject, @Nullable C defaultObjectIfNull) - Type Parameters:
C- class to which the value of the entry should be cast to- Parameters:
key-keydefaultObject- default object to return if no entry with given key existsdefaultObjectIfNull- default object to return if the value of the entry with given key isnull- Returns:
- value (cast to
AbstractData) of entry with given key ornullif the value of given key isnullor given defaultObject isnulland there is no entry for given key. - Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractData
-
getAs
- Type Parameters:
C- class to which the value of the entry should be cast to- Parameters:
key-keydefaultObject- default object to return if no entry with given key exists- Returns:
- value (cast to
AbstractData) of entry with given key ornullif the value of given key isnullor given defaultObject isnulland there is no entry for given key. - Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractData
-
getAs
- Type Parameters:
C- class to which the value of the entry should be cast to- Parameters:
key-key- Returns:
- value (cast to
AbstractData) of entry with given key ornullif the value of the entry isnullor if no such entry exits - Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractData- See Also:
-
getAndConvert
default <C extends V,R> R getAndConvert(@NotNull K key, @NotNull @NotNull Converter<C, R> converter) The value returned byget(Object)with given key must be of typeAbstractDataornull.
If the value returned byget(Object)with given key isnull,Converter.convert(Object)withnullis called!- Type Parameters:
C- the convertible typeR- the result type- Parameters:
key- the key for the entry of typeAbstractDataconverter-Converterto convert fromAbstractDatatoAbstractData- Returns:
- result
AbstractDataornullif your functions returnsnull - Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeAbstractData
-
getAndConvert
@Nullable @Contract("_, _, !null -> !null") default <C extends V,R> R getAndConvert(@NotNull K key, @NotNull @NotNull Converter<C, R> converter, @Nullable R defaultObject) - Type Parameters:
C- the convertible typeR- the result type- Parameters:
key- the key for the entry of typeAbstractDataconverter-Converterto convert fromAbstractDatatoAbstractDatadefaultObject- object to return ifget(Object)with given key isnull. (if entry or value isnull)- Returns:
- result
AbstractDataornullif defaultObject isnullandget(Object)with given isnullor if your functions returnsnull - Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeAbstractData- See Also:
-
getAndConvertOrDefault
@Contract("_, _, !null, !null -> !null") @Nullable default <C extends V,R> R getAndConvertOrDefault(@NotNull K key, @NotNull @NotNull Converter<C, R> converter, @Nullable R defaultObject, @Nullable R defaultObjectIfNull) - Type Parameters:
C- the convertible typeR- the result type- Parameters:
key-keyconverter-Converterto convert fromAbstractDatatoAbstractData#defaultObject- default object to return if no entry with given key existsdefaultObjectIfNull- default object to return if the value of the entry with given key isnull- Returns:
- result
AbstractDataornullif the value of the entry isnullor if no entry with given key exists and your default object isnull - Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractData
-
getAndConvertOrDefaultBoth
@Nullable @Contract("_, _, !null -> !null") default <C extends V,R> R getAndConvertOrDefaultBoth(@NotNull K key, @NotNull @NotNull Converter<C, R> converter, @Nullable R defaultObject) - Type Parameters:
C- the convertible typeR- the result type- Parameters:
key- the key for the entry of typeAbstractDataconverter-Converterto convert fromAbstractDatatoAbstractDatadefaultObject- object to return ifget(Object)with given key isnull. (if entry or value isnull)- Returns:
- result
AbstractDataornullif defaultObject isnullandget(Object)with given isnullor if your functions returnsnull - Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeAbstractData
-
getAndConvertWithException
@Nullable default <C extends V,R, R getAndConvertWithExceptionE extends Exception> (@NotNull K key, @NotNull @NotNull ExceptionConverter<C, R, throws EE> converter) The value returned byget(Object)with given key must be of typeAbstractDataornull.
If the value returned byget(Object)with given key isnull,ExceptionConverter.convert(Object)withnull.- Type Parameters:
C- the convertible typeR- the result typeE- the Exception thrown by yourExceptionConverter- Parameters:
key- the key for the entry of typeAbstractDataconverter-Converterto convert fromAbstractDatatoAbstractData- Returns:
- result
AbstractDataornullif your functions returnsnull - Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeAbstractDataE- ifExceptionConverter.convert(Object)throws an Exception
-
getAndConvertWithException
@Nullable default <C extends V,R, R getAndConvertWithExceptionE extends Exception> (@NotNull K key, @NotNull @NotNull ExceptionConverter<C, R, throws EE> converter, @Nullable R defaultObject) - Type Parameters:
C- the convertible typeR- the result typeE- the Exception thrown by yourExceptionConverter- Parameters:
key- the key for the entry of typeAbstractDataconverter-Converterto convert fromAbstractDatatoAbstractDatadefaultObject- object to return ifget(Object)with given key isnull- Returns:
- result
AbstractDataornullif defaultObject isnullandget(Object)with given isnullor if your functions returnsnull - Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeAbstractDataE- ifExceptionConverter.convert(Object)throws an Exception
-
getNumberAsByte
default <E extends Exception> byte getNumberAsByte(@NotNull K key, @NotNull @NotNull ValueFactory<K, Byte, throws EE> valueFactory) - Type Parameters:
E- factory that may be thrown by yourValueFactory- Parameters:
key- the key for the entry which should be of typeNumbervalueFactory- ifget(Object)returnsnull, this factory is used to create a byte or throw a factory- Returns:
byte valueofNumbervalue at given key or created value by your valueFactory ifget(Object)returnednull.- Throws:
E- may be thrown by yourValueFactory
-
getNumberAsShort
default <E extends Exception> short getNumberAsShort(@NotNull K key, @NotNull @NotNull ValueFactory<K, Short, throws EE> valueFactory) - Type Parameters:
E- factory that may be thrown by yourValueFactory- Parameters:
key- the key for the entry which should be of typeNumbervalueFactory- ifget(Object)returnsnull, this factory is used to create a short or throw a factory- Returns:
short valueofNumbervalue at given key or created value by your valueFactory ifget(Object)returnednull.- Throws:
E- may be thrown by yourValueFactory
-
getNumberAsInt
default <E extends Exception> int getNumberAsInt(@NotNull K key, @NotNull @NotNull ValueFactory<K, Integer, throws EE> valueFactory) - Type Parameters:
E- factory that may be thrown by yourValueFactory- Parameters:
key- the key for the entry which should be of typeNumbervalueFactory- ifget(Object)returnsnull, this factory is used to create an int or throw a factory- Returns:
int valueofNumbervalue at given key or created value by your valueFactory ifget(Object)returnednull.- Throws:
E- may be thrown by yourValueFactory
-
getNumberAsLong
default <E extends Exception> long getNumberAsLong(@NotNull K key, @NotNull @NotNull ValueFactory<K, Long, throws EE> valueFactory) - Type Parameters:
E- factory that may be thrown by yourValueFactory- Parameters:
key- the key for the entry which should be of typeNumbervalueFactory- ifget(Object)returnsnull, this factory is used to create an int or throw a factory- Returns:
long valueofNumbervalue at given key or created value by your valueFactory ifget(Object)returnednull.- Throws:
E- may be thrown by yourValueFactory
-
getNumberAsFloat
default <E extends Exception> float getNumberAsFloat(@NotNull K key, @NotNull @NotNull ValueFactory<K, Float, throws EE> valueFactory) - Type Parameters:
E- factory that may be thrown by yourValueFactory- Parameters:
key- the key for the entry which should be of typeNumbervalueFactory- ifget(Object)returnsnull, this factory is used to create a float or throw a factory- Returns:
float valueofNumbervalue at given key or created value by your valueFactory ifget(Object)returnednull.- Throws:
E- may be thrown by yourValueFactory
-
getNumberAsDouble
default <E extends Exception> double getNumberAsDouble(@NotNull K key, @NotNull @NotNull ValueFactory<K, Double, throws EE> valueFactory) - Type Parameters:
E- factory that may be thrown by yourValueFactory- Parameters:
key- the key for the entry which should be of typeNumbervalueFactory- ifget(Object)returnsnull, this factory is used to create a double or throw a factory- Returns:
double valueofNumbervalue at given key or created value by your valueFactory ifget(Object)returnednull.- Throws:
E- may be thrown by yourValueFactory
-
getList
- Parameters:
key- the key for the entry, whose value is of typeListofObject- Returns:
ListofObject- Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeListofObject
-
getList
@Contract("_, !null -> !null") @Nullable default @Nullable List<Object> getList(@NotNull K key, @Nullable @Nullable List<Object> defaultList) - Parameters:
key- the key for the entry, whose value is of typeListofObject- Returns:
ListofObjector defaultList ifget(Object)for given key returnsnull- Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeListofObject
-
getListAndConvert
@Nullable default <C,R> @Nullable ArrayList<R> getListAndConvert(@NotNull K key, @NotNull @NotNull Converter<C, R> converter) - Type Parameters:
C- type which all elements of the implementations returned bygetList(Object)will be cast toR- result type- Parameters:
key- the key for the entry, whose value is of typeListofObjectconverter- to convert fromvalue contained in the implementationsto theresult type- Returns:
ArrayListofAbstractDataornullifgetList(Object)with given key returnsnull- Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeListofObjectClassCastException- if the elements of the implementations returned bygetList(Object)with given key cannot be cast toAbstractData
-
getListAndConvertWithException
@Nullable default <C,R, @Nullable ArrayList<R> getListAndConvertWithExceptionE extends Throwable> (@NotNull K key, @NotNull @NotNull ExceptionConverter<C, R, throws EE> converter) - Type Parameters:
C- type which all elements of the implementations returned bygetList(Object)will be cast toR- result type- Parameters:
key- the key for the entry, whose value is of typeListofObjectconverter- to convert fromvalue contained in the implementationsto theresult type- Returns:
ArrayListofAbstractDataornullifgetList(Object)with given key returnsnull- Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeListofObjectClassCastException- if the elements of the implementations returned bygetList(Object)with given key cannot be cast toAbstractDataE- if the functions throws this exception
-
getListAndConvertAndFreeMemory
@Nullable default <C,R> @Nullable ArrayList<R> getListAndConvertAndFreeMemory(@NotNull K key, @NotNull @NotNull Converter<C, R> converter) Each element from the implementations - returned by
getList(Object)with given key - will be set tonull, after it has been converted and stored in the implementations that will be returned. After every element of the former implementations has been converted,List.clear()will be called.- Type Parameters:
C- type which all elements of the implementations returned bygetList(Object)will be cast toR- result type- Parameters:
key- the key for the entry, whose value is of typeListofObjectconverter- to convert fromvalue contained in the implementationsto theresult type- Returns:
ArrayListofAbstractDataornullifgetList(Object)with given key returnsnull- Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeListofObjectClassCastException- if the elements of the implementations returned bygetList(Object)with given key cannot be cast toAbstractData
-
getListAndConvertWithExceptionAndFreeMemory
@Nullable default <C,R, @Nullable ArrayList<R> getListAndConvertWithExceptionAndFreeMemoryE extends Throwable> (@NotNull K key, @NotNull @NotNull ExceptionConverter<C, R, throws EE> converter) Each element from the implementations - returned by
getList(Object)with given key - will be set tonull, after it has been converted and stored in the implementations that will be returned. After every element of the former implementations has been converted,List.clear()will be called.- Type Parameters:
C- type which all elements of the implementations returned bygetList(Object)will be cast toR- result type- Parameters:
key- the key for the entry, whose value is of typeListofObjectconverter- to convert fromvalue contained in the implementationsto theresult type- Returns:
ArrayListofAbstractDataornullifgetList(Object)with given key returnsnull- Throws:
ClassCastException- if the value returned byget(Object)with given key is not of typeListofObjectClassCastException- if the elements of the implementations returned bygetList(Object)with given key cannot be cast toAbstractDataE- if given converter throws an exception (ExceptionConverter.convert(Object))
-
processIfContained
default <C extends V> boolean processIfContained(@NotNull K key, @NotNull @NotNull Consumer<C> consumer) If an entry with given key exists, it will be processed by given consumer and
truewill be returned.
If an entry with given key does not exists,falsewill be returned.
- Type Parameters:
C- type to cast to- Parameters:
key- the key for the entryconsumer- consumer to process the entry, if it exists- Returns:
trueif an entry with given key exists,falseotherwise- Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractData- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
The entry's value may still benull. To assure non-null values useprocessIfNotNull(Object, Consumer).
-
convertAndProcessIfContained
default <C extends V,R> boolean convertAndProcessIfContained(@NotNull K key, @NotNull @NotNull Converter<C, R> converter, @NotNull @NotNull Consumer<R> consumer) If an entry with given key exists, it will be
convertedby givenconverter, then processed by givenconsumerandtruewill be returned.
If an entry with given key does not exists,falsewill be returned.
- Type Parameters:
C- type to cast to.R- type to convert to.- Parameters:
key- the keyAbstractDatafor the entry.converter- to convert fromAbstractDatatoAbstractData.consumer- consumer to process the entry, if it exists.- Returns:
trueif an entry with given key exists,falseotherwise.- Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractData.- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
The entry's value may still benull. To assure non-null values useprocessIfNotNull(Object, Consumer).
-
convertWithExceptionAndProcessIfContained
default <C extends V,R, boolean convertWithExceptionAndProcessIfContainedE extends Throwable> (@NotNull K key, @NotNull @NotNull ExceptionConverter<C, R, throws EE> converter, @NotNull @NotNull Consumer<R> consumer) If an entry with given key exists, it will be
convertedby givenconverter, then processed by givenconsumerandtruewill be returned.
If an entry with given key does not exists,falsewill be returned.
- Type Parameters:
C- type to cast to.R- type to convert to.E- exception your converter can throw.- Parameters:
key- the keyAbstractDatafor the entry.converter- to convert fromAbstractDatatoAbstractData.consumer- consumer to process the entry, if it exists.- Returns:
trueif an entry with given key exists,falseotherwise.- Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractData.E- if yourExceptionConverterthrows this exception.- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
The entry's value may still benull. To assure non-null values useprocessIfNotNull(Object, Consumer).
-
processListIfContained
default boolean processListIfContained(@NotNull K key, @NotNull @NotNull Consumer<List<Object>> consumer) If an entry with key exists, it will be cast to a
Listand then processed by givenconsumerandtruewill be returned.- Parameters:
key- the keyAbstractDatafor the entry.consumer- consumer to process the entry, if it exists.- Returns:
trueif an entry with given key exists,falseotherwise.- Throws:
ClassCastException- if the value of the entry with given key is not aList.- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
The entry's value may still benull. To assure non-null values useprocessIfNotNull(Object, Consumer).
-
convertAndProcessListIfContained
default <C,R> boolean convertAndProcessListIfContained(@NotNull K key, @NotNull @NotNull Converter<C, R> converter, @NotNull @NotNull Consumer<List<R>> consumer) If an entry with given
keyexists, it will be cast to aListand every element cast toAbstractDataconvertedtoAbstractData. All elements will be added to a newList, which will then be processed by givenconsumerandtruewill be returned.- Parameters:
key- the keyAbstractDatafor the entry.converter-Converterto convert fromAbstractDatatoAbstractDataconsumer- consumer to process the entry, if it exists.- Returns:
trueif an entry with given key exists,falseotherwise.- Throws:
ClassCastException- if the value of the entry with given key is not aListor if any element inside the list is not of typeAbstractData.- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
The entry's value may still benull. To assure non-null values useprocessIfNotNull(Object, Consumer).
-
convertWithExceptionAndProcessListIfContained
default <C,R, boolean convertWithExceptionAndProcessListIfContainedE extends Throwable> (@NotNull K key, @NotNull @NotNull ExceptionConverter<C, R, throws EE> converter, @NotNull @NotNull Consumer<List<R>> consumer) If an entry with given
keyexists, it will be cast to aListand every element cast toAbstractDataconvertedtoAbstractData. All elements will be added to a newList, which will then be processed by givenconsumerandtruewill be returned.- Parameters:
key- the keyAbstractDatafor the entry.converter-ExceptionConverterto convert fromAbstractDatatoAbstractDataconsumer- consumer to process the entry, if it exists.- Returns:
trueif an entry with given key exists,falseotherwise.- Throws:
ClassCastException- if the value of the entry with given key is not aListor if any element inside the list is not of typeAbstractData.E extends Throwable- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
The entry's value may still benull. To assure non-null values useprocessIfNotNull(Object, Consumer).
-
processIfContainedAndRequireNotNull
default <C extends V,E extends Throwable> boolean processIfContainedAndRequireNotNull(@NotNull K key, @NotNull @NotNull Consumer<C> consumer, ExceptionSupplier<K, AbstractData<K, throws EV>, E> exceptionSupplier) -
If an entry with given key exists and it's value is not
null, it will be processed by given consumer andtruewill be returned. -
If an entry with given key exists and it's value is
null, the exceptionAbstractDatasupplied by yourExceptionSupplierwill be thrown. -
If an entry with given key does not exists,
falsewill be returned.
- Type Parameters:
C- type to cast to- Parameters:
key- the key for the entryconsumer- consumer to process the entry, if it existsexceptionSupplier-ExceptionSuppliersupplies aThrowableifget(Object)with given key returnsnull.- Returns:
trueif an entry with given key exists,falseotherwise- Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractDataE- if an entry with given key exists, and its value isnull.- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
ifget(Object)returnsnull,Converter.convert(Object)will not be called. So it is safe for yourConverterto assume not-null values.
-
If an entry with given key exists and it's value is not
-
convertAndProcessIfContainedAndRequireNotNull
default <C extends V,R, boolean convertAndProcessIfContainedAndRequireNotNullE extends Throwable> (@NotNull K key, Converter<C, R> converter, @NotNull @NotNull Consumer<R> consumer, ExceptionSupplier<K, throws EAbstractData<K, V>, E> exceptionSupplier) -
If an entry with given key exists and it's value is not
null, it will be cast toAbstractData, converted toAbstractDataand then processed by given consumer andtruewill be returned. -
If an entry with given key exists and it's value is
null, the exceptionAbstractDatasupplied by yourExceptionSupplierwill be thrown. -
If an entry with given key does not exists,
falsewill be returned.
- Type Parameters:
C- type to cast to- Parameters:
key- the key for the entryconverter-Converterto convert fromAbstractDatatoAbstractData.consumer- consumer to process the entry, if it existsexceptionSupplier-ExceptionSuppliersupplies aThrowableifget(Object)with given key returnsnull.- Returns:
trueif an entry with given key exists,falseotherwise- Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractDataE- if an entry with given key exists, and its value isnull.- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
ifget(Object)returnsnull,Converter.convert(Object)will not be called. So it is safe for yourConverterto assume not-null values.
-
If an entry with given key exists and it's value is not
-
convertWithExceptionAndProcessIfContainedAndRequireNotNull
default <C extends V,R, boolean convertWithExceptionAndProcessIfContainedAndRequireNotNullE extends Throwable, F extends Throwable> (@NotNull K key, ExceptionConverter<C, R, throws E, FF> converter, @NotNull @NotNull Consumer<R> consumer, ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) -
If an entry with given key exists and it's value is not
null, it will be cast toAbstractData, converted toAbstractDataand then processed by given consumer andtruewill be returned. -
If an entry with given key exists and it's value is
null, the exceptionAbstractDatasupplied by yourExceptionSupplierwill be thrown. -
If an entry with given key does not exists,
falsewill be returned.
- Type Parameters:
C- type to cast to.E- exception supplied by yourExceptionSupplier.R- type to convert to.F- exception thrown by yourExceptionConverter.- Parameters:
key- the key for the entryconverter-ExceptionConverterto convert fromAbstractDatatoAbstractData.consumer- consumer to process the entry, if it existsexceptionSupplier-ExceptionSuppliersupplies aThrowableifget(Object)with given key returnsnull.- Returns:
trueif an entry with given key exists,falseotherwise- Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractDataE- if an entry with given key exists, and its value isnull.F- if yourconverterthrows this exception- Implementation Note:
- The entry will NOT be removed from this
AbstractData.
ifget(Object)returnsnull,Converter.convert(Object)will not be called. So it is safe for yourConverterto assume not-null values.
-
If an entry with given key exists and it's value is not
-
processIfNotNull
default <C extends V> boolean processIfNotNull(@NotNull K key, @NotNull @NotNull Consumer<C> consumer) - Type Parameters:
C- type to cast to- Parameters:
key- the key for the entryconsumer- consumer to process the entry, if it exists, and it's value is notnull.- Returns:
trueif an entry with given key exists, and it's value is notnull.falseotherwise- Throws:
ClassCastException- if the value of the entry with given key is not of typeAbstractData
-
getAndRequireNotNull
@NotNull default <E extends Throwable> @NotNull Object getAndRequireNotNull(@NotNull K key, @NotNull @NotNull ExceptionSupplier<K, AbstractData<K, throws EV>, E> exceptionSupplier) Getsthe value with given key and returns it, if the value is notnull. If the value isnull,AbstractDatasupplied by yourExceptionSupplierwill be thrown.- Type Parameters:
E- TheThrowableto be thrown ifget(Object)with given key returnsnull.- Parameters:
key-AbstractDatakeyexceptionSupplier-ExceptionSuppliersupplies aThrowableifget(Object)with given key returnsnull.- Returns:
valuereturned byget(Object). Nevernull.- Throws:
E- ifget(Object)with given key returnsnull.
-
getAsAndRequireNotNull
@NotNull default <C extends V,E extends Throwable> C getAsAndRequireNotNull(@NotNull K key, @NotNull @NotNull ExceptionSupplier<K, AbstractData<K, throws EV>, E> exceptionSupplier) Getsthe value with given key, casts it toAbstractDataand returns it, if the value is notnull. If the value isnull,AbstractDatasupplied by yourExceptionSupplierwill be thrown.- Type Parameters:
C- The class to cast to.E- TheThrowableto be thrown ifget(Object)with given key returnsnull.- Parameters:
key-AbstractDatakeyexceptionSupplier-ExceptionSuppliersupplies aThrowableifget(Object)with given key returnsnull.- Returns:
valuecast toAbstractDatareturned byget(Object). Nevernull.- Throws:
E- ifget(Object)with given key returnsnull.ClassCastException- if the value returned byget(Object)with given key is not of typeAbstractData.
-
getAndRequireNotNullAndConvert
@NotNull default <C extends V,R, R getAndRequireNotNullAndConvertE extends Throwable> (@NotNull K key, @NotNull @NotNull Converter<C, R> converter, @NotNull @NotNull ExceptionSupplier<K, throws EAbstractData<K, V>, E> exceptionSupplier) Getsthe value with given key and casts it toAbstractData. If the value is notnullit will beconvertedtoAbstractDataand then returned. If the value isnull,AbstractDatasupplied by yourExceptionSupplierwill be thrown.Note: if
get(Object)returnsnull,Converter.convert(Object)will not be called. So it is safe for yourConverterto assume not-null values.- Type Parameters:
C- The class to cast to.E- TheThrowableto be thrown ifget(Object)with given key returnsnull.R- The class toconvertto.- Parameters:
key-AbstractDatakeyexceptionSupplier-ExceptionSuppliersupplies aThrowableifget(Object)with given key returnsnull.converter-Converterto convert fromAbstractDatatoAbstractData.- Returns:
valuecast toAbstractDatareturned byget(Object). Nevernull.- Throws:
E- ifget(Object)with given key returnsnull.ClassCastException- if the value returned byget(Object)with given key is not of typeAbstractData.
-
getAndRequireNotNullAndConvertWithException
@NotNull default <C extends V,R, R getAndRequireNotNullAndConvertWithExceptionE extends Throwable, F extends Throwable> (@NotNull K key, @NotNull @NotNull ExceptionConverter<C, R, throws E, FF> converter, @NotNull @NotNull ExceptionSupplier<K, AbstractData<K, V>, E> exceptionSupplier) Getsthe value with given key and casts it toAbstractData. If the value is notnullit will beconvertedtoAbstractDataand then returned. If the value isnull,AbstractDatasupplied by yourExceptionSupplierwill be thrown.- Type Parameters:
C- The class to cast to.E- TheThrowableto be thrown ifget(Object)with given key returnsnull.F- TheThrowablewhich yourExceptionConvertercan throw.R- The class toconvertto.- Parameters:
key-AbstractDatakeyexceptionSupplier-ExceptionSuppliersupplies aThrowableifget(Object)with given key returnsnull.converter-ExceptionConverterto convert fromAbstractDatatoAbstractData.- Returns:
valuecast toAbstractDatareturned byget(Object). Nevernull.- Throws:
E- ifget(Object)with given key returnsnull.ClassCastException- if the value returned byget(Object)with given key is not of typeAbstractData.F- if yourExceptionConverterthrows this exception.- Implementation Note:
- if
get(Object)returnsnull,ExceptionConverter.convert(Object)will not be called. So it is safe for yourExceptionConverterto assume not-null values.
-
toRecord
Converts thisAbstractDatato givenrecordClass. This conversion supports all primitive types,Stringand records.- Type Parameters:
T- record class- Parameters:
recordClass- the class to the recordAbstractData.- Returns:
- record
AbstractDatafilled by thisAbstractData.
-
isEmpty
boolean isEmpty()- Returns:
trueif this data does not contain any entries,falseotherwise
-
size
int size()- Returns:
- current amount of
entriescontained.
-
toJsonString
Writes thisAbstractDatato aStringBuilder.- Returns:
StringBuilder
-
getParseType
How thisAbstractDatashould be parsed- Returns:
ParseType
-
getData
-