-
public final class EnumUtilsKt
-
-
Method Summary
Modifier and Type Method Description final static <E extends Enum<E>> EvalueOf(String name, Boolean ignoreCase)final static <E extends Enum<E>> EvalueOf(String name, Function0<Object> error)final static <E extends Enum<E>, K extends Any> EvalueOf(K key, Function2<K, E, Boolean> mapper)Attempts to find the value of the generified enum given a key, K, and a function to map Enum types to the given key. final static <E extends Enum<E>> Booleanor(E $self, Enum<E> type)final static <E extends Enum<E>> Booleanand(E $self, Enum<E> type)-
-
Method Detail
-
valueOf
final static <E extends Enum<E>, K extends Any> E valueOf(K key, Function2<K, E, Boolean> mapper)
Attempts to find the value of the generified enum given a key, K, and a function to map Enum types to the given key. When the first successful match of the mapper is found this function will return. If no match is found null is returned.
Example usage:
enum class YourEnum( val name: String ) { VALUE_ONE("Bob"), ...; } ... val myEnum = valueOf<YourEnum>("bOB") { bob : String, enumValue : YourEnum-> enumValue.name.equals(bob, ignoreCase = true) } assertNotNull(myEnum) { "Bob not found?!" }- Parameters:
key- The key to look for when mappingmapper- The function to map by.
-
-
-
-