Examples of MetaMethod


Examples of groovy.lang.MetaMethod

      argTypes[i++] = arg == null ? null : arg.getClass();
    }

    MetaClass metaClass = target instanceof Class ? InvokerHelper.getMetaClass((Class) target) : InvokerHelper.getMetaClass(target);

    MetaMethod metaMethod = metaClass.pickMethod(method, argTypes);
    if (metaMethod == null) {
      return false;
    }

    Class returnType = metaMethod.getReturnType();
    return returnType == void.class || returnType == Void.class;
  }
View Full Code Here

Examples of org.adoptopenjdk.jitwatch.model.MetaMethod

  @Test
  public void testSourceSignatureRegExMatcher()
  {
    // single primitive param, void return
    Method m = getMethod("java.lang.AbstractStringBuilder", "ensureCapacity", new Class<?>[] { int.class });
    MetaMethod method = new MetaMethod(m, null);
    String sourceSig = "public void ensureCapacity(int foo)";
    Matcher matcher = Pattern.compile(method.getSignatureRegEx()).matcher(sourceSig);
    boolean match = matcher.find();
    assertTrue(match);

    // 2 primitive params,void return
    Method m2 = getMethod("java.lang.AbstractStringBuilder", "setCharAt", new Class<?>[] { int.class, char.class });
    MetaMethod method2 = new MetaMethod(m2, null);
    String sourceSig2 = "public void setCharAt(int foo, char bar)";
    Matcher matcher2 = Pattern.compile(method2.getSignatureRegEx()).matcher(sourceSig2);
    boolean match2 = matcher2.find();
    assertTrue(match2);

    // Object param and return type
    Method m3 = getMethod("java.lang.AbstractStringBuilder", "append", new Class<?>[] { java.lang.String.class });
    MetaMethod methodFQ = new MetaMethod(m3, null);
    String sourceSigFQ = "public AbstractStringBuilder append(String foo)";
    Matcher matcherFQ = Pattern.compile(methodFQ.getSignatureRegEx()).matcher(sourceSigFQ);
    boolean matchFQ = matcherFQ.find();
    assertTrue(matchFQ);

    // constructor with primitive params
    Constructor<?> c1 = getConstructor("java.lang.AbstractStringBuilder", new Class<?>[] { int.class });
    MetaConstructor con1 = new MetaConstructor(c1, null);
    String sourceSigC1 = "AbstractStringBuilder(int foo)";
    Matcher matcherC1 = Pattern.compile(con1.getSignatureRegEx()).matcher(sourceSigC1);
    boolean matchC1 = matcherC1.find();
    assertTrue(matchC1);

    // array return type, no params
    Method m4 = getMethod("java.lang.AbstractStringBuilder", "getValue", new Class<?>[0]);
    MetaMethod method4 = new MetaMethod(m4, null);
    String sourceSig4 = "final char[] getValue()";
    Matcher matcher4 = Pattern.compile(method4.getSignatureRegEx()).matcher(sourceSig4);
    boolean match4 = matcher4.find();
    assertTrue(match4);

    // array param and object return type
    Method m5 = getMethod("java.lang.AbstractStringBuilder", "append", new Class<?>[] { char[].class });
    MetaMethod method5 = new MetaMethod(m5, null);
    String sourceSig5 = "public AbstractStringBuilder append(char[] foo)";
    Matcher matcher5 = Pattern.compile(method5.getSignatureRegEx()).matcher(sourceSig5);
    boolean match5 = matcher5.find();
    assertTrue(match5);
  }
View Full Code Here

