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

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

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

MetaClass.getInterfaces介绍

暂无

代码示例

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

private static void addInterfaces(final MetaClass metaClass, final Collection<MetaClass> supersAndIfaces) {
 for (final MetaClass iface : metaClass.getInterfaces()) {
  supersAndIfaces.add(iface);
  addInterfaces(iface, supersAndIfaces);
 }
}

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

private static void addInterfaces(final MetaClass metaClass, final Collection<MetaClass> supersAndIfaces) {
 for (final MetaClass iface : metaClass.getInterfaces()) {
  supersAndIfaces.add(iface);
  addInterfaces(iface, supersAndIfaces);
 }
}

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

private Stream<MetaClass> findJsTypeIfaces(final MetaClass type) {
 return stream(type.getInterfaces())
  .flatMap(iface -> stream(iface.getInterfaces()))
  .distinct()
  .filter(iface -> !iface.getFullyQualifiedName().startsWith("java.util"))
  .filter(iface -> iface.isAnnotationPresent(JsType.class) && !iface.getAnnotation(JsType.class).isNative());
}

代码示例来源:origin: kiegroup/appformer

public boolean implementsResource(MetaClass metaClass) {
  for (MetaClass iface : metaClass.getInterfaces()) {
    if (iface.asClass().equals(Resource.class) || implementsResource(iface)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.uberfire/uberfire-security-codegen

public boolean implementsResource(MetaClass metaClass) {
  for (MetaClass iface : metaClass.getInterfaces()) {
    if (iface.asClass().equals(Resource.class) || implementsResource(iface)) {
      return true;
    }
  }
  return false;
}

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

/**
 * @return True iff the given type is an interface extending {@code elemental.html.Element}.
 */
public static boolean isElementalIface(final MetaClass type) {
 if (!(type.isInterface() && type.getPackageName().startsWith("elemental."))) {
  return false;
 }
 final Queue<MetaClass> ifaces = new LinkedList<MetaClass>();
 ifaces.add(type);
 while (!ifaces.isEmpty()) {
  final MetaClass iface = ifaces.poll();
  if (iface.getFullyQualifiedName().equals("elemental.dom.Element")) {
   return true;
  } else {
   ifaces.addAll(Arrays.asList(iface.getInterfaces()));
  }
 }
 return false;
}

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

/**
 * @return True iff the given type is an interface extending {@code elemental.html.Element}.
 */
public static boolean isElementalIface(final MetaClass type) {
 if (!(type.isInterface() && type.getPackageName().startsWith("elemental."))) {
  return false;
 }
 final Queue<MetaClass> ifaces = new LinkedList<MetaClass>();
 ifaces.add(type);
 while (!ifaces.isEmpty()) {
  final MetaClass iface = ifaces.poll();
  if (iface.getFullyQualifiedName().equals("elemental.dom.Element")) {
   return true;
  } else {
   ifaces.addAll(Arrays.asList(iface.getInterfaces()));
  }
 }
 return false;
}

代码示例来源: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

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 static void fillInInterfacesAndSuperTypes(final Set<MetaClass> set, final MetaClass type) {
 for (final MetaClass iface : type.getInterfaces()) {
  set.add(iface);
  fillInInterfacesAndSuperTypes(set, iface);
 }
 if (type.getSuperClass() != null) {
  fillInInterfacesAndSuperTypes(set, type.getSuperClass());
 }
}

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

private static void fillInInterfacesAndSuperTypes(final Set<MetaClass> set, final MetaClass type) {
 for (final MetaClass iface : type.getInterfaces()) {
  set.add(iface);
  fillInInterfacesAndSuperTypes(set, iface);
 }
 if (type.getSuperClass() != null) {
  fillInInterfacesAndSuperTypes(set, type.getSuperClass());
 }
}

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

/**
 * Recursive subroutine of {@link #fillInheritanceMap(org.jboss.errai.codegen.meta.MetaClass)}.
 */
private static void fillInheritanceMap(final Multimap<String, String> inheritanceMap,
                    final MetaClass visiting,
                    final MetaClass mappingClass) {
 if (visiting == null || visiting.equals(MetaClassFactory.get(Object.class)))
  return;
 if (!visiting.equals(mappingClass)) {
  inheritanceMap.put(visiting.getFullyQualifiedName(), mappingClass.getFullyQualifiedName());
 }
 fillInheritanceMap(inheritanceMap, visiting.getSuperClass(), mappingClass);
 for (final MetaClass iface : visiting.getInterfaces()) {
  fillInheritanceMap(inheritanceMap, iface, mappingClass);
 }
}

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

private static void addInterfaces(final MetaClass clazz, final BuildMetaClass buildMetaClass, final MetaParameterizedType parameterizedType) {
 final MetaType[] typeParams = (clazz.getParameterizedType() != null ? clazz.getParameterizedType().getTypeParameters() : clazz.getTypeParameters());
 final MetaType[] typeArgs = parameterizedType.getTypeParameters();
 validateTypeArgumentsAgainstParameters(clazz, typeParams, typeArgs);
 final Map<String, MetaType> typeArgsByTypeParam = mapTypeArgsByTypeParamName(typeParams, typeArgs);
 final List<MetaClass> ifaces = Arrays
     .stream(clazz.getInterfaces())
     .map(iface -> getParameterizedInterface(typeArgsByTypeParam, iface))
     .collect(Collectors.toList());
 buildMetaClass.setInterfaces(ifaces);
}

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

public static int scoreInterface(final MetaClass parm, final MetaClass arg) {
 if (parm.isInterface()) {
  final MetaClass[] iface = arg.getInterfaces();
  if (iface != null) {
   for (final MetaClass c : iface) {
    if (c == parm) return 1;
    else if (parm.isAssignableFrom(c)) return scoreInterface(parm, arg.getSuperClass());
   }
  }
 }
 return 0;
}

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

/**
 * Returns the literalizable target type for any matching subtype. Meaning, that if say, the type
 * <tt>com.bar.FooImpl</tt> is a subtype of the interface <tt>com.bar.Foo</tt>, which is itself marked literalizable,
 * this method will return a reference to the <tt>java.lang.Class</tt> instance for <tt>com.bar.Foo</tt>
 *
 * @param clazz
 *     the class, interface or superclass to obtain a literalizable target type for.
 * @param clazz
 *     . If there are no matches, returns <tt>null</tt>.
 *
 * @return the literalizable target type that matches
 */
public Class<?> getLiteralizableTargetType(final MetaClass clazz) {
 checkThread();
 Context ctx = this;
 do {
  MetaClass cls = clazz;
  do {
   if (ctx.literalizableClasses.contains(cls))
    return cls.asClass();
   for (final MetaClass iface : cls.getInterfaces()) {
    if (ctx.literalizableClasses.contains(iface))
     return iface.asClass();
   }
  }
  while ((cls = cls.getSuperClass()) != null);
 }
 while ((ctx = ctx.parent) != null);
 return null;
}

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

/**
 * Recursive subroutine of {@link #fillInheritanceMap(org.jboss.errai.codegen.meta.MetaClass)}.
 */
private static void fillInheritanceMap(final Multimap<String, String> inheritanceMap,
                    final MetaClass visiting,
                    final MetaClass mappingClass) {
 if (visiting == null || visiting.equals(MetaClassFactory.get(Object.class)))
  return;
 if (!visiting.equals(mappingClass)) {
  inheritanceMap.put(visiting.getFullyQualifiedName(), mappingClass.getFullyQualifiedName());
 }
 fillInheritanceMap(inheritanceMap, visiting.getSuperClass(), mappingClass);
 for (final MetaClass iface : visiting.getInterfaces()) {
  fillInheritanceMap(inheritanceMap, iface, mappingClass);
 }
}

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

private static void addInterfaces(final MetaClass clazz, final BuildMetaClass buildMetaClass, final MetaParameterizedType parameterizedType) {
 final MetaType[] typeParams = (clazz.getParameterizedType() != null ? clazz.getParameterizedType().getTypeParameters() : clazz.getTypeParameters());
 final MetaType[] typeArgs = parameterizedType.getTypeParameters();
 validateTypeArgumentsAgainstParameters(clazz, typeParams, typeArgs);
 final Map<String, MetaType> typeArgsByTypeParam = mapTypeArgsByTypeParamName(typeParams, typeArgs);
 final List<MetaClass> ifaces = Arrays
     .stream(clazz.getInterfaces())
     .map(iface -> getParameterizedInterface(typeArgsByTypeParam, iface))
     .collect(Collectors.toList());
 buildMetaClass.setInterfaces(ifaces);
}

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

public static int scoreInterface(final MetaClass parm, final MetaClass arg) {
 if (parm.isInterface()) {
  final MetaClass[] iface = arg.getInterfaces();
  if (iface != null) {
   for (final MetaClass c : iface) {
    if (c == parm) return 1;
    else if (parm.isAssignableFrom(c)) return scoreInterface(parm, arg.getSuperClass());
   }
  }
 }
 return 0;
}

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

@Test
public void testGetInterfaces() throws Exception {
 final MetaClass grandparent = getMetaClass(Grandparent.class);
 assertEquals(1, grandparent.getInterfaces().length);
 assertEquals(
     Arrays.asList(getMetaClass(GrandparentInterface.class)),
     Arrays.asList(grandparent.getInterfaces()));
}

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

@Override
public boolean isAssignableFrom(final MetaClass clazz) {
 Boolean assignable = ASSIGNABLE_CACHE.get(clazz);
 if (assignable != null) {
  return assignable;
 }
 // XXX not sure if this is uncached on purpose.
 // FIXME there are no tests or documentation for this case
 if (!isPrimitive() && NULL_TYPE.equals(clazz))
  return true;
 if (isArray() && clazz.isArray()) {
  return getOuterComponentType().isAssignableFrom(clazz.getOuterComponentType())
    && getArrayDimensions(this) == getArrayDimensions(clazz);
 }
 final MetaClass sup;
 if (getFullyQualifiedName().equals(Object.class.getName())) {
  assignable = true;
 }
 else if (this.getFullyQualifiedName().equals(clazz.getFullyQualifiedName())) {
  assignable = true;
 }
 else if (isInterface() && _hasInterface(clazz.getInterfaces(), this.getErased())) {
  assignable = true;
 }
 else
  assignable = (sup = clazz.getSuperClass()) != null && isAssignableFrom(sup);
 ASSIGNABLE_CACHE.put(clazz, assignable);
 return assignable;
}

相关文章