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

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

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

MetaClass.getErased介绍

[英]Returns a MetaClass that represents the same class as this one, but guaranteed to have no type parameters.
[中]返回一个元类,该元类表示与此元类相同的类,但保证没有类型参数。

代码示例

代码示例来源: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: org.jboss.errai/errai-bus

private void generateMethod(ClassStructureBuilder<?> classBuilder, MetaMethod method) {
 final List<Class<?>> interceptors = interceptorProvider.getInterceptors(remote, method);
 final boolean intercepted = !interceptors.isEmpty();
 final Parameter[] parms = DefParameters.from(method).getParameters().toArray(new Parameter[0]);
 final Parameter[] finalParms = new Parameter[parms.length];
 final List<Statement> parmVars = new ArrayList<Statement>();
 for (int i = 0; i < parms.length; i++) {
  finalParms[i] = Parameter.of(parms[i].getType().getErased(), parms[i].getName(), true);
  parmVars.add(Stmt.loadVariable(parms[i].getName()));
 }
 final Statement parameters = (intercepted) ?
   new StringStatement("getParameters()", MetaClassFactory.get(Object[].class)) :
    Stmt.newArray(Object.class).initialize(parmVars.toArray());
 final BlockBuilder<?> methodBlock =
   classBuilder.publicMethod(method.getReturnType().getErased(), method.getName(), finalParms);
 if (intercepted) {
  methodBlock.append(generateInterceptorLogic(classBuilder, method,
    generateRequest(classBuilder, method, parameters, true), parmVars, interceptors));
 }
 else {
  methodBlock.append(generateRequest(classBuilder, method, parameters, false));
 }
 final Statement returnStmt = ProxyUtil.generateProxyMethodReturnStatement(method);
 if (returnStmt != null) {
  methodBlock.append(returnStmt);
 }
 methodBlock.finish();
}

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

private boolean isRawType(final MetaClass type) {
 // Guaranteed to be true for all raw types in all MetaClass impls
 return type == type.getErased();
}

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

private void linkInjectableReference(final InjectableReference injectableReference) {
 final Collection<InjectableReference> candidates = directInjectableReferencesByAssignableTypes
     .get(injectableReference.type.getErased());
 logger.debug("Found {} candidate references.", candidates.size());
 for (final InjectableReference candidate : candidates) {
  if (GraphUtil.candidateSatisfiesInjectable(injectableReference, candidate)) {
   logger.trace("Candidate has been linked: {}", candidate);
   injectableReference.linked.add(candidate);
  }
 }
}

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

/**
 * Mark a class "literalizable". Meaning that all classes that are assignable to this type, are candidates for
 * reification to code snapshots for this context and all subcontexts. See {@link SnapshotMaker} for further details.
 *
 * @param clazz
 *     the class, interface or superclass to be considered literalizable.
 */
public void addLiteralizableClass(final MetaClass clazz) {
 checkThread();
 literalizableClasses.add(clazz.getErased());
}

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

/**
 * Mark a class "literalizable". Meaning that all classes that are assignable to this type, are candidates for
 * reification to code snapshots for this context and all subcontexts. See {@link SnapshotMaker} for further details.
 *
 * @param clazz
 *     the class, interface or superclass to be considered literalizable.
 */
public void addLiteralizableClass(final MetaClass clazz) {
 checkThread();
 literalizableClasses.add(clazz.getErased());
}

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

private void resolveTypeSpecialization(final InjectableImpl specialization, final Set<InjectableImpl> toBeRemoved) {
 final MetaClass specializedType = specialization.type.getSuperClass().getErased();
 for (final InjectableReference injectable : directInjectableReferencesByAssignableTypes.get(specializedType)) {
  if (injectable.type.equals(specializedType)) {
   if (!injectable.linked.isEmpty()) {
    updateSpecializedReferenceLinks(specialization, toBeRemoved, injectable);
    break;
   }
  }
 }
}

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

private void processAssignableTypes(final InjectableReference injectableReference) {
 for (final MetaClass assignable : injectableReference.type.getAllSuperTypesAndInterfaces()) {
  try {
   directInjectableReferencesByAssignableTypes.put(assignable.getErased(), injectableReference);
  } catch (final Throwable t) {
   throw new RuntimeException("Error occurred adding the assignable type " + assignable.getFullyQualifiedName(), t);
  }
 }
}

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

