From 17e2f80c8bb972c7553af20d223301da1cb97cdc Mon Sep 17 00:00:00 2001 From: wonwoo Date: Tue, 16 Oct 2018 14:28:21 +0900 Subject: [PATCH] refactoring --- .../main/java/ml/wonwoo/util/ClassUtils.java | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/mpple-core/src/main/java/ml/wonwoo/util/ClassUtils.java b/mpple-core/src/main/java/ml/wonwoo/util/ClassUtils.java index 2e146c9..89bfbc0 100644 --- a/mpple-core/src/main/java/ml/wonwoo/util/ClassUtils.java +++ b/mpple-core/src/main/java/ml/wonwoo/util/ClassUtils.java @@ -1,6 +1,7 @@ package ml.wonwoo.util; import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -100,27 +101,18 @@ public static boolean isJoda() { return isPresent("org.joda.time.DateTime"); } - public static boolean isWrapperType(Class type) { - return wrapperType.containsKey(type) || wrapperType.containsValue(type); - } - - public static boolean isDefaultJavaType(Class type) { - return defaultJavaType.containsKey(type) || defaultJavaType.containsValue(type); - } - - public static T instantiateClass(Class clazz, Object... args) { + public static T instantiateClass(Class clazz) { try { Constructor declaredConstructor = clazz.getDeclaredConstructor(); if (!declaredConstructor.isAccessible()) { declaredConstructor.setAccessible(true); } - return declaredConstructor.newInstance(args); + return declaredConstructor.newInstance(); } catch (Exception e) { throw new IllegalArgumentException(e); } } - public static Type getGenericType(Method method) { return method.getGenericParameterTypes()[0]; } @@ -135,12 +127,8 @@ public static boolean isPresent(String className) { } - public static T findMappingAnnotation(Method method, Class annotation) { - return method.getAnnotation(annotation); - } - - public static T findMappingAnnotation(Field field, Class annotation) { - return field.getAnnotation(annotation); + public static T findMappingAnnotation(AnnotatedElement element, Class annotation) { + return element.getAnnotation(annotation); } public static Field[] findAllFields(Class clazz) {