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

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

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

MetaClass.isAssignableTo介绍

暂无

代码示例

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

/**
 * Checks if the provided type is a {@link List} or {@link Set}.
 *
 * @param paramType
 *          the type to check
 * @return true if the type can be assigned to a List or Set, otherwise false.
 */
private boolean isListOrSet(final MetaClass paramType) {
 return paramType.isAssignableTo(List.class) || paramType.isAssignableTo(Set.class);
}

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

@Override
 public void callback(final MetaClass type) {
  if (type.isDefaultInstantiable() && type.isAssignableTo(widgetClazz)) {
   addProviderForWidgetType(injectionContext, type);
  }
 }
});

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

public static boolean isNativeJsType(final MetaClass type) {
 return type.isAssignableTo(JavaScriptObject.class) || hasNativeJsTypeAnnotation(type);
}

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

public static boolean isNativeJsType(final MetaClass type) {
 return type.isAssignableTo(JavaScriptObject.class) || hasNativeJsTypeAnnotation(type);
}

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

private boolean isJavaScriptObject(final MetaClass type) {
 return type.isAssignableTo(JavaScriptObject.class) || isNativeJSType(type);
}

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

private boolean isElemental2Event(final MetaClass eventType) {
 return eventType.isAssignableTo(elemental2.dom.Event.class) && isNativeJsType(eventType);
}

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

private boolean isElemental2Event(final MetaClass eventType) {
 return eventType.isAssignableTo(elemental2.dom.Event.class) && isNativeJsType(eventType);
}

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

private Collection<String> getElementTags(final MetaClass type) {
 if (type.isAssignableTo(ELEMENTAL_ELEMENT_META_CLASS)) {
  return elemental2ElementTags(type);
 }
 if (type.isAssignableTo(GWT_ELEMENT_META_CLASS)) {
  return gwtElementTags(type);
 }
 return customElementTags(type);
}

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

private Collection<String> getElementTags(final MetaClass type) {
 if (type.isAssignableTo(ELEMENTAL_ELEMENT_META_CLASS)) {
  return elemental2ElementTags(type);
 }
 if (type.isAssignableTo(GWT_ELEMENT_META_CLASS)) {
  return gwtElementTags(type);
 }
 return customElementTags(type);
}

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

private MetaClass getValueType(final MetaClass type) {
 if (type.isAssignableTo(TakesValue.class)) {
  return type.getMethod("getValue", new Class[0]).getReturnType();
 }
 else {
  return null;
 }
}

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

private MetaClass getValueType(final MetaClass type) {
 if (type.isAssignableTo(TakesValue.class)) {
  return type.getMethod("getValue", new Class[0]).getReturnType();
 }
 else {
  return null;
 }
}

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

private static void _doRunnableTasks(final Collection<MetaClass> classes, final BlockBuilder<?> blockBuilder) {
 for (final MetaClass clazz : classes) {
  if (!clazz.isAssignableTo(Runnable.class)) {
   throw new RuntimeException("annotated @IOCBootstrap task: " + clazz.getName() + " is not of type: "
     + Runnable.class.getName());
  }
  blockBuilder.append(Stmt.nestedCall(Stmt.newObject(clazz)).invoke("run"));
 }
}

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

private Collection<MetaMethod> getMatchingMethods(final MetaClassMember member, final Collection<MetaMethod> disposesMethods) {
 final Collection<MetaMethod> matching = new ArrayList<>();
 final Qualifier memberQual = qualFactory.forSource(member);
 final MetaClass producedType = getProducedType(member);
 for (final MetaMethod candidate : disposesMethods) {
  final MetaParameter disposesParam = candidate.getParametersAnnotatedWith(Disposes.class).iterator().next();
  if (producedType.isAssignableTo(disposesParam.getType())) {
   final Qualifier paramQual = qualFactory.forSink(disposesParam);
   if (paramQual.isSatisfiedBy(memberQual)) {
    matching.add(candidate);
   }
  }
 }
 return matching;
}

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

