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

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

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

MetaClass.getMethods介绍

[英]Returns all declared and inherited public, protected, and package-private methods available on this class.
[中]返回该类上可用的所有已声明和继承的public、protected和package private方法。

代码示例

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

public ClassStructureBuilder<?> generate() {
 final String safeProxyClassName = remote.getFullyQualifiedName().replace('.', '_') + "Impl";
 final ClassStructureBuilder<?> classBuilder =
  ClassBuilder.define(safeProxyClassName, AbstractRpcProxy.class)
   .packageScope()
   .implementsInterface(remote)
   .body();
 for (final MetaMethod method : remote.getMethods()) {
  if (ProxyUtil.shouldProxyMethod(method)) {
   generateMethod(classBuilder, method);
  }
 }
 return classBuilder;
}

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

for (final MetaMethod method : enclosingType.getMethods()) {
 for (final MetaParameter param : method.getParameters()) {
  if (param.isAnnotationPresent(annoType)) {

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

private Collection<MetaMethod> getAllDisposesMethods(final MetaClass type, final boolean staticOnly) {
 final Collection<MetaMethod> disposers = new ArrayList<>();
 for (final MetaMethod method : type.getMethods()) {
  if (staticOnly && !method.isStatic()) {
   continue;
  }
  final List<MetaParameter> disposerParams = method.getParametersAnnotatedWith(Disposes.class);
  if (disposerParams.size() > 1) {
   throw new RuntimeException("Found method " + method + " in " + method.getDeclaringClassName()
       + " with multiple @Disposes parameters.");
  } else if (disposerParams.size() == 1) {
   disposers.add(method);
  }
 }
 return disposers;
}

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

for (final MetaMethod method : enclosingType.getMethods()) {
 for (final MetaParameter param : method.getParameters()) {
  if (param.isAnnotationPresent(annoType)) {

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

/**
 * Callback interface for providing custom method bodies in snapshots. There are three major use cases:
 * <ol>
 *  <li>To implement methods that take parameters (snapshots of
 *      these methods cannot be generated automatically)
 *  <li>To return a reference to some object that's already in the
 *      scope of the snapshot (such as a reference to a parent object
 *      from a getParent() method)
 *  <li>To implement additional methods in the case that the snapshot
 *      type is not the same as the type to extend.
 * </ol>
 *
 * @author Jonathan Fuerth <jfuerth@gmail.com>
 */
public interface MethodBodyCallback {
 /**
  * Optionally returns the statement that should be used as the body of the
  * given method for the given object's snapshot. If the default snapshot
  * behaviour provided by SnapshotMaker is sufficient for the given method,
  * this callback can simply return null.
  *
  * @param method
  *          The method to provide the body for.
  * @param o
  *          The instance object that we are taking the snapshot of. You can
  *          use this reference if you need to invoke {@code method}.
  * @param containingClass
  *          The class that will contain the generated method. During the
  *          callback, you can generate additional methods and fields within

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

/**
 * Callback interface for providing custom method bodies in snapshots. There are three major use cases:
 * <ol>
 *  <li>To implement methods that take parameters (snapshots of
 *      these methods cannot be generated automatically)
 *  <li>To return a reference to some object that's already in the
 *      scope of the snapshot (such as a reference to a parent object
 *      from a getParent() method)
 *  <li>To implement additional methods in the case that the snapshot
 *      type is not the same as the type to extend.
 * </ol>
 *
 * @author Jonathan Fuerth <jfuerth@gmail.com>
 */
public interface MethodBodyCallback {
 /**
  * Optionally returns the statement that should be used as the body of the
  * given method for the given object's snapshot. If the default snapshot
  * behaviour provided by SnapshotMaker is sufficient for the given method,
  * this callback can simply return null.
  *
  * @param method
  *          The method to provide the body for.
  * @param o
  *          The instance object that we are taking the snapshot of. You can
  *          use this reference if you need to invoke {@code method}.
  * @param containingClass
  *          The class that will contain the generated method. During the
  *          callback, you can generate additional methods and fields within

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

@Override
public MetaMethod[] getMethods() {
 if (_methodsCache != null) return _methodsCache;
 final MetaMethod[] methodArray = methods.toArray(new MetaMethod[methods.size()]);
 final MetaMethod[] outputMethods;
 if (superClass != null) {
  final List<MetaMethod> methodList = new ArrayList<>();
  for (final MetaMethod m : superClass.getMethods()) {
   if (_getMethod(methodArray, m.getName(), GenUtil.fromParameters(m.getParameters())) == null) {
    methodList.add(m);
   }
  }
  methodList.addAll(Arrays.asList(methodArray));
  outputMethods = methodList.toArray(new MetaMethod[methodList.size()]);
 }
 else {
  outputMethods = methodArray;
 }
 return _methodsCache = outputMethods;
}

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

@Override
public MetaMethod[] getMethods() {
 if (_methodsCache != null) return _methodsCache;
 final MetaMethod[] methodArray = methods.toArray(new MetaMethod[methods.size()]);
 final MetaMethod[] outputMethods;
 if (superClass != null) {
  final List<MetaMethod> methodList = new ArrayList<>();
  for (final MetaMethod m : superClass.getMethods()) {
   if (_getMethod(methodArray, m.getName(), GenUtil.fromParameters(m.getParameters())) == null) {
    methodList.add(m);
   }
  }
  methodList.addAll(Arrays.asList(methodArray));
  outputMethods = methodList.toArray(new MetaMethod[methodList.size()]);
 }
 else {
  outputMethods = methodArray;
 }
 return _methodsCache = outputMethods;
}

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

for (final MetaMethod ifaceMethod : Arrays.asList(JavaReflectionClass.newInstance(interfaceType).getMethods())) {
 final String readableMethodDecl = GenUtil.getMethodString(ifaceMethod);
 if (!processedMethods.contains(readableMethodDecl)) {

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

for (final MetaMethod ifaceMethod : Arrays.asList(JavaReflectionClass.newInstance(interfaceType).getMethods())) {
 final String readableMethodDecl = GenUtil.getMethodString(ifaceMethod);
 if (!processedMethods.contains(readableMethodDecl)) {

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

for (final MetaMethod ifaceMethod : Arrays.asList(GWTClass.newInstance(oracle, interfaceType).getMethods())) {
 final String readableMethodDecl = GenUtil.getMethodString(ifaceMethod);
 if (!processedMethods.contains(readableMethodDecl)) {

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

for (final MetaMethod ifaceMethod : Arrays.asList(GWTClass.newInstance(oracle, interfaceType).getMethods())) {
 final String readableMethodDecl = GenUtil.getMethodString(ifaceMethod);
 if (!processedMethods.contains(readableMethodDecl)) {

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

private ObjectBuilder createAnonymousImpl(final MetaClass type) {
 final AnonymousClassStructureBuilder builder = newObject(type).extend();
 stream(type.getMethods())
  .filter(m -> m.isPublic() && m.isAbstract())
  .forEach(m -> {
   builder
    .publicOverridesMethod(m.getName(), of(m.getParameters()))
    .append(Stmt.throw_(RuntimeException.class))
    .finish();
  });
 return builder.finish();
}

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

@Test
public void testNoDuplicateMethodsInClassHierarchy() throws NotFoundException {
 final MetaClass child = getMetaClass(Child.class);
 final List<MetaMethod> foundMethods = new ArrayList<>();
 for (final MetaMethod m : child.getMethods()) {
  if (m.getName().equals("interfaceMethodOverriddenMultipleTimes")) {
   foundMethods.add(m);
  }
 }
 assertEquals("Only one copy of the method should have been found", 1, foundMethods.size());
}

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

final MetaMethod[] objMethods = Object_MetaClass.getMethods();
final MetaMethod[] nMethods = new MetaMethod[methods.length + objMethods.length];
System.arraycopy(methods, 0, nMethods, 0, methods.length);

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

public ClassStructureBuilder<?> generate() {
 final String safeProxyClassName = remote.getFullyQualifiedName().replace('.', '_') + "Impl";
 final ClassStructureBuilder<?> classBuilder =
  ClassBuilder.define(safeProxyClassName, AbstractRpcProxy.class)
   .packageScope()
   .implementsInterface(remote)
   .body();
 for (final MetaMethod method : remote.getMethods()) {
  if (ProxyUtil.shouldProxyMethod(method)) {
   generateMethod(classBuilder, method);
  }
 }
 return classBuilder;
}

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

for (final MetaMethod m : eventType.getMethods()) {
 if ("getAssociatedType".equals(m.getName())) {
  method = m;

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

@Test
public void testGetMethods() {
 final MetaClass c = getMetaClass(Child.class);
 final MetaMethod[] methods = c.getMethods();
 assertNotNull(methods);
 final List<String> methodSignatures = new ArrayList<>();
 for(final MetaMethod m : methods) {
  methodSignatures.add(GenUtil.getMethodString(m));
 }
 final List<String> expectedMethods = new ArrayList<>();
 expectedMethods.add("protectedMethod([])");
 expectedMethods.add("interfaceMethodOverriddenMultipleTimes([])");
 expectedMethods.add("packagePrivateMethod([])");
 expectedMethods.add("finalize([])");
 expectedMethods.add("equals([java.lang.Object])");
 expectedMethods.add("toString([])");
 expectedMethods.add("notify([])");
 expectedMethods.add("wait([])");
 expectedMethods.add("clone([])");
 expectedMethods.add("notifyAll([])");
 expectedMethods.add("getClass([])");
 expectedMethods.add("wait([long])");
 expectedMethods.add("hashCode([])");
 expectedMethods.add("wait([long, int])");
 Collections.sort(expectedMethods);
 Collections.sort(methodSignatures);
 assertEquals(expectedMethods.toString(), methodSignatures.toString());
}

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

.finish();
for (MetaMethod method : remote.getMethods()) {
 if (ProxyUtil.shouldProxyMethod(method)) {
  JaxrsResourceMethod resourceMethod = new JaxrsResourceMethod(method, headers, rootResourcePath);

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

private void implementAccessibleMethods(final ClassStructureBuilder<?> proxyImpl, final Injectable injectable, final BuildMetaClass factoryClass) {
 final Multimap<String, MetaMethod> proxiedMethodsByName = HashMultimap.create();
 final MetaClass injectedType = injectable.getInjectedType();
 for (final MetaMethod method : injectedType.getMethods()) {
  if (shouldProxyMethod(method, proxiedMethodsByName)) {
   proxiedMethodsByName.put(method.getName(), method);

相关文章