Class EntityFinder

    • Field Detail

      • PACKAGE_LEVEL_ANNOTATIONS

        private static final Set<String> PACKAGE_LEVEL_ANNOTATIONS
        Hibernate Annotations that only be applied on package level (in a package-info.java file).
      • reflections

        private final transient org.reflections.Reflections reflections
    • 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 an EntityFinder for the provided package.
        Parameters:
        project - The Maven project in which the calling Mojo is executed. Can be null.
        log - An Maven log object for creating output.
        packageName - The name of the package in the class should look for entities.
        Returns:
        An EntityFinder instance.
        Throws:
        org.apache.maven.plugin.MojoFailureException - If the Reflections instance needed by the EntityFinder can'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 the Entity annotation, the converter classes must be annotated with the Converter annotation. The method uses the Reflections library for finding the entity classes.
        Returns:
        An Set with all entity classes.
      • findPackages

        public Set<Package> findPackages()
        Finds all packages with Hibernate annotations on the package level.
        Returns:
        A Set with 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.