예제 #1
0
 private String addMethodPathComponent(
     ExecutableElement executableElement, TypeElement cls, String path, RequestMapping anno) {
   if (anno == null) {
     throw new IllegalArgumentException(
         String.format(
             "Method %s should have Request mapping annotation",
             executableElement.getSimpleName()));
   }
   if (anno.value() != null && anno.value().length > 0) {
     return Utils.joinPaths(path, anno.value()[0]);
   }
   return path;
 }
예제 #2
0
  private String getClassLevelUrlPath(TypeElement cls) {
    RestApiMountPoint mountPoint = cls.getAnnotation(RestApiMountPoint.class);
    String path = mountPoint == null ? "/" : mountPoint.value();

    RequestMapping clsAnno = cls.getAnnotation(RequestMapping.class);
    if (clsAnno == null || clsAnno.value().length == 0) {
      return path;
    } else if (clsAnno.value().length == 1) {
      return Utils.joinPaths(path, clsAnno.value()[0]);
    } else {
      throw new IllegalStateException(
          String.format(
              "The RequestMapping annotation of class %s has multiple value strings. Only zero or one value is supported",
              cls.getQualifiedName()));
    }
  }