diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-06-18 14:23:19 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-06-18 14:23:19 +0200 |
commit | 213d5355d78a0a690e366645d6416f4a8fe5e666 (patch) | |
tree | 30389a09db3f9b50f900d9276884cf5a7bc3938a /wizards/com | |
parent | 5695aea3bbe719881177b35c805920bee608751b (diff) |
Clean up some more
...making use of Java 5 variadic function parameters.
Change-Id: I1b538ec7fbb3021a225031543e25dad081a7a409
Diffstat (limited to 'wizards/com')
-rw-r--r-- | wizards/com/sun/star/wizards/ui/event/DataAware.java | 8 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/ui/event/MethodInvocation.java | 14 |
2 files changed, 6 insertions, 16 deletions
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.java b/wizards/com/sun/star/wizards/ui/event/DataAware.java index 98c3ea7f849b..c77f9eb570f2 100644 --- a/wizards/com/sun/star/wizards/ui/event/DataAware.java +++ b/wizards/com/sun/star/wizards/ui/event/DataAware.java @@ -291,15 +291,13 @@ public abstract class DataAware { * @param obj the object which contains the property. * @return the get method reflection object. */ - private static Class[] EMPTY_ARRAY = new Class[0]; - protected Method createGetMethod(String propName, Object obj) { Method m = null; try { //try to get a "get" method. - m = obj.getClass().getMethod("get" + propName, EMPTY_ARRAY); + m = obj.getClass().getMethod("get" + propName); } catch (NoSuchMethodException ex1) { @@ -313,7 +311,7 @@ public abstract class DataAware { */ public Object get(Object target) { try { - return getMethod.invoke(target, (Object[])EMPTY_ARRAY); + return getMethod.invoke(target); } catch (IllegalAccessException ex1) { ex1.printStackTrace(); } catch (InvocationTargetException ex2) { @@ -334,7 +332,7 @@ public abstract class DataAware { protected Method createSetMethod(String propName, Object obj, Class paramClass) { Method m = null; try { - m = obj.getClass().getMethod("set" + propName, new Class[] { paramClass }); + m = obj.getClass().getMethod("set" + propName, paramClass); } catch (NoSuchMethodException ex1) { throw new IllegalArgumentException("set" + propName + "(" + getMethod.getReturnType().getName() + ") method does not exist on " + obj.getClass().getName()); } diff --git a/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java b/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java index 182e96f06bc0..b1d44e30bcab 100644 --- a/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java +++ b/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java @@ -42,10 +42,6 @@ import java.lang.reflect.Method; */ public class MethodInvocation { - - static final Class[] EMPTY_ARRAY = - { - }; //the method to invoke. Method mMethod; //the object to invoke the method on. @@ -66,10 +62,7 @@ public class MethodInvocation public MethodInvocation(String methodName, Object obj, Class paramClass) throws NoSuchMethodException { - this(paramClass == null ? obj.getClass().getMethod(methodName, (Class[])null) : obj.getClass().getMethod(methodName, new Class[] - { - paramClass - }), obj, paramClass); + this(paramClass == null ? obj.getClass().getMethod(methodName) : obj.getClass().getMethod(methodName, paramClass), obj, paramClass); } public MethodInvocation(Method method, Object obj, Class paramClass) @@ -86,12 +79,11 @@ public class MethodInvocation { if (mWithParam) { - return mMethod.invoke(mObject, (Object) param - ); + return mMethod.invoke(mObject, param); } else { - return mMethod.invoke(mObject, (Object[])EMPTY_ARRAY); + return mMethod.invoke(mObject); } } |