* Can be overridden to do transformations on the value after it has been retrieved, but make sure
* to call super.setValue() or the value won't be set.
*
* @param instance the created type
- * @param value the value that has been read from ContiguousList storage
+ * @param value the value that has been read from ContiguousList storage
*/
- public void setValue(Object instance, Object value){
- Object objectToCall = instance;
-
+ public void setValue(Object instance, Object value) {
try {
- for (MethodHandle childGetter:childGetters){
- objectToCall = childGetter.invoke(instance);
- }
- setter.invokeWithArguments(objectToCall, value);
+ setter.invokeWithArguments(instance, value);
} catch (Throwable e) {
throw new IllegalStateException(e);
}
-
}
- void addChildGetter(MethodHandle childGetter){
- childGetters.add(childGetter);
- }
}
diff --git a/lib/src/main/java/nl/sanderhautvast/contiguous/PropertyHandlerFactory.java b/lib/src/main/java/nl/sanderhautvast/contiguous/PropertyHandlerFactory.java
new file mode 100644
index 0000000..de946bc
--- /dev/null
+++ b/lib/src/main/java/nl/sanderhautvast/contiguous/PropertyHandlerFactory.java
@@ -0,0 +1,58 @@
+package nl.sanderhautvast.contiguous;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+/*
+ * Maps the propertyvalue type to a PropertyHandler
+ */
+final class PropertyHandlerFactory {
+ private static final Map