/** * Convenience method to obtain all variables and values from the mojo (including its superclasses) * * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. * * @param object * @return map of variable names and values */ public Map<String, Object> getVariablesAndValuesFromObject( Object object ) throws IllegalAccessException { return testCase.getVariablesAndValuesFromObject( object ); }
/** * Convenience method to obtain all variables and values from the mojo (including its superclasses) * * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. * * @param clazz * @param object * @return map of variable names and values */ public Map<String, Object> getVariablesAndValuesFromObject( Class<?> clazz, Object object ) throws IllegalAccessException { return testCase.getVariablesAndValuesFromObject( clazz, object ); }
/** * Convenience method to obtain all variables and values from the mojo (including its superclasses) * * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. * * @param object * @return map of variable names and values */ protected Map<String, Object> getVariablesAndValuesFromObject( Object object ) throws IllegalAccessException { return getVariablesAndValuesFromObject( object.getClass(), object ); }
/** * Convenience method to obtain all variables and values from the mojo (including its superclasses) * * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. * * @param clazz * @param object * @return map of variable names and values */ protected Map<String, Object> getVariablesAndValuesFromObject( Class<?> clazz, Object object ) throws IllegalAccessException { Map<String, Object> map = new HashMap<String, Object>(); Field[] fields = clazz.getDeclaredFields(); AccessibleObject.setAccessible( fields, true ); for ( Field field : fields ) { map.put( field.getName(), field.get( object ) ); } Class<?> superclass = clazz.getSuperclass(); if ( !Object.class.equals( superclass ) ) { map.putAll( getVariablesAndValuesFromObject( superclass, object ) ); } return map; }
/** * Convenience method to obtain all variables and values from the mojo (including its superclasses) * * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. * * @param object * @return map of variable names and values */ public Map<String, Object> getVariablesAndValuesFromObject( Object object ) throws IllegalAccessException { return testCase.getVariablesAndValuesFromObject( object ); }
/** * Convenience method to obtain all variables and values from the mojo (including its superclasses) * * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. * * @param clazz * @param object * @return map of variable names and values */ public Map<String, Object> getVariablesAndValuesFromObject( Class<?> clazz, Object object ) throws IllegalAccessException { return testCase.getVariablesAndValuesFromObject( clazz, object ); }
/** * Convenience method to obtain all variables and values from the mojo (including its superclasses) * * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. * * @param object * @return map of variable names and values */ protected Map<String, Object> getVariablesAndValuesFromObject( Object object ) throws IllegalAccessException { return getVariablesAndValuesFromObject( object.getClass(), object ); }
/** * Convenience method to obtain all variables and values from the mojo (including its superclasses) * * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. * * @param clazz * @param object * @return map of variable names and values */ protected Map<String, Object> getVariablesAndValuesFromObject( Class<?> clazz, Object object ) throws IllegalAccessException { Map<String, Object> map = new HashMap<String, Object>(); Field[] fields = clazz.getDeclaredFields(); AccessibleObject.setAccessible( fields, true ); for ( Field field : fields ) { map.put( field.getName(), field.get( object ) ); } Class<?> superclass = clazz.getSuperclass(); if ( !Object.class.equals( superclass ) ) { map.putAll( getVariablesAndValuesFromObject( superclass, object ) ); } return map; }