------------------------------------------------------------ revno: 7063 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Mon 2012-05-28 16:59:25 +0200 message: minor fix modified: dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java
-- lp:dhis2 https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk Your team DHIS 2 developers is subscribed to branch lp:dhis2. To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java' --- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2012-05-25 21:10:19 +0000 +++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java 2012-05-28 14:59:25 +0000 @@ -313,17 +313,17 @@ } // FIXME add type check - private Expression getAndClearExpression( T object, String field ) + private Expression getAndClearExpression( T object, String fieldName ) { Expression expression = null; - if ( ReflectionUtils.findGetterMethod( field, object ) != null ) + if ( ReflectionUtils.findGetterMethod( fieldName, object ) != null ) { - expression = ReflectionUtils.invokeGetterMethod( field, object ); + expression = ReflectionUtils.invokeGetterMethod( fieldName, object ); if ( expression != null ) { - ReflectionUtils.invokeSetterMethod( field, object, new Object[]{ null } ); + ReflectionUtils.invokeSetterMethod( fieldName, object, new Object[] { null } ); } } @@ -331,19 +331,19 @@ } // FIXME add type check - private Set<DataElementOperand> getAndClearDataElementOperands( T object, String field ) + private Set<DataElementOperand> getAndClearDataElementOperands( T object, String fieldName ) { Set<DataElementOperand> dataElementOperands = new HashSet<DataElementOperand>(); - if ( ReflectionUtils.findGetterMethod( field, object ) != null ) + if ( ReflectionUtils.findGetterMethod( fieldName, object ) != null ) { - Set<DataElementOperand> detachedDataElementOperands = ReflectionUtils.invokeGetterMethod( field, object ); + Set<DataElementOperand> detachedDataElementOperands = ReflectionUtils.invokeGetterMethod( fieldName, object ); dataElementOperands = new HashSet<DataElementOperand>( detachedDataElementOperands ); if ( detachedDataElementOperands.size() > 0 ) { detachedDataElementOperands.clear(); - ReflectionUtils.invokeSetterMethod( field, object, new HashSet<DataElementOperand>() ); + ReflectionUtils.invokeSetterMethod( fieldName, object, new HashSet<DataElementOperand>() ); } } @@ -694,7 +694,7 @@ if ( ref != null ) { fieldMap.put( field, ref ); - ReflectionUtils.invokeSetterMethod( field.getName(), object, new Object[]{ null } ); + ReflectionUtils.invokeSetterMethod( field.getName(), object, new Object[] { null } ); } } === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java 2012-05-28 14:25:12 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java 2012-05-28 14:59:25 +0000 @@ -211,8 +211,7 @@ return false; } - @SuppressWarnings( "unchecked" ) - public static <T> T invokeGetterMethod( String fieldName, Object target ) + public static Method findGetterMethod( String fieldName, Object target ) { String[] getterNames = new String[] { "get", @@ -229,15 +228,28 @@ if ( method != null ) { - return invokeMethod( target, method ); + return method; } } return null; + } @SuppressWarnings( "unchecked" ) - public static <T> T invokeSetterMethod( String fieldName, Object target, Object... args ) + public static <T> T invokeGetterMethod( String fieldName, Object target ) + { + Method method = findGetterMethod( fieldName, target ); + + if ( method != null ) + { + return invokeMethod( target, method ); + } + + return null; + } + + public static Method findSetterMethod( String fieldName, Object target ) { String[] setterNames = new String[] { "set" @@ -252,13 +264,26 @@ if ( method != null ) { - return invokeMethod( target, method, args ); + return method; } } return null; } + @SuppressWarnings( "unchecked" ) + public static <T> T invokeSetterMethod( String fieldName, Object target, Object... args ) + { + Method method = findSetterMethod( fieldName, target ); + + if ( method != null ) + { + return invokeMethod( target, method, args ); + } + + return null; + } + public static boolean isType( Field field, Class<?> clazz ) { Class<?> type = field.getType();
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp