[Libreoffice-commits] .: 2 commits - wizards/com
Stephan Bergmann
sbergmann at kemper.freedesktop.org
Mon Jun 18 05:23:41 PDT 2012
wizards/com/sun/star/wizards/ui/event/DataAware.java | 8 ++----
wizards/com/sun/star/wizards/ui/event/MethodInvocation.java | 14 ++----------
2 files changed, 6 insertions(+), 16 deletions(-)
New commits:
commit 213d5355d78a0a690e366645d6416f4a8fe5e666
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Jun 18 14:23:19 2012 +0200
Clean up some more
...making use of Java 5 variadic function parameters.
Change-Id: I1b538ec7fbb3021a225031543e25dad081a7a409
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.java b/wizards/com/sun/star/wizards/ui/event/DataAware.java
index 98c3ea7..c77f9eb 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 182e96f..b1d44e3 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);
}
}
commit 5695aea3bbe719881177b35c805920bee608751b
Author: Noel Grandin <noel at peralex.com>
Date: Mon Jun 18 11:37:19 2012 +0200
Add casts to reduce javac warning messages.
These warning arise because of the additional of varargs parameters
in Java1.6. Casting the parameter eliminates the compiler
confusion.
Change-Id: I4906bcfa2700ef80a67b79c61c6848a18e8a7168
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.java b/wizards/com/sun/star/wizards/ui/event/DataAware.java
index 6138286..98c3ea7 100644
--- a/wizards/com/sun/star/wizards/ui/event/DataAware.java
+++ b/wizards/com/sun/star/wizards/ui/event/DataAware.java
@@ -313,7 +313,7 @@ public abstract class DataAware {
*/
public Object get(Object target) {
try {
- return getMethod.invoke(target, EMPTY_ARRAY);
+ return getMethod.invoke(target, (Object[])EMPTY_ARRAY);
} catch (IllegalAccessException ex1) {
ex1.printStackTrace();
} catch (InvocationTargetException ex2) {
diff --git a/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java b/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java
index adea073..182e96f 100644
--- a/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java
+++ b/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java
@@ -66,7 +66,7 @@ public class MethodInvocation
public MethodInvocation(String methodName, Object obj, Class paramClass) throws NoSuchMethodException
{
- this(paramClass == null ? obj.getClass().getMethod(methodName, null) : obj.getClass().getMethod(methodName, new Class[]
+ this(paramClass == null ? obj.getClass().getMethod(methodName, (Class[])null) : obj.getClass().getMethod(methodName, new Class[]
{
paramClass
}), obj, paramClass);
@@ -91,7 +91,7 @@ public class MethodInvocation
}
else
{
- return mMethod.invoke(mObject, EMPTY_ARRAY);
+ return mMethod.invoke(mObject, (Object[])EMPTY_ARRAY);
}
}
More information about the Libreoffice-commits
mailing list