[Minor] Some code cleanup for JDK 9
This commit is contained in:
parent
2cb799dfb4
commit
84d3ca4666
|
@ -32,7 +32,7 @@ public abstract class BooleanSelector<T extends StrolchElement> implements Selec
|
|||
this.selectors = new ArrayList<>(1);
|
||||
}
|
||||
|
||||
public BooleanSelector(Selector<T>... selector) {
|
||||
public BooleanSelector(Selector<T> selector) {
|
||||
this.selectors = Arrays.asList(selector);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class NotSelector<T extends StrolchElement> extends BooleanSelector<T> {
|
|||
/**
|
||||
* @param selector
|
||||
*/
|
||||
public NotSelector(Selector<T> selector) {
|
||||
NotSelector(Selector<T> selector) {
|
||||
super(selector);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,15 +32,6 @@ public class OrSelector<T extends StrolchElement> extends BooleanSelector<T> {
|
|||
super(selectors);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public OrSelector(Selector<T>... selector) {
|
||||
super(selector);
|
||||
}
|
||||
|
||||
public OrSelector(Selector<T> leftHandSide, Selector<T> rightHandSide) {
|
||||
super(leftHandSide, rightHandSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrSelector<T> with(Selector<T> selector) {
|
||||
super.with(selector);
|
||||
|
|
|
@ -1847,7 +1847,7 @@ public class DefaultPrivilegeHandler implements PrivilegeHandler {
|
|||
PrivilegePolicy policy;
|
||||
try {
|
||||
|
||||
policy = policyClazz.newInstance();
|
||||
policy = policyClazz.getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
String msg = "The class for the policy with the name {0} does not exist!{1}"; //$NON-NLS-1$
|
||||
msg = MessageFormat.format(msg, policyName, policyName);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package li.strolch.privilege.model.internal;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -117,11 +118,12 @@ public class PrivilegeContainerModel {
|
|||
// load class and try to create a new instance
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<PrivilegePolicy> clazz = (Class<PrivilegePolicy>) Class.forName(policyClassName);
|
||||
clazz.newInstance();
|
||||
|
||||
clazz.getConstructor().newInstance();
|
||||
|
||||
this.policies.put(privilegeName, clazz);
|
||||
|
||||
} catch (InstantiationException e) {
|
||||
} catch (InstantiationException | InvocationTargetException e) {
|
||||
String msg = "Configured Privilege Policy {0} with class {1} could not be instantiated."; //$NON-NLS-1$
|
||||
msg = MessageFormat.format(msg, privilegeName, policyClassName);
|
||||
throw new PrivilegeException(msg, e);
|
||||
|
@ -133,6 +135,10 @@ public class PrivilegeContainerModel {
|
|||
String msg = "Configured Privilege Policy {0} with class {1} does not exist."; //$NON-NLS-1$
|
||||
msg = MessageFormat.format(msg, privilegeName, policyClassName);
|
||||
throw new PrivilegeException(msg, e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
String msg = "Configured Privilege Policy {0} with class {1} has missing parameterless constructor"; //$NON-NLS-1$
|
||||
msg = MessageFormat.format(msg, privilegeName, policyClassName);
|
||||
throw new PrivilegeException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ package li.strolch.service.test;
|
|||
import static li.strolch.testbase.runtime.RuntimeMock.assertServiceResult;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
|
||||
|
@ -91,10 +93,11 @@ public abstract class AbstractRealmServiceTest {
|
|||
if (!Driver.isRegistered())
|
||||
Driver.register();
|
||||
|
||||
Version dbVersion = DbSchemaVersionCheck.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX,
|
||||
PostgreSqlPersistenceHandler.class);
|
||||
String sql = DbSchemaVersionCheck.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX,
|
||||
PostgreSqlPersistenceHandler.class, dbVersion, "drop"); //$NON-NLS-1$
|
||||
Version dbVersion = DbSchemaVersionCheck
|
||||
.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class);
|
||||
String sql = DbSchemaVersionCheck
|
||||
.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX, PostgreSqlPersistenceHandler.class, dbVersion,
|
||||
"drop"); //$NON-NLS-1$
|
||||
try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) {
|
||||
connection.prepareStatement(sql).execute();
|
||||
}
|
||||
|
@ -156,10 +159,11 @@ public abstract class AbstractRealmServiceTest {
|
|||
Class<? extends Service<T, U>> svcClass, Class<?> expectedServiceResultType, T arg, Runner before,
|
||||
Runner validator, Runner after) {
|
||||
try {
|
||||
runTransient(svcClass.newInstance(), expectedServiceResultType, arg, before, validator, after);
|
||||
runCached(svcClass.newInstance(), expectedServiceResultType, arg, before, validator, after);
|
||||
runTransactional(svcClass.newInstance(), expectedServiceResultType, arg, before, validator, after);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
Constructor<? extends Service<T, U>> constructor = svcClass.getConstructor();
|
||||
runTransient(constructor.newInstance(), expectedServiceResultType, arg, before, validator, after);
|
||||
runCached(constructor.newInstance(), expectedServiceResultType, arg, before, validator, after);
|
||||
runTransactional(constructor.newInstance(), expectedServiceResultType, arg, before, validator, after);
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
||||
throw new RuntimeException("Failed to instantiate class " + svcClass.getName() + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue