com.nativelibs4java.util
Class EnumValues

java.lang.Object
  extended by com.nativelibs4java.util.EnumValues

public class EnumValues
extends Object

Methods to ease conversion between EnumValue-annotated enums and their integer value.

Author:
ochafik

Constructor Summary
EnumValues()
           
 
Method Summary
static
<E extends Enum<E>>
E
getEnum(long value, Class<E> enumClass)
          Get the first enum item in enum class E which EnumValue value is equal to value
static
<E extends Enum<E>>
EnumSet<E>
getEnumSet(long value, Class<E> enumClass)
          Get the set of all the enum item in enum class E which EnumValue value flags are all present in value
static
<E extends Enum<?>>
long
getValue(E enumItem)
          Get the integer value associated with an enum item
static
<E extends Enum<E>>
long
getValue(EnumSet<E> set)
          Get the integer value resulting from ORing all the values of all the enum items present in the enum set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumValues

public EnumValues()
Method Detail

getEnum

public static <E extends Enum<E>> E getEnum(long value,
                                            Class<E> enumClass)
Get the first enum item in enum class E which EnumValue value is equal to value

Type Parameters:
E - type of the enum
Parameters:
value -
enumClass -
Returns:
first enum item with matching value, null if there is no matching enum item

getEnumSet

public static <E extends Enum<E>> EnumSet<E> getEnumSet(long value,
                                                        Class<E> enumClass)
Get the set of all the enum item in enum class E which EnumValue value flags are all present in value

Type Parameters:
E - type of the enum
Parameters:
value -
enumClass -
Returns:
enum items with matching value flags

getValue

public static <E extends Enum<?>> long getValue(E enumItem)
Get the integer value associated with an enum item

Parameters:
enumItem -
Returns:
the numeric value of the enum
See Also:
EnumValue

getValue

public static <E extends Enum<E>> long getValue(EnumSet<E> set)
Get the integer value resulting from ORing all the values of all the enum items present in the enum set.

Parameters:
set - the EnumSet to process
Returns:
the OR of all the values of the enums in the set
See Also:
getValue(java.lang.Enum), EnumValue


Copyright © 2009-2013. All Rights Reserved.