Skip to content

Commit

Permalink
GH-80 Support inherited fields (Resolve #80)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Aug 9, 2021
1 parent acbf23b commit 9fdc393
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions cdn-kt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion cdn/src/main/java/net/dzikoysk/cdn/CdnDeserializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public T deserialize(Class<T> scheme, Section content) throws Exception {
}

private Object deserialize(Object instance, Section root) throws Exception {
for (Field field : instance.getClass().getDeclaredFields()) {
for (Field field : instance.getClass().getFields()) {
if (CdnUtils.isIgnored(field)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion cdn/src/main/java/net/dzikoysk/cdn/CdnSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Configuration serialize(Object entity) {
public Section serialize(Section root, Object entity) throws Exception {
Class<?> scheme = entity.getClass();

for (Field field : scheme.getDeclaredFields()) {
for (Field field : scheme.getFields()) {
if (CdnUtils.isIgnored(field)) {
continue;
}
Expand Down
12 changes: 8 additions & 4 deletions cdn/src/test/groovy/net/dzikoysk/cdn/TestConfiguration.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ class TestConfiguration {
@Description(['', '// Section description'])
public @Contextual SectionConfiguration section = new SectionConfiguration()

static class SectionConfiguration {

@Description('# Random value')
public Integer subEntry = -1
static class ParentSectionConfiguration {

@Description('# List description')
public List<String> list = [ 'record', 'record : with : semicolons' ]
Expand All @@ -47,4 +44,11 @@ class TestConfiguration {

}

static class SectionConfiguration extends ParentSectionConfiguration {

@Description('# Random value')
public Integer subEntry = -1

}

}

0 comments on commit 9fdc393

Please sign in to comment.