private static ReadConcern readConcern(final String value) { return when(value.toUpperCase()) .is("DEFAULT", ReadConcern.DEFAULT) .is("LOCAL", ReadConcern.LOCAL) .is("MAJORITY", ReadConcern.MAJORITY) .orElseThrow(() -> new IllegalArgumentException("readConcern: " + value)); }
private static WriteConcern writeConcern(final String value) { return when(value.toUpperCase()) .is("W1", WriteConcern.W1) .is("W2", WriteConcern.W2) .is("W3", WriteConcern.W3) .is("ACKNOWLEDGED", WriteConcern.ACKNOWLEDGED) .is("MAJORITY", WriteConcern.MAJORITY) .orElseThrow(() -> new IllegalArgumentException("writeConcern: " + value)); }
static Class loadType(final ClassLoader loader, final String name) { return when(name) .<Class>is("boolean", boolean.class) .is("char", char.class) .is("byte", byte.class) .is("short", short.class) .is("int", int.class) .is("long", long.class) .is("float", float.class) .is("double", double.class) .orElseGet(() -> loader.loadClass(name.replace("/", "."))); }
static SQLTemplates toSQLTemplates(final String type) { return when(type) .<SQLTemplates>is("db2", DB2Templates::new) .is("mysql", MySQLTemplates::new) .is("mariadb", MySQLTemplates::new) .is("h2", H2Templates::new) .is("hsqldb", HSQLDBTemplates::new) .is("pgsql", PostgreSQLTemplates::new) .is("postgresql", PostgreSQLTemplates::new) .is("sqlite", SQLiteTemplates::new) .is("oracle", OracleTemplates::new) .is("firebirdsql", FirebirdTemplates::new) .is("sqlserver", SQLServer2012Templates::new) .orElseThrow(() -> new IllegalStateException("Unsupported database: " + type)); } }
private static ReadConcern readConcern(final String value) { return when(value.toUpperCase()) .is("DEFAULT", ReadConcern.DEFAULT) .is("LOCAL", ReadConcern.LOCAL) .is("MAJORITY", ReadConcern.MAJORITY) .orElseThrow(() -> new IllegalArgumentException("readConcern: " + value)); }
private static WriteConcern writeConcern(final String value) { return when(value.toUpperCase()) .is("W1", WriteConcern.W1) .is("W2", WriteConcern.W2) .is("W3", WriteConcern.W3) .is("ACKNOWLEDGED", WriteConcern.ACKNOWLEDGED) .is("MAJORITY", WriteConcern.MAJORITY) .orElseThrow(() -> new IllegalArgumentException("writeConcern: " + value)); }
static Class loadType(final ClassLoader loader, final String name) { return when(name) .<Class>is("boolean", boolean.class) .is("char", char.class) .is("byte", byte.class) .is("short", short.class) .is("int", int.class) .is("long", long.class) .is("float", float.class) .is("double", double.class) .orElseGet(() -> loader.loadClass(name.replace("/", "."))); }
static SQLTemplates toSQLTemplates(final String type) { return when(type) .<SQLTemplates>is("db2", DB2Templates::new) .is("mysql", MySQLTemplates::new) .is("mariadb", MySQLTemplates::new) .is("h2", H2Templates::new) .is("hsqldb", HSQLDBTemplates::new) .is("pgsql", PostgreSQLTemplates::new) .is("postgresql", PostgreSQLTemplates::new) .is("sqlite", SQLiteTemplates::new) .is("oracle", OracleTemplates::new) .is("firebirdsql", FirebirdTemplates::new) .is("sqlserver", SQLServer2012Templates::new) .orElseThrow(() -> new IllegalStateException("Unsupported database: " + type)); } }