protected SimpleMapping(final String key, final MetaClass targetType) {
 if (key == null) {
  throw new NullPointerException("key is null");
 }
 this.type = targetType.asBoxed(); 
 this.targetType = targetType.getErased().asBoxed();
 this.key = key;
}

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

protected SimpleMapping(final String key, final MetaClass targetType) {
 if (key == null) {
  throw new NullPointerException("key is null");
 }
 this.type = targetType.asBoxed(); 
 this.targetType = targetType.getErased().asBoxed();
 this.key = key;
}

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

private static boolean _hasInterface(final MetaClass[] from, final MetaClass to) {
 for (final MetaClass interfaceType : from) {
  if (to.getFullyQualifiedName().equals(interfaceType.getErased().getFullyQualifiedName()))
   return true;
  else if (_hasInterface(interfaceType.getInterfaces(), to))
   return true;
 }
 return false;
}

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

private MetaClass[] getErasedParamterTypes(final MetaMethod method) {
 final MetaClass[] paramTypes = new MetaClass[method.getParameters().length];
 for (int i = 0; i < paramTypes.length; i++) {
  paramTypes[i] = method.getParameters()[i].getType().getErased();
 }
 return paramTypes;
}

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

private static boolean _hasInterface(final MetaClass[] from, final MetaClass to) {
 for (final MetaClass interfaceType : from) {
  if (to.getFullyQualifiedName().equals(interfaceType.getErased().getFullyQualifiedName()))
   return true;
  else if (_hasInterface(interfaceType.getInterfaces(), to))
   return true;
 }
 return false;
}

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

private MetaClass[] getErasedParamterTypes(final MetaMethod method) {
 final MetaClass[] paramTypes = new MetaClass[method.getParameters().length];
 for (int i = 0; i < paramTypes.length; i++) {
  paramTypes[i] = method.getParameters()[i].getType().getErased();
 }
 return paramTypes;
}

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

private Parameter[] getParametersForDeclaration(final MetaMethod method) {
 final MetaParameter[] metaParams = method.getParameters();
 final Parameter[] params = new Parameter[metaParams.length];
 for (int i = 0; i < params.length; i++) {
  params[i] = Parameter.of(metaParams[i].getType().getErased(), metaParams[i].getName());
 }
 return params;
}

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

private boolean needsLazyInit(MetaClass type) {
 MetaClass compType = type.getOuterComponentType().getErased();
 return (!compType.asUnboxed().isPrimitive() && !compType.equals(MetaClassFactory.get(String.class)) && !context
   .getDefinitionsFactory().hasBuiltInDefinition(compType));
}

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

private boolean needsLazyInit(MetaClass type) {
 MetaClass compType = type.getOuterComponentType().getErased();
 return (!compType.asUnboxed().isPrimitive() && !compType.equals(MetaClassFactory.get(String.class)) && !context
   .getDefinitionsFactory().hasBuiltInDefinition(compType));
}

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

@Test
public void testEraseNonGenericType() throws Exception {
 final MetaClass child = getMetaClass(Child.class);
 assertSame(child, child.getErased());
}

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

@Test
public void testEraseParameterizedTopLevelType() throws Exception {
 final MetaClass parameterized = getMetaClass(ParameterizedClass.class);
 assertEquals("ParameterizedClass", parameterized.getName());
 assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass", parameterized.getFullyQualifiedName());
 assertNull(parameterized.getParameterizedType());
 // I think this would be correct, but right now we get the raw type name
 //assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass<T>", parameterized.getFullyQualifiedNameWithTypeParms());
 assertEquals("org.jboss.errai.codegen.test.model.ParameterizedClass", parameterized.getErased().getFullyQualifiedNameWithTypeParms());
}

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

@Test
public void testFieldWithStringTypeParam() throws Exception {
 final MetaClass metaClass = getMetaClass(ClassWithGenericCollections.class);
 final MetaField field = metaClass.getDeclaredField("hasStringParam");
 assertNotNull(field);
 assertEquals("Collection", field.getType().getName());
 assertEquals("java.util.Collection", field.getType().getFullyQualifiedName());
 assertEquals("<java.lang.String>", field.getType().getParameterizedType().toString());
 assertEquals("java.util.Collection<java.lang.String>", field.getType().getFullyQualifiedNameWithTypeParms());
 assertEquals("java.util.Collection", field.getType().getErased().getFullyQualifiedNameWithTypeParms());
 assertEquals(
     Arrays.asList(getMetaClass(String.class)),
     Arrays.asList(field.getType().getParameterizedType().getTypeParameters()));
}

相关文章