Examples of org.apache.bval.model.MetaMethod

            }
            if (annotationIgnores.isIgnoreAnnotationOnReturn(method) && methodDesc.getReturnValueDescriptor() != null) {
                methodDesc.setReturnValueDescriptor(null);
            }

            final MetaMethod metaMethod = metaBean.getMethod(method);
            if (metaMethod != null) {
                for (final Annotation anno : metaMethod.getAnnotations()) {
                    if (anno instanceof Valid) {
                        methodDesc.setCascaded(true);
                    } else {
                        // set first param as null to force it to be read
                        processAnnotations(null, methodDesc, method.getReturnType(), anno);
                    }
                }

                // parameter validations
                final Collection<MetaParameter> paramsAnnos = metaMethod.getParameters();
                final List<String> names = factoryContext.getParameterNameProvider().getParameterNames(method);
                for (final MetaParameter paramAnnos : paramsAnnos) {
                    final int idx = paramAnnos.getIndex();
                    final ParameterAccess access = new ParameterAccess(method.getParameterTypes()[idx], idx);
                    processAnnotations(methodDesc, paramAnnos.getAnnotations(), access, idx, names.get(idx));
View Full Code Here

Examples of org.jboss.errai.codegen.framework.meta.MetaMethod

      }
    }
  }
 
  public static MetaMethod findGetterMethod(MetaClass cls, String key) {
    MetaMethod metaMethod = _findGetterMethod("get", cls, key);
    if (metaMethod != null) return metaMethod;
    metaMethod = _findGetterMethod("is", cls, key);
     return metaMethod;
  }
View Full Code Here

Examples of org.jboss.errai.codegen.framework.meta.MetaMethod

  public MetaClassMember getReadingMember() {
    if (readingMember != null) {
    return readingMember;
    }
   
    MetaMethod meth = toMap.getMethod(getterMethod, new MetaClass[0]);

    meth.asMethod().setAccessible(true);

    readingMember = meth;

    if (readingMember == null) {
      throw new RuntimeException("no such getter method: " + toMap.getFullyQualifiedName() + "." + getterMethod);
View Full Code Here

Examples of org.jboss.errai.codegen.framework.meta.MetaMethod

  public MetaClassMember getBindingMember() {
    if (bindingMember != null) {
      return bindingMember;
    }

    MetaMethod meth = toMap.getMethod(setterMethod, targetType);

    meth.asMethod().setAccessible(true);

    bindingMember = meth;

    if (bindingMember == null) {
      throw new RuntimeException("no such setter method: " + toMap.getFullyQualifiedName() + "." + setterMethod);
View Full Code Here

Examples of org.jboss.errai.codegen.framework.meta.MetaMethod

  public MetaClassMember getReadingMember() {
    if (readingMember != null) {
      return readingMember;
    }

    MetaMethod meth = toMap.getMethod(getterMethod, new MetaClass[0]);

    meth.asMethod().setAccessible(true);
   
    readingMember = meth;
   
    if (readingMember == null) {
      throw new RuntimeException("no such getter method: " + toMap.getFullyQualifiedName() + "." + getterMethod);
View Full Code Here

Examples of org.jboss.errai.codegen.meta.MetaMethod

    if (javaMember instanceof Field) {
      MetaField field = MetaClassFactory.get((Field) javaMember);
      return field.isAnnotationPresent(GeneratedValue.class);
    }
    else if (javaMember instanceof Method) {
      MetaMethod method = MetaClassFactory.get((Method) javaMember);
      return method.isAnnotationPresent(GeneratedValue.class);
    }
    throw new IllegalArgumentException("Given member is a "
        + javaMember.getClass().getName()
        + " but JPA attributes can only be a Field or a Method.");
  }
View Full Code Here

Examples of org.jboss.errai.codegen.meta.MetaMethod

    if (javaMember instanceof Field) {
      MetaField field = MetaClassFactory.get((Field) javaMember);
      return field.isAnnotationPresent(GeneratedValue.class);
    }
    else if (javaMember instanceof Method) {
      MetaMethod method = MetaClassFactory.get((Method) javaMember);
      return method.isAnnotationPresent(GeneratedValue.class);
    }
    throw new IllegalArgumentException("Given member is a "
            + javaMember.getClass().getName()
            + " but JPA attributes can only be a Field or a Method.");
  }
View Full Code Here

Examples of org.jboss.errai.codegen.meta.MetaMethod

            if (field.isPublic()) {
              tryBuilder.append(loadVariable("entity").loadField(field.getName()).assignValue(val));
              continue;
            }
            else {
              final MetaMethod setterMeth = GenUtil.findCaseInsensitiveMatch(null,
                      field.getDeclaringClass(), "set" + field.getName(),
                      field.getType());

              if (setterMeth != null && !setterMeth.isPrivate()) {
                // Bind via setter
                bindingStatement =
                    loadVariable("entity").invoke(setterMeth, Cast.to(memberMapping.getTargetType(), val));
              }
              else if (field.getType().getCanonicalName().equals("long")) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.