Skip to content

Commit

Permalink
apply default value to static fields on load automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
g3force committed Nov 6, 2015
1 parent 73a0923 commit 3121f17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.g3force</groupId>
<artifactId>configurable</artifactId>
<version>v1.7</version>
<version>v1.8</version>
<name>configurable</name>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -484,7 +489,6 @@ private List<ConfigurableFieldData> read(final Class<?> clazz)
try
{
Object obj = field.get(null);
assert obj != null;
if (obj != null)
{
value = s2vConv.toString(type, obj);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3121f17

Please sign in to comment.