[Japi-cvs] SF.net SVN: japi: [302] libs/swing-action/trunk/src/net/sf/japi/swing/ ReflectionAction.
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2007-01-15 19:29:53
|
Revision: 302 http://svn.sourceforge.net/japi/?rev=302&view=rev Author: christianhujer Date: 2007-01-15 11:29:48 -0800 (Mon, 15 Jan 2007) Log Message: ----------- Changed method lookup to prefer ActionMethods over normal methods. Modified Paths: -------------- libs/swing-action/trunk/src/net/sf/japi/swing/ReflectionAction.java Modified: libs/swing-action/trunk/src/net/sf/japi/swing/ReflectionAction.java =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/ReflectionAction.java 2007-01-14 23:21:34 UTC (rev 301) +++ libs/swing-action/trunk/src/net/sf/japi/swing/ReflectionAction.java 2007-01-15 19:29:48 UTC (rev 302) @@ -243,11 +243,19 @@ * @throws NoSuchMethodException In case the method was not found. */ @Nullable public static Method getActionMethod(@NotNull final Class<?> clazz, @NotNull final String methodName) throws NoSuchMethodException { + // First search for explicit ActionMethods. for (final Method method : clazz.getMethods()) { - if (method.getName().equals(methodName) || method.isAnnotationPresent(ActionMethod.class) && method.getAnnotation(ActionMethod.class).value().equals(methodName)) { + if (method.isAnnotationPresent(ActionMethod.class) && (method.getName().equals(methodName) || method.getAnnotation(ActionMethod.class).value().equals(methodName))) { return method; } } + // Second, if no explicit ActionMethod was found, try implicit. + // This could be improved. + for (final Method method : clazz.getMethods()) { + if (method.getName().equals(methodName)) { + return method; + } + } throw new NoSuchMethodException(methodName + " (error: no public method named " + methodName + " and annotated as @ActionMethod found)"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |