code: public static int setPublic(int modifier, boolean b) {
          if (b) {
              return (modifier | PUBLIC) & (~PROTECTED & ~PRIVATE);
          }
          else {
              return modifier & ~PUBLIC;
          }
      }
docs: When set public, the modifier is cleared from being private or
  protected.