Class EntityFinder
- java.lang.Object
-
- de.jpdigital.maven.plugins.hibernate5ddl.EntityFinder
-
final class EntityFinder extends Object
Helper class for finding the entity classes. An instance of this class is created using theforPackage(org.apache.maven.project.MavenProject, org.apache.maven.plugin.logging.Log, java.lang.String, boolean)method.- Author:
- Jens Pelzetter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classEntityFinder.ClassLoaderCreator
-
Field Summary
Fields Modifier and Type Field Description private ClassLoaderclassLoaderprivate static Set<String>PACKAGE_LEVEL_ANNOTATIONSHibernate Annotations that only be applied on package level (in apackage-info.javafile).private org.reflections.Reflectionsreflections
-
Constructor Summary
Constructors Modifier Constructor Description privateEntityFinder(org.reflections.Reflections reflections, ClassLoader classLoader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static URLclassPathElemToUrl(String classPathElem)Helper method for converting a fully qualified package name from the string representation to a a URL.Set<Class<?>>findEntities()Finds all entity classes and all converter classes in the package for which the instance of this class was created.Set<Package>findPackages()Finds all packages with Hibernate annotations on the package level.static EntityFinderforClassPath(org.apache.maven.project.MavenProject project, org.apache.maven.plugin.logging.Log log, boolean includeTestClasses)static EntityFinderforPackage(org.apache.maven.project.MavenProject project, org.apache.maven.plugin.logging.Log log, String packageName, boolean includeTestClasses)Creates anEntityFinderfor the provided package.
-
-
-
Field Detail
-
PACKAGE_LEVEL_ANNOTATIONS
private static final Set<String> PACKAGE_LEVEL_ANNOTATIONS
Hibernate Annotations that only be applied on package level (in apackage-info.javafile).
-
reflections
private final transient org.reflections.Reflections reflections
-
classLoader
private final ClassLoader classLoader
-
-
Constructor Detail
-
EntityFinder
private EntityFinder(org.reflections.Reflections reflections, ClassLoader classLoader)
-
-
Method Detail
-
forClassPath
public static EntityFinder forClassPath(org.apache.maven.project.MavenProject project, org.apache.maven.plugin.logging.Log log, boolean includeTestClasses) throws org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoFailureException
-
forPackage
public static EntityFinder forPackage(org.apache.maven.project.MavenProject project, org.apache.maven.plugin.logging.Log log, String packageName, boolean includeTestClasses) throws org.apache.maven.plugin.MojoFailureException
Creates anEntityFinderfor the provided package.- Parameters:
project- The Maven project in which the calling Mojo is executed. Can benull.log- An Maven log object for creating output.packageName- The name of the package in the class should look for entities.- Returns:
- An
EntityFinderinstance. - Throws:
org.apache.maven.plugin.MojoFailureException- If theReflectionsinstance needed by theEntityFindercan't be created.
-
findEntities
public Set<Class<?>> findEntities()
Finds all entity classes and all converter classes in the package for which the instance of this class was created. The entity classes must be annotated with theEntityannotation, the converter classes must be annotated with theConverterannotation. The method uses the Reflections library for finding the entity classes.- Returns:
- An
Setwith all entity classes.
-
findPackages
public Set<Package> findPackages()
Finds all packages with Hibernate annotations on the package level.- Returns:
- A
Setwith all packages annoated with package level Hiberannotations.
-
classPathElemToUrl
private static URL classPathElemToUrl(String classPathElem) throws org.apache.maven.plugin.MojoFailureException
Helper method for converting a fully qualified package name from the string representation to a a URL.- Parameters:
classPathElem- The class path to convert.- Returns:
- A URL for the package.
- Throws:
org.apache.maven.plugin.MojoFailureException- If something goes wrong.
-
-