Here you can find the source of enumSetOf(long bitSet, Class
public static <E extends Enum<E>> EnumSet<E> enumSetOf(long bitSet, Class<E> eClass)
//package com.java2s; //License from project: Apache License import java.util.EnumSet; public class Main { public static final long EMPTY_BIT_SET = 0L; public static <E extends Enum<E>> EnumSet<E> enumSetOf(long bitSet, Class<E> eClass) { if (bitSet == EMPTY_BIT_SET) { return EnumSet.noneOf(eClass); }/* w ww .j av a2 s. c om*/ EnumSet<E> flagSet = EnumSet.noneOf(eClass); for (E f : eClass.getEnumConstants()) { if (hasEnum(bitSet, f)) { flagSet.add(f); } } return flagSet; } public static boolean hasEnum(long bitSet, Enum<?> anEnum) { return (bitSet & (1 << anEnum.ordinal())) != 0; } }