Effective Java! Use EnumSet Instead of Bit Fields

Sometimes when we have an enumerated type that is primarily used in sets developers will set each value as an int or long with each being a different power of two. Something like the following:

public class TextStyles {
public static final int STYLE_BOLD = 1 << 0; // 1
public static final int STYLE_ITALIC = 1 << 1; // 2
public static final int STYLE_UNDERLINE = 1 << 2; // 4
public static final int STYLE_STRIKETHROUGH = 1 << 3; // 8
public void applyStyles(int styles) { ... }
}