Package com.sinch.sdk.core.utils
Class EnumSupportDynamic<T,E extends EnumDynamic<T,E>>
java.lang.Object
com.sinch.sdk.core.utils.EnumSupportDynamic<T,E>
- Type Parameters:
T
- Value type associated to dynamic enumE
- Dynamic enum class instance
Utility class to manage extendable enumeration set
Used to define a known set of value but enable to extend it dynamically
Typical use case: being able to send and/or receive values not yet defined at SDK version release
- Since:
- 1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Compare two dynamic enumGet a dynamic enum from valuefromValues
(Collection<T> values) Get List of enum from Collection and create undefined Enum from the Collection if requiredReturns the value used to create the enumvalues()
Get known valuesvaluesOf
(Collection<E> values) Transform Collection to List
-
Constructor Details
-
EnumSupportDynamic
Create a new instance of managing a dynamic enum- Parameters:
aClass
- Related class stored with dynamic enum supportsurplusFactory
- Factory T function to create a new dynamic enum valuevalues
- Values managed/stored by dynamic enum class- Since:
- 1.0
-
-
Method Details
-
values
Get known values- Returns:
- Stream of values
- Since:
- 1.0
-
valueOf
Returns the value used to create the enum- Parameters:
e
- the enum- Returns:
- Value associated to enum onto creation
-
valuesOf
Transform Collection to List- Parameters:
values
- Collection of values to be transformed- Returns:
- Created List
-
fromValues
Get List of enum from Collection and create undefined Enum from the Collection if required- Parameters:
values
- Collection of values to be used to fill returned List- Returns:
- List of enum related to source Collection
-
from
Get a dynamic enum from valueIf no dynamic enum was already created with
value
param, a new value is created and returned- Parameters:
value
- Value to be associated to newly create element- Returns:
- Dynamic enum
-
compare
Compare two dynamic enum- Parameters:
o1
- the first object to compareo2
- the second object to compare- Returns:
- the value 0 if o1 == o2& a value less than 0 if o1 < o2; and a value greater than 0 if o1 > o2
-