org.jboss.errai.codegen.meta.MetaClass.getDeclaredMethods()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.jboss.errai.codegen.meta.MetaClass.getDeclaredMethods()方法的一些代码示例,展示了MetaClass.getDeclaredMethods()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.getDeclaredMethods()方法的具体详情如下:
包路径:org.jboss.errai.codegen.meta.MetaClass
类名称:MetaClass
方法名:getDeclaredMethods

MetaClass.getDeclaredMethods介绍

暂无

代码示例

代码示例来源:origin: org.jboss.errai/errai-bus

@Override
 public Collection<MetaClass> provideTypesToExpose() {
  final Set<MetaClass> types = new HashSet<MetaClass>();
  for (final MetaClass metaClass : ClassScanner.getTypesAnnotatedWith(Remote.class)) {
   for (final MetaMethod method : metaClass.getDeclaredMethods()) {
    if (!method.getReturnType().isVoid()) {
     types.add(method.getReturnType().getErased());
    }
    for (final MetaParameter parameter : method.getParameters()) {
     final MetaClass type = parameter.getType();

     types.add(type.getErased());

     final MetaParameterizedType parameterizedType = type.getParameterizedType();
     if (parameterizedType != null) {
      for (final MetaType tp : parameterizedType.getTypeParameters()) {
        if (tp instanceof MetaClass) {
         types.add(((MetaClass) tp).getErased());
        }
      }
     }

    }
   }
  }
  return types;
 }
}

代码示例来源:origin: errai/errai

private static MetaMethod _findGetterMethod(final String prefix, final MetaClass cls, String key) {
 key = (prefix + key).toUpperCase();
 for (final MetaMethod m : cls.getDeclaredMethods()) {
  if (m.getName().toUpperCase().equals(key) && m.getParameters().length == 0) {
   return m;
  }
 }
 return null;
}

代码示例来源:origin: org.jboss.errai/errai-marshalling

private static MetaMethod _findGetterMethod(final String prefix, final MetaClass cls, String key) {
 key = (prefix + key).toUpperCase();
 for (final MetaMethod m : cls.getDeclaredMethods()) {
  if (m.getName().toUpperCase().equals(key) && m.getParameters().length == 0) {
   return m;
  }
 }
 return null;
}

代码示例来源:origin: errai/errai

@Override
public List<MetaMethod> getMethodsWithMetaAnnotations(final Class<? extends Annotation> annotation) {
 final List<MetaMethod> methods = new ArrayList<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaMethod m : scanTarget.getDeclaredMethods()) {
   for (final Annotation a : m.getAnnotations()) {
    if (_findMetaAnnotation(a.annotationType(), annotation)) {
     methods.add(m);
    }
   }
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return methods;
}

代码示例来源:origin: org.jboss.errai/errai-codegen

@Override
public final List<MetaMethod> getMethodsAnnotatedWith(final Class<? extends Annotation> annotation) {
 final Map<String, List<MetaMethod>> methodsByName = new HashMap<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaMethod m : scanTarget.getDeclaredMethods()) {
   if (m.isAnnotationPresent(annotation)) {
    final List<MetaMethod> methods = methodsByName.computeIfAbsent(m.getName(), k -> new ArrayList<>());
    if (isNotOverriden(m, methods)) {
     methods.add(m);
    }
   }
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return Collections
     .unmodifiableList(methodsByName
         .values()
         .stream()
         .flatMap(list -> list.stream())
         .collect(Collectors.toList()));
}

代码示例来源:origin: org.jboss.errai/errai-codegen

@Override
public List<MetaMethod> getMethodsWithMetaAnnotations(final Class<? extends Annotation> annotation) {
 final List<MetaMethod> methods = new ArrayList<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaMethod m : scanTarget.getDeclaredMethods()) {
   for (final Annotation a : m.getAnnotations()) {
    if (_findMetaAnnotation(a.annotationType(), annotation)) {
     methods.add(m);
    }
   }
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return methods;
}

代码示例来源:origin: errai/errai

