All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.hibernate.orm.deployment.JpaModelBuildItem Maven / Gradle / Ivy

package io.quarkus.hibernate.orm.deployment;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import javax.persistence.Entity;

import org.jboss.jandex.DotName;

import io.quarkus.builder.item.SimpleBuildItem;
import io.quarkus.hibernate.orm.runtime.boot.xml.RecordableXmlMapping;

/**
 * Internal model to represent which objects are likely needing enhancement
 * via HibernateEntityEnhancer.
 */
public final class JpaModelBuildItem extends SimpleBuildItem {

    private final Set allModelPackageNames = new TreeSet<>();
    private final Set entityClassNames = new TreeSet<>();
    private final Set potentialCdiBeanClassNames = new TreeSet<>();
    private final Set allModelClassNames = new TreeSet<>();
    private final Map> xmlMappingsByPU = new HashMap<>();

    public JpaModelBuildItem(Set allModelPackageNames, Set entityClassNames,
            Set potentialCdiBeanClassNames, Set allModelClassNames,
            Map> xmlMappingsByPU) {
        this.allModelPackageNames.addAll(allModelPackageNames);
        this.entityClassNames.addAll(entityClassNames);
        this.potentialCdiBeanClassNames.addAll(potentialCdiBeanClassNames);
        this.allModelClassNames.addAll(allModelClassNames);
        this.xmlMappingsByPU.putAll(xmlMappingsByPU);
    }

    /**
     * @return the list of packages annotated with a JPA annotation.
     */
    public Set getAllModelPackageNames() {
        return allModelPackageNames;
    }

    /**
     * @return the list of entities (i.e. classes marked with {@link Entity})
     */
    public Set getEntityClassNames() {
        return entityClassNames;
    }

    /**
     * @return the list of classes that might be retrieved by Hibernate ORM as CDI beans,
     *         e.g. converters, listeners, ...
     */
    public Set getPotentialCdiBeanClassNames() {
        return potentialCdiBeanClassNames;
    }

    /**
     * @return the list of all model class names: entities, mapped super classes, {@link #getPotentialCdiBeanClassNames()}...
     */
    public Set getAllModelClassNames() {
        return allModelClassNames;
    }

    /**
     * @return the list of all XML mappings for the given persistence unit.
     */
    public List getXmlMappings(String puName) {
        return xmlMappingsByPU.getOrDefault(puName, Collections.emptyList());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy