In C, I sometimes used structures such as
enum {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
typedef NSUInteger UIViewAutoresizing;
Is there any Java equivalent?
Use EnumSet.
Excerpt from the Link above which qualifies as example:
package resolver; import java.util.EnumSet; public class EnumPatternExample { public enum Style { BOLD, ITALIC, UNDERLINE, STRIKETHROUGH } public static void main(String[] args) { final EnumSet<Style> styles = EnumSet.noneOf(Style.class); styles.addAll(EnumSet.range(Style.BOLD, Style.STRIKETHROUGH)); // enable all constants styles.removeAll(EnumSet.of(Style.UNDERLINE, Style.STRIKETHROUGH)); // disable a couple assert EnumSet.of(Style.BOLD, Style.ITALIC).equals(styles); // check set contents are correct System.out.println(styles); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With