The final restructured version for automatic build using maven tycho
[Mograsim.git] / plugins / net.mograsim.logic.model / src / net / mograsim / logic / model / serializing / ReflectionHelper.java
1 package net.mograsim.logic.model.serializing;
2
3 public class ReflectionHelper
4 {
5         private ReflectionHelper()
6         {
7         }
8
9         public static Class<?> tryInvokeStaticInitializer(String className, String errorMessageFormat)
10         {
11                 return tryInvokeStaticInitializer(className, errorMessageFormat, ReflectionHelper.class.getClassLoader());
12         }
13
14         public static Class<?> tryInvokeStaticInitializer(String className, String errorMessageFormat, ClassLoader classLoader)
15         {
16                 try
17                 {
18                         return tryInvokeStaticInitializer(className, classLoader);
19                 }
20                 catch (ClassNotFoundException e)
21                 {
22                         System.err.printf(errorMessageFormat, className, "ClassNotFoundException thrown: " + e.getMessage());
23                         return null;
24                 }
25         }
26
27         public static Class<?> tryInvokeStaticInitializer(String className) throws ClassNotFoundException
28         {
29                 return tryInvokeStaticInitializer(className, ReflectionHelper.class.getClassLoader());
30         }
31
32         public static Class<?> tryInvokeStaticInitializer(String className, ClassLoader classLoader) throws ClassNotFoundException
33         {
34                 return Class.forName(className, true, classLoader);
35         }
36 }