Package

macrame

enums

Permalink

package enums

Visibility
  1. Public
  2. All

Type Members

  1. trait All[Enum] extends StringConverters[Enum] with NumericConverters[Enum] with OrderedModular[Enum]

    Permalink

    This traits provides *all* of the auto-generated functions in EnumApi.

    This traits provides *all* of the auto-generated functions in EnumApi. It is rare that one actually needs all such functions and it is recommended that you use a smaller subset of these functions as provided by the other traits in the macrame.enums namespace.

  2. trait AsInt[Enum] extends AnyRef

    Permalink

    This trait provides conversion from an enumeration to Int.

    This trait provides conversion from an enumeration to Int. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends AsInt[Color]

    This enables the following two ways to convert Color to a Int.

    Red.asInt
    Color.asInt(Red) // returns 0
  3. trait AsLong[Enum] extends AnyRef

    Permalink

    This trait provides conversion from an enumeration to Long.

    This trait provides conversion from an enumeration to Long. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends AsLong[Color]

    This enables the following two ways to convert Color to a Long.

    Red.asLong
    Color.asLong(Red) // returns 0l
  4. trait AsShort[Enum] extends AnyRef

    Permalink

    This trait provides conversion from an enumeration to Short.

    This trait provides conversion from an enumeration to Short. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends AsShort[Color]

    This enables the following two ways to convert Color to a Short.

    Red.asShort
    Color.asShort(Red) // returns 0
  5. trait AsString[Enum] extends AnyRef

    Permalink

    This trait provides conversion from an enumeration to String.

    This trait provides conversion from an enumeration to String. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends AsString[Color]

    This enables the following two ways to convert Color to a String.

    Red.asString
    Color.asString(Red) // returns "Red"
  6. trait FromInt[Enum] extends AnyRef

    Permalink

    This trait provides conversion from Int to an enumeration.

    This trait provides conversion from Int to an enumeration. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends FromInt[Color]

    This creates the following function to convert Int to Option[Color].

    Color.fromInt(0) // returns Some(Red)
  7. trait FromLong[Enum] extends AnyRef

    Permalink

    This trait provides conversion from Long to an enumeration.

    This trait provides conversion from Long to an enumeration. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends FromLong[Color]

    This creates the following function to convert Long to Option[Color].

    Color.fromLong(0l) // returns Some(Red)
  8. trait FromShort[Enum] extends AnyRef

    Permalink

    This trait provides conversion from Short to an enumeration.

    This trait provides conversion from Short to an enumeration. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends FromShort[Color]

    This creates the following function to convert Short to Option[Color].

    Color.fromShort(0 : Short) // returns Some(Red)
  9. trait FromString[Enum] extends AnyRef

    Permalink

    This trait provides conversion from String to an enumeration.

    This trait provides conversion from String to an enumeration. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends FromString[Color]

    This creates the following function to convert String to Option[Color].

    Color.fromString("Red") // returns Some(Red)
  10. trait IntConverters[Enum] extends AsInt[Enum] with FromInt[Enum]

    Permalink

    This trait provides the Int/Enum conversions from AsInt and FromInt.

    This trait provides the Int/Enum conversions from AsInt and FromInt. As with those traits you must extend the companion object of the enumeration.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends IntConverters[Color]
  11. trait LongConverters[Enum] extends AsLong[Enum] with FromLong[Enum]

    Permalink

    This trait provides the Long/Enum conversions from AsLong and FromLong.

    This trait provides the Long/Enum conversions from AsLong and FromLong. As with those traits you must extend the companion object of the enumeration.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends LongConverters[Color]
  12. trait NumericConverters[Enum] extends LongConverters[Enum] with ShortConverters[Enum] with IntConverters[Enum]

    Permalink

    This trait provides the numeric/enumeration conversions from IntConverters, ShortConverters, and LongConverters.

    This trait provides the numeric/enumeration conversions from IntConverters, ShortConverters, and LongConverters. As with those traits you must extend the companion object of the enumeration.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends NumericConverters[Color]
  13. trait Ordered[Enum] extends AnyRef

    Permalink

    This trait provides an Ordering instance for an enumeration as well as functions which use that order.

    This trait provides an Ordering instance for an enumeration as well as functions which use that order. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends Ordered[Color]

    This enables the following functions (and more).

    Red < Blue // true
    Blue.next
    Color.next(Blue) // yellow
    Yellow >= Yellow // true
    Color.first // Red
    Color.last // Yellow
  14. trait OrderedModular[Enum] extends Ordered[Enum]

    Permalink

    This traits provides the same interface as Ordered as well as the modular ordering functions.

    This traits provides the same interface as Ordered as well as the modular ordering functions. As with that trait it works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends OrderedModular[Color]

    This enables the following functions.

    Red.prevMod
    Color.prevMod(Red) // Yellow
    Yellow.nextMod
    Color.nextMod(Yellow) // Red
  15. trait ShortConverters[Enum] extends AsShort[Enum] with FromShort[Enum]

    Permalink

    This trait provides the Short/Enum conversions from AsShort and FromShort.

    This trait provides the Short/Enum conversions from AsShort and FromShort. As with those traits you must extend the companion object of the enumeration.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends ShortConverters[Color]
  16. trait StringConverters[Enum] extends AsString[Enum] with FromString[Enum]

    Permalink

    This trait provides the String/Enum conversions from AsString and FromString.

    This trait provides the String/Enum conversions from AsString and FromString. As with those traits you must extend the companion object of the enumeration.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends StringConverters[Color]

Ungrouped