@Override
public final List<MetaMethod> getMethodsAnnotatedWith(final Class<? extends Annotation> annotation) {
 final Map<String, List<MetaMethod>> methodsByName = new HashMap<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaMethod m : scanTarget.getDeclaredMethods()) {
   if (m.isAnnotationPresent(annotation)) {
    final List<MetaMethod> methods = methodsByName.computeIfAbsent(m.getName(), k -> new ArrayList<>());
    if (isNotOverriden(m, methods)) {
     methods.add(m);
    }
   }
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return Collections
     .unmodifiableList(methodsByName
         .values()
         .stream()
         .flatMap(list -> list.stream())
         .collect(Collectors.toList()));
}

代码示例来源:origin: errai/errai

@Override
public List<MetaParameter> getParametersAnnotatedWith(final Class<? extends Annotation> annotation) {
 final List<MetaParameter> methods = new ArrayList<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaConstructor m : scanTarget.getDeclaredConstructors()) {
   methods.addAll(m.getParametersAnnotatedWith(annotation));
  }
  for (final MetaMethod m : scanTarget.getDeclaredMethods()) {
   methods.addAll(m.getParametersAnnotatedWith(annotation));
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return methods;
}

代码示例来源:origin: errai/errai

public static Collection<MetaMethod> getNonBindingAttributes(final MetaClass annoClass) {
 return filterAnnotationMethods(Arrays.stream(annoClass.getDeclaredMethods()),
     method -> method.isAnnotationPresent(Nonbinding.class) && method.isPublic()
         && !method.getName().equals("equals") && !method.getName().equals("hashCode"));
}

代码示例来源:origin: org.jboss.errai/errai-codegen

public static Collection<MetaMethod> getNonBindingAttributes(final MetaClass annoClass) {
 return filterAnnotationMethods(Arrays.stream(annoClass.getDeclaredMethods()),
     method -> method.isAnnotationPresent(Nonbinding.class) && method.isPublic()
         && !method.getName().equals("equals") && !method.getName().equals("hashCode"));
}

代码示例来源:origin: org.jboss.errai/errai-codegen

@Override
public List<MetaParameter> getParametersAnnotatedWith(final Class<? extends Annotation> annotation) {
 final List<MetaParameter> methods = new ArrayList<>();
 MetaClass scanTarget = this;
 while (scanTarget != null) {
  for (final MetaConstructor m : scanTarget.getDeclaredConstructors()) {
   methods.addAll(m.getParametersAnnotatedWith(annotation));
  }
  for (final MetaMethod m : scanTarget.getDeclaredMethods()) {
   methods.addAll(m.getParametersAnnotatedWith(annotation));
  }
  scanTarget = scanTarget.getSuperClass();
 }
 return methods;
}

代码示例来源:origin: errai/errai

public static Collection<MetaMethod> getAnnotationAttributes(final MetaClass annoClass) {
 return filterAnnotationMethods(Arrays.stream(annoClass.getDeclaredMethods()),
     method -> !method.isAnnotationPresent(Nonbinding.class) && method.isPublic()
         && !method.getName().equals("equals") && !method.getName().equals("hashCode"));
}

代码示例来源:origin: org.jboss.errai/errai-codegen

public static Collection<MetaMethod> getAnnotationAttributes(final MetaClass annoClass) {
 return filterAnnotationMethods(Arrays.stream(annoClass.getDeclaredMethods()),
     method -> !method.isAnnotationPresent(Nonbinding.class) && method.isPublic()
         && !method.getName().equals("equals") && !method.getName().equals("hashCode"));
}

代码示例来源:origin: org.jboss.errai/errai-codegen

/**
 * Checks is the given {@link MetaMethod} is in scope (part of the attached class contexts).
 *
 * @param method
 *     the method to check.
 *
 * @return true if in scope, otherwise false.
 */
public boolean isInScope(final MetaMethod method) {
 checkThread();
 Context c = this;
 do {
  for (final MetaClass clazz : c.classContexts) {
   for (final MetaMethod m : clazz.getDeclaredMethods()) {
    if (m.equals(method))
     return true;
   }
  }
 }
 while ((c = c.parent) != null);
 return false;
}

代码示例来源:origin: errai/errai

/**
 * Checks is the given {@link MetaMethod} is in scope (part of the attached class contexts).
 *
 * @param method
 *     the method to check.
 *
 * @return true if in scope, otherwise false.
 */
