Package 

Class EnumUtilsKt

    • Method Summary

      Modifier and Type Method Description
      final static <E extends Enum<E>> E valueOf(String name, Boolean ignoreCase)
      final static <E extends Enum<E>> E valueOf(String name, Function0<Object> error)
      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.
      final static <E extends Enum<E>> Boolean or(E $self, Enum<E> type)
      final static <E extends Enum<E>> Boolean and(E $self, Enum<E> type)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 mapping
        mapper - The function to map by.