• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Bazel Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 package com.google.devtools.build.android.desugar;
15 
16 /**
17  * Convenience method for working with {@code int} bitwise flags.
18  */
19 class BitFlags {
20 
21   /**
22    * Returns {@code true} iff <b>all</b> bits in {@code bitmask} are set in {@code flags}.
23    * Trivially returns {@code true} if {@code bitmask} is 0.
24    */
isSet(int flags, int bitmask)25   public static boolean isSet(int flags, int bitmask) {
26     return (flags & bitmask) == bitmask;
27   }
28 
29   /**
30    * Returns {@code true} iff <b>none</b> of the bits in {@code bitmask} are set in {@code flags}.
31    * Trivially returns {@code true} if {@code bitmask} is 0.
32    */
noneSet(int flags, int bitmask)33   public static boolean noneSet(int flags, int bitmask) {
34     return (flags & bitmask) == 0;
35   }
36 
37   // Static methods only
BitFlags()38   private BitFlags() {}
39 }
40