diff --git a/.gitignore b/.gitignore
index b83d222..f9a5458 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
/target/
+.idea
+*.iml
diff --git a/pom.xml b/pom.xml
index 9ef3990..d6c7afc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.github.g3force
instanceables
- v1.3
+ 2.0
instanceables
@@ -20,15 +20,15 @@
- log4j
- log4j
- 1.2.17
+ org.apache.logging.log4j
+ log4j-api
+ 2.12.1
com.github.g3force
String2ValueConverter
- v1.6
+ 2.1
@@ -74,4 +74,4 @@
-
\ No newline at end of file
+
diff --git a/src/main/java/com/github/g3force/instanceables/IInstanceableEnum.java b/src/main/java/com/github/g3force/instanceables/IInstanceableEnum.java
index 89049f8..6c83adf 100644
--- a/src/main/java/com/github/g3force/instanceables/IInstanceableEnum.java
+++ b/src/main/java/com/github/g3force/instanceables/IInstanceableEnum.java
@@ -10,19 +10,11 @@
/**
* Implement this in an enum that provides {@link InstanceableClass}s
- *
- * @author Nicolai Ommer
*/
public interface IInstanceableEnum
{
- /**
- * @return
- */
InstanceableClass getInstanceableClass();
-
-
- /**
- * @return
- */
+
+
String name();
}
diff --git a/src/main/java/com/github/g3force/instanceables/IInstanceableObserver.java b/src/main/java/com/github/g3force/instanceables/IInstanceableObserver.java
index 6e6a2ba..de81024 100644
--- a/src/main/java/com/github/g3force/instanceables/IInstanceableObserver.java
+++ b/src/main/java/com/github/g3force/instanceables/IInstanceableObserver.java
@@ -10,13 +10,8 @@
/**
* Observer interface to get notified about new instances
- *
- * @author Nicolai Ommer
*/
public interface IInstanceableObserver
{
- /**
- * @param object
- */
void onNewInstance(Object object);
}
diff --git a/src/main/java/com/github/g3force/instanceables/InstanceableClass.java b/src/main/java/com/github/g3force/instanceables/InstanceableClass.java
index 35bb04e..64e3195 100644
--- a/src/main/java/com/github/g3force/instanceables/InstanceableClass.java
+++ b/src/main/java/com/github/g3force/instanceables/InstanceableClass.java
@@ -9,7 +9,6 @@
package com.github.g3force.instanceables;
import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -17,40 +16,23 @@
/**
* An {@link InstanceableClass} can be used to create an object from a class and a set of parameters.
- *
- * @author Nicolai Ommer
*/
public class InstanceableClass
{
- // --------------------------------------------------------------------------
- // --- variables and constants ----------------------------------------------
- // --------------------------------------------------------------------------
- private final Class> impl;
- private final List params;
-
-
- // --------------------------------------------------------------------------
- // --- constructors ---------------------------------------------------------
- // --------------------------------------------------------------------------
-
- /**
- * @param impl
- * @param params
- */
+ private final Class> impl;
+ private final List params;
+
+
public InstanceableClass(final Class> impl, final InstanceableParameter... params)
{
this.impl = impl;
this.params = Arrays.asList(params);
}
-
-
- // --------------------------------------------------------------------------
- // --- methods --------------------------------------------------------------
- // --------------------------------------------------------------------------
-
+
+
/**
* Create a new instance with the specified arguments
- *
+ *
* @param args
* @return
* @throws NotCreateableException
@@ -62,35 +44,20 @@ public Object newInstance(final Object... args) throws NotCreateableException
{
Constructor> con = getConstructor();
result = con.newInstance(args);
- } catch (final SecurityException err)
- {
- throw new NotCreateableException("", err);
- } catch (final InstantiationException err)
- {
- throw new NotCreateableException("", err);
- } catch (final IllegalAccessException err)
- {
- throw new NotCreateableException("", err);
- } catch (final IllegalArgumentException err)
- {
- throw new NotCreateableException("", err);
- } catch (final InvocationTargetException err)
- {
- throw new NotCreateableException("", err);
- } catch (final IllegalStateException err)
- {
- throw new NotCreateableException("", err);
} catch (NoSuchMethodException err)
{
throw new NotCreateableException("Wrong constructor types.", err);
+ } catch (final Exception err)
+ {
+ throw new NotCreateableException("Can not create instance", err);
}
return result;
}
-
-
+
+
/**
* Create a new instance with default parameters (as defined in enum)
- *
+ *
* @return
* @throws NotCreateableException
*/
@@ -100,7 +67,7 @@ public Object newDefaultInstance() throws NotCreateableException
{
return newInstance();
}
- List