public boolean isInScope(final MetaMethod method) {
 checkThread();
 Context c = this;
 do {
  for (final MetaClass clazz : c.classContexts) {
   for (final MetaMethod m : clazz.getDeclaredMethods()) {
    if (m.equals(method))
     return true;
   }
  }
 }
 while ((c = c.parent) != null);
 return false;
}

代码示例来源:origin: errai/errai

for (final MetaMethod metaMethod : metaClass.getDeclaredMethods()) {
 if (metaMethod.isAnnotationPresent(annotation)) {
  result.add(metaMethod);
for (final MetaMethod metaMethod : metaClass.getDeclaredMethods()) {
 if (metaMethod.isAnnotationPresent(annotation)) {
  result.add(metaMethod);

代码示例来源:origin: errai/errai

@Override
 public Collection<MetaClass> provideTypesToExpose() {
  final Set<MetaClass> types = new HashSet<MetaClass>();
  for (final MetaClass metaClass : ClassScanner.getTypesAnnotatedWith(Remote.class)) {
   for (final MetaMethod method : metaClass.getDeclaredMethods()) {
    if (!method.getReturnType().isVoid()) {
     types.add(method.getReturnType().getErased());
    }
    for (final MetaParameter parameter : method.getParameters()) {
     final MetaClass type = parameter.getType();

     types.add(type.getErased());

     final MetaParameterizedType parameterizedType = type.getParameterizedType();
     if (parameterizedType != null) {
      for (final MetaType tp : parameterizedType.getTypeParameters()) {
        if (tp instanceof MetaClass) {
         types.add(((MetaClass) tp).getErased());
        }
      }
     }

    }
   }
  }
  return types;
 }
}

代码示例来源:origin: errai/errai

public static MetaMethod findCaseInsensitiveMatch(final MetaClass retType,
                         final MetaClass clazz,
                         final String name,
                         final MetaClass... parms) {
 MetaClass c = clazz;
 do {
  Outer:
  for (final MetaMethod method : c.getDeclaredMethods()) {
   if (name.equalsIgnoreCase(method.getName())) {
    if (parms.length != method.getParameters().length) continue;
    final MetaParameter[] mps = method.getParameters();
    for (int i = 0; i < parms.length; i++) {
     if (!parms[i].getFullyQualifiedName().equals(mps[i].getType().getFullyQualifiedName())) {
      continue Outer;
     }
    }
    if (retType != null
      && !retType.getFullyQualifiedName().equals(method.getReturnType().getFullyQualifiedName())) {
     continue;
    }
    return method;
   }
  }
 }
 while ((c = c.getSuperClass()) != null);
 return null;
}

代码示例来源:origin: org.jboss.errai/errai-codegen

public static MetaMethod findCaseInsensitiveMatch(final MetaClass retType,
                         final MetaClass clazz,
                         final String name,
                         final MetaClass... parms) {
 MetaClass c = clazz;
 do {
  Outer:
  for (final MetaMethod method : c.getDeclaredMethods()) {
   if (name.equalsIgnoreCase(method.getName())) {
    if (parms.length != method.getParameters().length) continue;
    final MetaParameter[] mps = method.getParameters();
    for (int i = 0; i < parms.length; i++) {
     if (!parms[i].getFullyQualifiedName().equals(mps[i].getType().getFullyQualifiedName())) {
      continue Outer;
     }
    }
    if (retType != null
      && !retType.getFullyQualifiedName().equals(method.getReturnType().getFullyQualifiedName())) {
     continue;
    }
    return method;
   }
  }
 }
 while ((c = c.getSuperClass()) != null);
 return null;
}

代码示例来源:origin: errai/errai

private ObjectBuilder createAnnoImpl(final MetaClass annoType) {
 final AnonymousClassStructureBuilder builder = ObjectBuilder.newInstanceOf(annoType).extend();
 Arrays.stream(annoType.getDeclaredMethods())
    .forEach(m -> builder.publicOverridesMethod(m.getName())
        .append(castTo(m.getReturnType(), loadVariable("parameters").invoke("get", m.getName())).returnValue()).finish());
 builder.publicOverridesMethod("annotationType").append(loadLiteral(annoType).returnValue()).finish();
 return builder.finish();
}

相关文章