docs: public boolean matches(final String path, final Map<String, String> pathParameters) {
  
          if (!template && base.contains("*")) {
              final int indexOf = base.indexOf("*");
              final String startBase = base.substring(0, indexOf);
              if (!path.startsWith(startBase)) {
                  return false;
              }
              pathParameters.put("*", path.substring(indexOf,path.length()));
              return true;
          }
  
  
          if (!path.startsWith(base)) {
              return false;
          }
          int baseLength = base.length();
          if (!template) {
              return path.length() == baseLength;
          }
          if(trailingSlash) {
              //the template has a trailing slash
              //we verify this first as it is cheap
              //and it simplifies the matching algorithm below
              if(path.charAt(path.length() -1 ) != '/') {
                  return false;
              }
          }
  
          int currentPartPosition = 0;
          PathTemplate.Part current = parts.get(currentPartPosition);
          int stringStart = baseLength;
          int i;
          for (i = baseLength; i < path.length(); ++i) {
              final char currentChar = path.charAt(i);
              if (currentChar == '?' || current.part.equals("*")) {
                  break;
              } else if (currentChar == '/') {
                  String result = path.substring(stringStart, i);
                  if (current.template) {
                      pathParameters.put(current.part, result);
                  } else if (!result.equals(current.part)) {
                      pathParameters.clear();
                      return false;
                  }
                  ++currentPartPosition;
                  if (currentPartPosition == parts.size()) {
                      //this is a match if this is the last character
                      return i == (path.length() - 1);
                  }
                  current = parts.get(currentPartPosition);
                  stringStart = i + 1;
              }
          }
          if (currentPartPosition + 1 != parts.size()) {
              pathParameters.clear();
              return false;
          }
  
          String result = path.substring(stringStart, i);
          if (current.part.equals("*")) {
              pathParameters.put(current.part, path.substring(stringStart,path.length()));
              return true;
          }
          if (current.template) {
              pathParameters.put(current.part, result);
          } else if (!result.equals(current.part)) {
              pathParameters.clear();
              return false;
          }
          return true;
      }