From 3121f17af5f166bbca7e0196e22f1405837f7825 Mon Sep 17 00:00:00 2001 From: Nicolai Ommer Date: Fri, 6 Nov 2015 11:16:12 +0100 Subject: [PATCH] apply default value to static fields on load automatically --- pom.xml | 2 +- .../g3force/configurable/ConfigAnnotationProcessor.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2d5d4b5..f8c75c0 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.github.g3force configurable - v1.7 + v1.8 configurable diff --git a/src/main/java/com/github/g3force/configurable/ConfigAnnotationProcessor.java b/src/main/java/com/github/g3force/configurable/ConfigAnnotationProcessor.java index a5645fd..16e9af7 100644 --- a/src/main/java/com/github/g3force/configurable/ConfigAnnotationProcessor.java +++ b/src/main/java/com/github/g3force/configurable/ConfigAnnotationProcessor.java @@ -160,6 +160,11 @@ public synchronized void loadClass(final Class clazz, final boolean overwrite if ((fdCur == null) || overwrite) { data.put(fd.getKey(), fd); + if (!fd.fieldDefValue.isEmpty()) + { + fd.fieldValue = fd.fieldDefValue; + } + applyFieldData(fd, null); } else { fdCur.comment = fd.comment; @@ -484,7 +489,6 @@ private List read(final Class clazz) try { Object obj = field.get(null); - assert obj != null; if (obj != null) { value = s2vConv.toString(type, obj); @@ -542,7 +546,6 @@ private void write(final Class clazz, final Object obj, final ConfigurableFie return; } Object value = s2vConv.parseString(type, fieldData.fieldValue); - assert value != null; // FIXME try { field.set(obj, value);