Пример #1
0
 public static String createCallSignature(MetaMethod m) {
   StringAppender append = new StringAppender(m.getName()).append(':');
   for (MetaParameter parm : m.getParameters()) {
     append.append(parm.getType().getCanonicalName()).append(':');
   }
   return append.toString();
 }
Пример #2
0
  public static Statement generateProxyMethodReturnStatement(MetaMethod method) {
    Statement returnStatement = null;
    if (!method.getReturnType().equals(MetaClassFactory.get(void.class))) {

      // if it's a Number and not a BigDecimal or BigInteger
      if (MetaClassFactory.get(Number.class).isAssignableFrom(method.getReturnType().asBoxed())
          && method.getReturnType().asUnboxed().getFullyQualifiedName().indexOf('.') == -1) {

        if (MetaClassFactory.get(Double.class).isAssignableFrom(method.getReturnType().asBoxed())) {
          returnStatement = Stmt.load(0.0).returnValue();
        } else if (MetaClassFactory.get(Float.class)
            .isAssignableFrom(method.getReturnType().asBoxed())) {
          returnStatement = Stmt.load(0f).returnValue();
        } else if (MetaClassFactory.get(Long.class)
            .isAssignableFrom(method.getReturnType().asBoxed())) {
          returnStatement = Stmt.load(0l).returnValue();
        } else {
          returnStatement = Stmt.load(0).returnValue();
        }
      } else if (MetaClassFactory.get(char.class).equals(method.getReturnType())) {
        returnStatement = Stmt.load(0).returnValue();
      } else if (MetaClassFactory.get(Boolean.class)
          .isAssignableFrom(method.getReturnType().asBoxed())) {
        returnStatement = Stmt.load(false).returnValue();
      } else {
        returnStatement = Stmt.load(null).returnValue();
      }
    }
    return returnStatement;
  }
Пример #3
0
  /**
   * Generates HTTP headers based on the JAX-RS annotations on the provided method.
   *
   * @param clazz the JAX-RS resource class
   * @return headers
   */
  public static JaxrsHeaders fromMethod(MetaMethod method) {
    JaxrsHeaders headers = new JaxrsHeaders();

    Produces p = method.getAnnotation(Produces.class);
    if (p != null) {
      headers.setAcceptHeader(p.value());
    }

    Consumes c = method.getAnnotation(Consumes.class);
    if (c != null) {
      headers.setContentTypeHeader(c.value());
    }

    return headers;
  }