Accept list in constructor and scan
HibernateModule - accept list for constructor and scan to avoid copying list to a new array.
@@ -168,6 +168,17 @@ public class HibernateModule implements Extension {
this("db", classes);
}
+ /**
+ * Creates a Hibernate module.
+ *
+ * @param name The name/key of the data source to attach.
+ * @param classes Persistent classes.
+ */
+ public HibernateModule(@Nonnull String name, List<Class> classes) {
+ this.name = name;
+ this.classes = classes;
+ }
+
/**
* Scan packages and look for persistent classes.
*
@@ -179,6 +190,17 @@ public class HibernateModule implements Extension {
return this;
}
+ /**
+ * Scan packages and look for persistent classes.
+ *
+ * @param packages Package names.
+ * @return This module.
+ */
+ public @Nonnull HibernateModule scan(@Nonnull List<String> packages) {
+ this.packages = packages;
+ return this;
+ }
+
/**
* Allow to customize a {@link Session} before opening it.
*
