Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/org.eclipse.papyrus.infra.tools')
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ReflectHelper.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ReflectHelper.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ReflectHelper.java
new file mode 100644
index 00000000000..a8c706ef087
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ReflectHelper.java
@@ -0,0 +1,44 @@
+package org.eclipse.papyrus.infra.tools.util;
+
+import java.lang.reflect.Method;
+
+/**
+ *
+ * This helper provides methods to get methods reflectively
+ * It is not the better way to access to method, but sometimes it can be interested to avoid to duplicate
+ * lot of code
+ *
+ */
+public class ReflectHelper {
+
+ /**
+ *
+ * Should not be instantiated
+ *
+ */
+ private ReflectHelper() {
+ // prevents instantiation
+ }
+
+ /**
+ * Warning : each call of this method should be tested with a JUnit test, in order to know
+ * when the API has changed
+ *
+ * @param aClass
+ * a class
+ * @param methodName
+ * the name of the method to find
+ * @param parameterTypes
+ * an array owning the type of the parameters of the called method
+ * @return
+ * the wanted method
+ * @throws NoSuchMethodException
+ * @throws SecurityException
+ */
+ public static Method getMethod(final Class<?> aClass, final String methodName, Class<?>[] parameterTypes) throws SecurityException, NoSuchMethodException {
+ Method m = null;
+ m = aClass.getDeclaredMethod(methodName, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+}

Back to the top