Java tutorial
//package com.java2s; //License from project: Apache License import java.util.EnumSet; public class Main { private static <T extends Enum<T>> int enumSetToBitwise(EnumSet<T> enumSet) { int bitwise = 0; for (Enum<T> enumValue : enumSet) { bitwise += (int) Math.pow(2, enumValue.ordinal()); } return bitwise; } }