Java源码示例:javax.persistence.metamodel.StaticMetamodel

示例1
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  if (roundEnv.processingOver() || annotations.isEmpty()) {
    return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
  }

  roundEnv
      .getElementsAnnotatedWith(StaticMetamodel.class)
      .stream()
      .map(TypeElement.class::cast)
      .map(typeElement -> new MetamodelClass(elements, types, typeElement))
      .forEach(metamodelClass -> metamodelClass.writeEntityGraphTo(filer));

  return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
 
示例2
private void populateEntityInfo() throws NoSuchMethodException {
    Set<Class<?>> metaClasses = BeanUtils.reflections.getTypesAnnotatedWith(StaticMetamodel.class);
    for (Class it : metaClasses) {
        StaticMetamodel at = (StaticMetamodel) it.getAnnotation(StaticMetamodel.class);
        metaModelClasses.put(at.value(), it);
    }

    Set<Class<?>> invClasses = BeanUtils.reflections.getTypesAnnotatedWith(Inventory.class);

    for (Class invClass : invClasses) {
        EntityInfo info = buildEntityInfo(invClass);

        if (info.inventoryAnnotation.parent().length > 0) {
            Parent pat = info.inventoryAnnotation.parent()[0];
            Class pinvClass = pat.inventoryClass();
            DebugUtils.Assert(pinvClass.isAnnotationPresent(Inventory.class), String.format("inventory[%s]'s parent inventory class[%s] is not annotated by @Inventory", info.inventoryClass.getName(), pinvClass.getName()));
            EntityInfo pinfo = buildEntityInfo(pinvClass);
            info.parent = pinfo;
            pinfo.children.add(info);
        }

    }

    for (EntityInfo e : entityInfos.values()) {
        e.buildFlatTypeEntityMap();
    }
}
 
示例3
@Override
public Set<String> getSupportedAnnotationTypes() {
  return Collections.singleton(StaticMetamodel.class.getCanonicalName());
}