Пример #1
0
  /**
   * Loads the specified entity parameter according to the method signature override.
   *
   * @param signatureOverride The signature override.
   * @return The resource entity parameter.
   */
  protected ResourceEntityParameter loadEntityParameter(ResourceMethodSignature signatureOverride) {
    try {
      Class<?> entityType = signatureOverride.input();
      if (entityType != ResourceMethodSignature.NONE.class) {
        AnnotationProcessorEnvironment env = net.sf.jelly.apt.Context.getCurrentEnvironment();
        TypeDeclaration type = env.getTypeDeclaration(entityType.getName());
        return new ResourceEntityParameter(type, env.getTypeUtils().getDeclaredType(type));
      }
    } catch (MirroredTypeException e) {
      DecoratedTypeMirror typeMirror =
          (DecoratedTypeMirror) TypeMirrorDecorator.decorate(e.getTypeMirror());
      if (typeMirror.isDeclared()) {
        if (typeMirror.isInstanceOf(ResourceMethodSignature.class.getName() + ".NONE")) {
          return null;
        } else {
          return new ResourceEntityParameter(
              ((DeclaredType) typeMirror).getDeclaration(), typeMirror);
        }
      } else {
        throw new ValidationException(
            getPosition(), "Illegal input type (must be a declared type): " + typeMirror);
      }
    }

    return null;
  }