code: public static int getPrecisionFormat(@Nonnull final String mapcode) throws UnknownPrecisionFormatException {
  
          // First, decode to ASCII.
          final String decodedMapcode = convertStringToPlainAscii(mapcode).toUpperCase();
  
          // Syntax needs to be OK.
          if (!PATTERN_MAPCODE.matcher(decodedMapcode).matches()) {
              throw new UnknownPrecisionFormatException(decodedMapcode + " is not a correctly formatted mapcode code; " +
                      "the regular expression for the mapcode code syntax is: " + REGEX_MAPCODE);
          }
  
          // Precision part should be OK.
          final Matcher matcherPrecision = PATTERN_PRECISION.matcher(decodedMapcode);
          if (!matcherPrecision.find()) {
              return 0;
          }
          final int length = matcherPrecision.end() - matcherPrecision.start() - 1;
          assert (1 <= length) && (length <= 8);
          return length;
      }
docs: This method return the mapcode type, given a mapcode string. If the mapcode string has an invalid
  format, an exception is thrown.
  
  Note that this method only checks the syntactic validity of the mapcode, the string format. It does not
  check if the mapcode is really a valid mapcode representing a position on Earth.
  
  @param mapcode Mapcode (optionally with a territory).
  @return Type of mapcode code format.
  @throws UnknownPrecisionFormatException If precision format is incorrect.