package enums
Type Members
- trait All[E] extends StringConverters[E] with NumericConverters[E] with OrderedModular[E]
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 themacrame.enums
namespace. - trait AsInt[E] extends AnyRef
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 aInt
.Red.asInt Color.asInt(Red) // returns 0
- trait AsLong[E] extends AnyRef
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 aLong
.Red.asLong Color.asLong(Red) // returns 0L
- trait AsShort[E] extends AnyRef
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 aShort
.Red.asShort Color.asShort(Red) // returns 0
- trait AsString[E] extends AnyRef
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 aString
.Red.asString Color.asString(Red) // returns "Red"
- trait FromInt[E] extends AnyRef
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
toOption[Color].
Color.fromInt(0) // returns Some(Red)
- trait FromLong[E] extends AnyRef
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
toOption[Color].
Color.fromLong(0L) // returns Some(Red)
- trait FromShort[E] extends AnyRef
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
toOption[Color].
Color.fromShort(0 : Short) // returns Some(Red)
- trait FromString[E] extends AnyRef
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
toOption[Color].
Color.fromString("Red") // returns Some(Red)
- trait IntConverters[E] extends AsInt[E] with FromInt[E]
This trait provides the
Int
/E
conversions fromAsInt
andFromInt
.This trait provides the
Int
/E
conversions fromAsInt
andFromInt
. As with those traits you must extend the companion object of the enumeration.@enum class Color { Red Blue Yellow } object Color extends IntConverters[Color]
- trait LongConverters[E] extends AsLong[E] with FromLong[E]
This trait provides the
Long
/E
conversions fromAsLong
andFromLong
.This trait provides the
Long
/E
conversions fromAsLong
andFromLong
. As with those traits you must extend the companion object of the enumeration.@enum class Color { Red Blue Yellow } object Color extends LongConverters[Color]
- trait NumericConverters[E] extends LongConverters[E] with ShortConverters[E] with IntConverters[E]
This trait provides the numeric/enumeration conversions from
IntConverters
,ShortConverters
, andLongConverters
.This trait provides the numeric/enumeration conversions from
IntConverters
,ShortConverters
, andLongConverters
. As with those traits you must extend the companion object of the enumeration.@enum class Color { Red Blue Yellow } object Color extends NumericConverters[Color]
- trait Ordered[E] extends AnyRef
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
- trait OrderedModular[E] extends Ordered[E]
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
- trait ShortConverters[E] extends AsShort[E] with FromShort[E]
This trait provides the
Short
/E
conversions fromAsShort
andFromShort
.This trait provides the
Short
/E
conversions fromAsShort
andFromShort
. As with those traits you must extend the companion object of the enumeration.@enum class Color { Red Blue Yellow } object Color extends ShortConverters[Color]
- trait StringConverters[E] extends AsString[E] with FromString[E]
This trait provides the
String
/E
conversions fromAsString
andFromString
.This trait provides the
String
/E
conversions fromAsString
andFromString
. As with those traits you must extend the companion object of the enumeration.@enum class Color { Red Blue Yellow } object Color extends StringConverters[Color]