/** * Returns the property name if this is a getter * * @param method The method to investigate for being a property * @return The property name or null if not a getter */ private static String isAGetter(MethodWrapper method) { return isAGetter(method.getMethod()); }
private Method getPreDestroyMethod(Class<?> clazz, Class<?> matchingClass) { if (clazz == null || Object.class.equals(clazz)) return null; if (matchingClass.isAssignableFrom(clazz)) { // A little performance optimization Method retVal; try { retVal = clazz.getMethod(ClassReflectionHelperUtilities.CONVENTION_PRE_DESTROY, new Class<?>[0]); } catch (NoSuchMethodException e) { retVal = null; } return retVal; } for (MethodWrapper wrapper : getAllMethods(clazz)) { Method m = wrapper.getMethod(); if (ClassReflectionHelperUtilities.isPreDestroy(m)) return m; } return null; }
private Method getPostConstructMethod(Class<?> clazz, Class<?> matchingClass) { if (clazz == null || Object.class.equals(clazz)) return null; if (matchingClass.isAssignableFrom(clazz)) { // A little performance optimization Method retVal; try { retVal = clazz.getMethod(ClassReflectionHelperUtilities.CONVENTION_POST_CONSTRUCT, new Class<?>[0]); } catch (NoSuchMethodException e) { retVal = null; } return retVal; } for (MethodWrapper wrapper : getAllMethods(clazz)) { Method m = wrapper.getMethod(); if (ClassReflectionHelperUtilities.isPostConstruct(m)) return m; } return null; }
private Method getPostConstructMethod(Class<?> clazz, Class<?> matchingClass) { if (clazz == null || Object.class.equals(clazz)) return null; if (matchingClass.isAssignableFrom(clazz)) { // A little performance optimization Method retVal; try { retVal = clazz.getMethod(ClassReflectionHelperUtilities.CONVENTION_POST_CONSTRUCT, new Class<?>[0]); } catch (NoSuchMethodException e) { retVal = null; } return retVal; } for (MethodWrapper wrapper : getAllMethods(clazz)) { Method m = wrapper.getMethod(); if (ClassReflectionHelperUtilities.isPostConstruct(m)) return m; } return null; }
private Method getPostConstructMethod(Class<?> clazz, Class<?> matchingClass) { if (clazz == null || Object.class.equals(clazz)) return null; if (matchingClass.isAssignableFrom(clazz)) { // A little performance optimization Method retVal; try { retVal = clazz.getMethod(ClassReflectionHelperUtilities.CONVENTION_POST_CONSTRUCT, new Class<?>[0]); } catch (NoSuchMethodException e) { retVal = null; } return retVal; } for (MethodWrapper wrapper : getAllMethods(clazz)) { Method m = wrapper.getMethod(); if (ClassReflectionHelperUtilities.isPostConstruct(m)) return m; } return null; }
private Method getPostConstructMethod(Class<?> clazz, Class<?> matchingClass) { if (clazz == null || Object.class.equals(clazz)) return null; if (matchingClass.isAssignableFrom(clazz)) { // A little performance optimization Method retVal; try { retVal = clazz.getMethod(ClassReflectionHelperUtilities.CONVENTION_POST_CONSTRUCT, new Class<?>[0]); } catch (NoSuchMethodException e) { retVal = null; } return retVal; } for (MethodWrapper wrapper : getAllMethods(clazz)) { Method m = wrapper.getMethod(); if (ClassReflectionHelperUtilities.isPostConstruct(m)) return m; } return null; }
private Method getPreDestroyMethod(Class<?> clazz, Class<?> matchingClass) { if (clazz == null || Object.class.equals(clazz)) return null; if (matchingClass.isAssignableFrom(clazz)) { // A little performance optimization Method retVal; try { retVal = clazz.getMethod(ClassReflectionHelperUtilities.CONVENTION_PRE_DESTROY, new Class<?>[0]); } catch (NoSuchMethodException e) { retVal = null; } return retVal; } for (MethodWrapper wrapper : getAllMethods(clazz)) { Method m = wrapper.getMethod(); if (ClassReflectionHelperUtilities.isPreDestroy(m)) return m; } return null; }
private Method getPreDestroyMethod(Class<?> clazz, Class<?> matchingClass) { if (clazz == null || Object.class.equals(clazz)) return null; if (matchingClass.isAssignableFrom(clazz)) { // A little performance optimization Method retVal; try { retVal = clazz.getMethod(ClassReflectionHelperUtilities.CONVENTION_PRE_DESTROY, new Class<?>[0]); } catch (NoSuchMethodException e) { retVal = null; } return retVal; } for (MethodWrapper wrapper : getAllMethods(clazz)) { Method m = wrapper.getMethod(); if (ClassReflectionHelperUtilities.isPreDestroy(m)) return m; } return null; }
private Method getPreDestroyMethod(Class<?> clazz, Class<?> matchingClass) { if (clazz == null || Object.class.equals(clazz)) return null; if (matchingClass.isAssignableFrom(clazz)) { // A little performance optimization Method retVal; try { retVal = clazz.getMethod(ClassReflectionHelperUtilities.CONVENTION_PRE_DESTROY, new Class<?>[0]); } catch (NoSuchMethodException e) { retVal = null; } return retVal; } for (MethodWrapper wrapper : getAllMethods(clazz)) { Method m = wrapper.getMethod(); if (ClassReflectionHelperUtilities.isPreDestroy(m)) return m; } return null; }
/** * Converts a Java bean to a bean-like Map * * @param helper A ClassReflectionHelper to use for analyzing classes * @param bean a non-null bean to convert * @return a possibly zero length but never null bean-like map. All properties of the bean are filled * in, even if the value of the property is null */ public static Map<String, Object> convertJavaBeanToBeanLikeMap(ClassReflectionHelper helper, Object bean) { HashMap<String, Object> retVal = new HashMap<String, Object>(); Set<MethodWrapper> methods = helper.getAllMethods(bean.getClass()); for (MethodWrapper wrapper : methods) { String propName = isAGetter(wrapper); if (propName == null) continue; if ("class".equals(propName)) continue; Method method = wrapper.getMethod(); Object value = getValue(bean, method); retVal.put(propName, value); } return retVal; } }
/** * Converts a Java bean to a bean-like Map * * @param helper A ClassReflectionHelper to use for analyzing classes * @param bean a non-null bean to convert * @return a possibly zero length but never null bean-like map. All properties of the bean are filled * in, even if the value of the property is null */ public static Map<String, Object> convertJavaBeanToBeanLikeMap(ClassReflectionHelper helper, Object bean) { HashMap<String, Object> retVal = new HashMap<String, Object>(); Set<MethodWrapper> methods = helper.getAllMethods(bean.getClass()); for (MethodWrapper wrapper : methods) { String propName = isAGetter(wrapper); if (propName == null) continue; if ("class".equals(propName)) continue; Method method = wrapper.getMethod(); Object value = getValue(bean, method); retVal.put(propName, value); } return retVal; } }
/** * Converts a Java bean to a bean-like Map * * @param helper A ClassReflectionHelper to use for analyzing classes * @param bean a non-null bean to convert * @return a possibly zero length but never null bean-like map. All properties of the bean are filled * in, even if the value of the property is null */ public static Map<String, Object> convertJavaBeanToBeanLikeMap(ClassReflectionHelper helper, Object bean) { HashMap<String, Object> retVal = new HashMap<String, Object>(); Set<MethodWrapper> methods = helper.getAllMethods(bean.getClass()); for (MethodWrapper wrapper : methods) { String propName = isAGetter(wrapper); if (propName == null) continue; if ("class".equals(propName)) continue; Method method = wrapper.getMethod(); Object value = getValue(bean, method); retVal.put(propName, value); } return retVal; } }
/** * Converts a Java bean to a bean-like Map * * @param helper A ClassReflectionHelper to use for analyzing classes * @param bean a non-null bean to convert * @return a possibly zero length but never null bean-like map. All properties of the bean are filled * in, even if the value of the property is null */ public static Map<String, Object> convertJavaBeanToBeanLikeMap(ClassReflectionHelper helper, Object bean) { HashMap<String, Object> retVal = new HashMap<String, Object>(); Set<MethodWrapper> methods = helper.getAllMethods(bean.getClass()); for (MethodWrapper wrapper : methods) { String propName = isAGetter(wrapper); if (propName == null) continue; if ("class".equals(propName)) continue; Method method = wrapper.getMethod(); Object value = getValue(bean, method); retVal.put(propName, value); } return retVal; } }
if (propName == null) continue; Method method = wrapper.getMethod();
if (propName == null) continue; Method method = wrapper.getMethod();
if (propName == null) continue; Method method = wrapper.getMethod();
if (propName == null) continue; Method method = wrapper.getMethod();
Method method = methodWrapper.getMethod();
Method method = methodWrapper.getMethod();
Method method = methodWrapper.getMethod();