|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.floodlightcontroller.util.EnumBitmaps
public class EnumBitmaps
A utility class to convert between integer based bitmaps for (OpenFlow)
flags and Enum and EnumSet based representations.
The enum used to represent individual flags needs to implement the
BitmapableEnum interface.
Example:
int bitmap = 0x11; // OFPPC_PORT_DOWN | OFPPC_NO_STP
EnumSet<OFPortConfig> s = toEnumSet(OFPortConfig.class, bitmap);
// s will contain OFPPC_PORT_DOWN and OFPPC_NO_STP
EnumSet<OFPortConfig> s = EnumSet.of(OFPPC_NO_STP, OFPPC_PORT_DOWN);
int bitmap = toBitmap(s); // returns 0x11
Nested Class Summary | |
---|---|
static interface |
EnumBitmaps.BitmapableEnum
Enums used to represent individual flags needs to implement this interface |
Constructor Summary | |
---|---|
EnumBitmaps()
|
Method Summary | ||
---|---|---|
static
|
getMask(java.lang.Class<E> type)
Return the bitmap mask with all possible bits set. |
|
static
|
toBitmap(java.util.Set<E> set)
Convert the given EnumSet to the integer bitmap representation |
|
static
|
toEnumSet(java.lang.Class<E> type,
int bitmap)
Convert an integer bitmap to an EnumSet. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EnumBitmaps()
Method Detail |
---|
public static <E extends java.lang.Enum<E> & EnumBitmaps.BitmapableEnum> java.util.EnumSet<E> toEnumSet(java.lang.Class<E> type, int bitmap)
type
- The Enum class to use. Must implement BitmapableEnumbitmap
- The integer bitmap
java.lang.NullPointerException
- if type is null
java.lang.IllegalArgumentException
- if any enum constant from type has
more than one bit set.
java.lang.IllegalArgumentException
- if the bitmap has any bits set not
represented by an enum constant.public static <E extends java.lang.Enum<E> & EnumBitmaps.BitmapableEnum> int getMask(java.lang.Class<E> type)
type
- The Enum class to use. Must implement BitmapableEnum
java.lang.NullPointerException
- if type is null
java.lang.IllegalArgumentException
- if any enum constant from type has
more than one bit setpublic static <E extends java.lang.Enum<E> & EnumBitmaps.BitmapableEnum> int toBitmap(java.util.Set<E> set)
set
- The EnumSet to convert. The enum must implement
BitmapableEnum
java.lang.IllegalArgumentException
- if an enum constant from the set (!) has
more than one bit set
java.lang.NullPointerException
- if the set is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |