HHH-12749 - Avoid setting the isolation level to the same value in C3P0ConnectionProvider

Fix checkstyle issues
This commit is contained in:
Vlad Mihalcea 2018-07-02 14:15:50 +03:00
parent 6f336b850c
commit 387bbc51c1
1 changed files with 64 additions and 38 deletions

View File

@ -1,3 +1,9 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.testing.util;
import java.lang.reflect.Constructor;
@ -13,8 +19,10 @@ public class ReflectionUtil {
/**
* Get a field from a given class
*
* @param clazz clazz
* @param name field name
*
* @return field object
*/
public static Field getField(Class clazz, String name) {
@ -34,8 +42,10 @@ public class ReflectionUtil {
/**
* Get a field value from a given object
*
* @param target Object whose field is being read
* @param name field name
*
* @return field object
*/
public static <T> T getFieldValue(Object target, String name) {
@ -45,7 +55,10 @@ public class ReflectionUtil {
return (T) field.get( target );
}
catch (NoSuchFieldException e) {
throw new IllegalArgumentException( "Class " + target.getClass() + " does not contain a " + name + " field", e);
throw new IllegalArgumentException(
"Class " + target.getClass() + " does not contain a " + name + " field",
e
);
}
catch (IllegalAccessException e) {
throw new IllegalArgumentException( "Cannot set field " + name, e );
@ -54,8 +67,10 @@ public class ReflectionUtil {
/**
* Get a field value from a given class
*
* @param target Class whose field is being read
* @param name field name
*
* @return field value
*/
public static <T> T getStaticFieldValue(Class<?> target, String name) {
@ -70,6 +85,7 @@ public class ReflectionUtil {
/**
* Set target Object field to a certain value
*
* @param target Object whose field is being set
* @param field Object field to set
* @param value the new value for the given field
@ -85,6 +101,7 @@ public class ReflectionUtil {
/**
* Set target Object field to a certain value
*
* @param target Object whose field is being set
* @param fieldName Object field naem to set
* @param value the new value for the given field
@ -101,6 +118,7 @@ public class ReflectionUtil {
/**
* Set target Class field to a certain value
*
* @param target Class whose field is being set
* @param fieldName Class field name to set
* @param value the new value for the given field
@ -117,8 +135,10 @@ public class ReflectionUtil {
/**
* New target Object instance using the given arguments
*
* @param constructorSupplier constructor supplier
* @param args Constructor arguments
*
* @return new Object instance
*/
public static <T> T newInstance(Supplier<Constructor<T>> constructorSupplier, Object... args) {
@ -134,7 +154,9 @@ public class ReflectionUtil {
/**
* New target Object instance using the given Class name
*
* @param className class name
*
* @return new Object instance
*/
public static <T> T newInstance(String className) {
@ -152,6 +174,7 @@ public class ReflectionUtil {
* @param target target object
* @param property property
* @param parameterType setter parameter type
*
* @return setter method
*/
public static Method getSetter(Object target, String property, Class<?> parameterType) {
@ -167,12 +190,14 @@ public class ReflectionUtil {
* @param target target object
* @param methodName method name
* @param parameterTypes method parameter types
*
* @return return value
*/
public static Method getMethod(Object target, String methodName, Class... parameterTypes) {
try {
return target.getClass().getMethod( methodName, parameterTypes );
} catch (NoSuchMethodException e) {
}
catch (NoSuchMethodException e) {
throw new IllegalArgumentException( e );
}
}
@ -188,7 +213,8 @@ public class ReflectionUtil {
Method setter = getSetter( target, property, parameter.getClass() );
try {
setter.invoke( target, parameter );
} catch (IllegalAccessException | InvocationTargetException e) {
}
catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalArgumentException( e );
}
}