aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/desugar/io/BitFlags.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/desugar/io/BitFlags.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/desugar/io/BitFlags.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/io/BitFlags.java b/src/tools/android/java/com/google/devtools/build/android/desugar/io/BitFlags.java
new file mode 100644
index 0000000000..af6f48130e
--- /dev/null
+++ b/src/tools/android/java/com/google/devtools/build/android/desugar/io/BitFlags.java
@@ -0,0 +1,51 @@
+// Copyright 2016 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.android.desugar.io;
+
+import org.objectweb.asm.Opcodes;
+
+/** Convenience method for working with {@code int} bitwise flags. */
+public class BitFlags {
+
+ /**
+ * Returns {@code true} iff <b>all</b> bits in {@code bitmask} are set in {@code flags}. Trivially
+ * returns {@code true} if {@code bitmask} is 0.
+ */
+ public static boolean isSet(int flags, int bitmask) {
+ return (flags & bitmask) == bitmask;
+ }
+
+ /**
+ * Returns {@code true} iff <b>none</b> of the bits in {@code bitmask} are set in {@code flags}.
+ * Trivially returns {@code true} if {@code bitmask} is 0.
+ */
+ public static boolean noneSet(int flags, int bitmask) {
+ return (flags & bitmask) == 0;
+ }
+
+ public static boolean isInterface(int access) {
+ return isSet(access, Opcodes.ACC_INTERFACE);
+ }
+
+ public static boolean isStatic(int access) {
+ return isSet(access, Opcodes.ACC_STATIC);
+ }
+
+ public static boolean isSynthetic(int access) {
+ return isSet(access, Opcodes.ACC_SYNTHETIC);
+ }
+
+ // Static methods only
+ private BitFlags() {}
+}