Search in sources :

Example 1 with ElementKind

use of javax.lang.model.element.ElementKind in project hibernate-orm by hibernate.

the class XmlMetaEntity method parseElementCollection.

private boolean parseElementCollection(ElementCollection collection) {
    String[] types;
    XmlMetaCollection metaCollection;
    ElementKind elementKind = getElementKind(collection.getAccess());
    String explicitTargetClass = determineExplicitTargetEntity(collection.getTargetClass());
    String explicitMapKey = determineExplicitMapKeyClass(collection.getMapKeyClass());
    try {
        types = getCollectionTypes(collection.getName(), explicitTargetClass, explicitMapKey, elementKind);
    } catch (MetaModelGenerationException e) {
        logMetaModelException(collection.getName(), e);
        return true;
    }
    if (types != null) {
        if (types[2] == null) {
            metaCollection = new XmlMetaCollection(this, collection.getName(), types[0], types[1]);
        } else {
            metaCollection = new XmlMetaMap(this, collection.getName(), types[0], types[1], types[2]);
        }
        members.add(metaCollection);
    }
    return false;
}
Also used : ElementKind(javax.lang.model.element.ElementKind) MetaModelGenerationException(org.hibernate.jpamodelgen.MetaModelGenerationException)

Example 2 with ElementKind

use of javax.lang.model.element.ElementKind in project hibernate-orm by hibernate.

the class XmlMetaEntity method parseManyToMany.

private boolean parseManyToMany(ManyToMany manyToMany) {
    String[] types;
    XmlMetaCollection metaCollection;
    ElementKind elementKind = getElementKind(manyToMany.getAccess());
    String explicitTargetClass = determineExplicitTargetEntity(manyToMany.getTargetEntity());
    String explicitMapKey = determineExplicitMapKeyClass(manyToMany.getMapKeyClass());
    try {
        types = getCollectionTypes(manyToMany.getName(), explicitTargetClass, explicitMapKey, elementKind);
    } catch (MetaModelGenerationException e) {
        logMetaModelException(manyToMany.getName(), e);
        return true;
    }
    if (types != null) {
        if (types[2] == null) {
            metaCollection = new XmlMetaCollection(this, manyToMany.getName(), types[0], types[1]);
        } else {
            metaCollection = new XmlMetaMap(this, manyToMany.getName(), types[0], types[1], types[2]);
        }
        members.add(metaCollection);
    }
    return false;
}
Also used : ElementKind(javax.lang.model.element.ElementKind) MetaModelGenerationException(org.hibernate.jpamodelgen.MetaModelGenerationException)

Example 3 with ElementKind

use of javax.lang.model.element.ElementKind in project hibernate-orm by hibernate.

the class XmlMetaEntity method parseEmbedded.

private void parseEmbedded(Embedded embedded) {
    XmlMetaSingleAttribute attribute;
    ElementKind elementKind = getElementKind(embedded.getAccess());
    String type = getType(embedded.getName(), null, elementKind);
    if (type != null) {
        attribute = new XmlMetaSingleAttribute(this, embedded.getName(), type);
        members.add(attribute);
    }
}
Also used : ElementKind(javax.lang.model.element.ElementKind)

Example 4 with ElementKind

use of javax.lang.model.element.ElementKind in project hibernate-orm by hibernate.

the class XmlMetaEntity method parseBasic.

private void parseBasic(Basic basic) {
    XmlMetaSingleAttribute attribute;
    ElementKind elementKind = getElementKind(basic.getAccess());
    String type = getType(basic.getName(), null, elementKind);
    if (type != null) {
        attribute = new XmlMetaSingleAttribute(this, basic.getName(), type);
        members.add(attribute);
    }
}
Also used : ElementKind(javax.lang.model.element.ElementKind)

Example 5 with ElementKind

use of javax.lang.model.element.ElementKind in project spring-framework by spring-projects.

the class IndexedStereotypesProvider method getStereotypes.

@Override
public Set<String> getStereotypes(Element element) {
    Set<String> stereotypes = new LinkedHashSet<>();
    ElementKind kind = element.getKind();
    if (kind != ElementKind.CLASS && kind != ElementKind.INTERFACE) {
        return stereotypes;
    }
    Set<Element> seen = new HashSet<>();
    collectStereotypesOnAnnotations(seen, stereotypes, element);
    seen = new HashSet<>();
    collectStereotypesOnTypes(seen, stereotypes, element);
    return stereotypes;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ElementKind(javax.lang.model.element.ElementKind) Element(javax.lang.model.element.Element) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

ElementKind (javax.lang.model.element.ElementKind)44 TypeElement (javax.lang.model.element.TypeElement)22 Element (javax.lang.model.element.Element)19 ExecutableElement (javax.lang.model.element.ExecutableElement)18 TypeMirror (javax.lang.model.type.TypeMirror)10 VariableElement (javax.lang.model.element.VariableElement)9 PackageElement (javax.lang.model.element.PackageElement)7 AnnotationMirror (javax.lang.model.element.AnnotationMirror)6 ClassName (com.squareup.javapoet.ClassName)5 MethodSpec (com.squareup.javapoet.MethodSpec)5 TypeName (com.squareup.javapoet.TypeName)5 ArrayList (java.util.ArrayList)5 LinkedHashSet (java.util.LinkedHashSet)5 Modifier (javax.lang.model.element.Modifier)5 HashSet (java.util.HashSet)4 TypeParameterElement (javax.lang.model.element.TypeParameterElement)4 TypeSpec (com.squareup.javapoet.TypeSpec)3 Builder (com.squareup.javapoet.TypeSpec.Builder)3 VariableTree (com.sun.source.tree.VariableTree)3 JCTree (com.sun.tools.javac.tree.JCTree)3