private boolean isNotAlreadyProxied(final MetaMethod method, final Multimap<String, MetaMethod> proxiedMethodsByName) {
 methodLoop:
 for (final MetaMethod proxiedMethod : proxiedMethodsByName.get(method.getName())) {
  final MetaParameter[] proxiedParams = proxiedMethod.getParameters();
  final MetaParameter[] methodParams = method.getParameters();
  if (proxiedParams.length == methodParams.length) {
   for (int i = 0; i < methodParams.length; i++) {
    if (!proxiedParams[i].getType().isAssignableTo(methodParams[i].getType())) {
     continue methodLoop;
    }
   }
   return false;
  }
 }
 return true;
}

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

@Override
protected List<Statement> generateDestroyInstanceStatements(final ClassStructureBuilder<?> bodyBlockBuilder,
    final Injectable injectable, final DependencyGraph graph, final InjectionContext injectionContext) {
 final Injectable provider = getProviderInjectable(injectable);
 if (provider.getInjectedType().isAssignableTo(Disposer.class)) {
  return singletonList(castTo(Disposer.class,
      loadVariable("this").invoke("getReferenceAs", loadVariable("instance"), "disposer", Disposer.class))
          .invoke("dispose", loadVariable("instance")));
 }
 else {
  return emptyList();
 }
}

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

protected Injectable getProviderInjectable(final Injectable depInjectable) {
 for (final Dependency dep : depInjectable.getDependencies()) {
  if (dep.getDependencyType().equals(DependencyType.ProducerMember)) {
   final MetaClass providerType = dep.getInjectable().getInjectedType();
   if (providerType.isAssignableTo(getProviderRawType())) {
    return dep.getInjectable();
   }
   else {
    throw new RuntimeException("Unrecognized contextual provider type " + providerType.getFullyQualifiedName());
   }
  }
 }
 throw new RuntimeException();
}

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

@Override
protected List<Statement> generateCreateInstanceStatements(final ClassStructureBuilder<?> bodyBlockBuilder,
    final Injectable injectable, final DependencyGraph graph, final InjectionContext injectionContext) {
 final List<Statement> stmts = new ArrayList<>(2);
 final Injectable providerInjectable = getProviderInjectable(injectable);
 final MetaClass paramterizedProviderType = parameterizedAs(getProviderRawType(), typeParametersOf(injectable.getInjectedType()));
 stmts.add(declareFinalVariable("provider", paramterizedProviderType, lookupProviderStmt(providerInjectable, paramterizedProviderType)));
 stmts.add(declareFinalVariable("instance", injectable.getInjectedType(), invokeProviderStmt(loadVariable("provider"))));
 if (providerInjectable.getInjectedType().isAssignableTo(Disposer.class)) {
  stmts.add(loadVariable("this").invoke("setReference", loadVariable("instance"), "disposer", loadVariable("provider")));
 }
 stmts.add(loadVariable("instance").returnValue());
 return stmts;
}

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

@Test
public void testChildIsAssignableToChild() {
 // This test checks the valid case:
 // Child example = new Child();
 final MetaClass metaChild = getMetaClass(Child.class);
 assertTrue(metaChild.isAssignableTo(metaChild));
}

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

@Test
public void testUncleIsAssignableToChild() {
 // This test checks the allowed case:
 // ParentInterface pi = new Child();
 final MetaClass metaChild = getMetaClass(Child.class);
 final MetaClass metaUncle = getMetaClass(ParentInterface.class);
 assertTrue(metaChild.isAssignableTo(metaUncle));
}

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

@Test
public void testNullIsAssignableToChild() throws Exception {
  // This test checks the valid case:
  // Child example = null;
  final MetaClass metaChild = getMetaClass(Child.class);
  final MetaClass metaNull = getMetaClass(NullType.class);
  assertTrue(metaNull.isAssignableTo(metaChild));
}

相关文章