au.net.causal.maven.plugins.boxdb.db.H2Factory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boxdb-maven-plugin Show documentation
Show all versions of boxdb-maven-plugin Show documentation
Maven plugin to start databases using Docker and VMs
package au.net.causal.maven.plugins.boxdb.db;
import java.util.Objects;
@BoxDbBundled
public class H2Factory extends FileBasedDatabaseFactory
{
public H2Factory()
{
super("h2");
}
@Override
public H2Database create(BoxConfiguration boxConfiguration, ProjectConfiguration projectConfiguration, BoxContext context)
throws BoxDatabaseException
{
Objects.requireNonNull(boxConfiguration, "boxConfiguration == null");
Objects.requireNonNull(context, "context == null");
initializeDefaults(boxConfiguration, projectConfiguration, context);
return new H2Database(boxConfiguration, projectConfiguration, context);
}
protected void initializeDefaults(BoxConfiguration boxConfiguration, ProjectConfiguration projectConfiguration, BoxContext context)
throws BoxDatabaseException
{
super.initializeDefaults(boxConfiguration, projectConfiguration, context);
if (boxConfiguration.getDatabaseVersion() == null)
boxConfiguration.setDatabaseVersion("1.4.195");
if (boxConfiguration.getDatabasePort() <= 0)
boxConfiguration.setDatabasePort(9092);
CollationTranslator collationTranslator = new CollationTranslator(null, this::mapCommonCollation);
collationTranslator.processCollation(boxConfiguration);
}
private String mapCommonCollation(CommonCollation collation)
{
switch (collation)
{
case BINARY:
return null;
case CASE_INSENSITIVE:
return "en_US;PRIMARY";
default:
throw new Error("Unknown common collation: " + collation);
}
}
}