code: public static String flagsToString(short flags) {
          StringBuilder sb=new StringBuilder();
          boolean first=true;
  
          Flag[] all_flags=Flag.values();
          for(Flag flag: all_flags) {
              if(isFlagSet(flags, flag)) {
                  if(first)
                      first=false;
                  else
                      sb.append("|");
                  sb.append(flag);
              }
          }
          return sb.toString();
      }
docs: /* ----------------------------------- Private methods -------------------------------