From 8a371eebf930951af9f8a714142697dc5fbef80f Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Tue, 2 Mar 2010 05:38:35 +0000 Subject: [PATCH] Since I ended up naming the little protected helper method "toIntFlag", let's have it go ahead and return a flag rather than the bit position. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2752 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/ByteEnumUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/java/com/samskivert/util/ByteEnumUtil.java b/src/java/com/samskivert/util/ByteEnumUtil.java index fdd8a723..4d4c9884 100644 --- a/src/java/com/samskivert/util/ByteEnumUtil.java +++ b/src/java/com/samskivert/util/ByteEnumUtil.java @@ -52,7 +52,7 @@ public class ByteEnumUtil { int flags = 0; for (E value : set) { - flags |= (1 << toIntFlag(value)); + flags |= toIntFlag(value); } return flags; } @@ -64,7 +64,7 @@ public class ByteEnumUtil { EnumSet set = EnumSet.noneOf(eclass); for (E value : eclass.getEnumConstants()) { - if ((flags & (1 << toIntFlag(value))) != 0) { + if ((flags & toIntFlag(value)) != 0) { set.add(value); } } @@ -75,7 +75,7 @@ public class ByteEnumUtil * A helper function for setToInt() and intToSet() that validates that the specified * ByteEnum value is not null and has a code between 0 and 31, inclusive. */ - protected static & ByteEnum> byte toIntFlag (E value) + protected static & ByteEnum> int toIntFlag (E value) { byte code = value.toByte(); // allow this to throw NPE if (code < 0 || code > 31) { @@ -83,7 +83,7 @@ public class ByteEnumUtil "ByteEnum code is outside the range that can be turned into an int " + "[value=" + value + ", code=" + code + "]"); } - return code; + return (1 << code); } // TODO: setToByteArray() and byteArrayToSet(), for larger ByteEnums?