Skip to content

Commit

Permalink
Add node combining
Browse files Browse the repository at this point in the history
Start preparing for 2.4.0
  • Loading branch information
virustotalop committed Mar 31, 2022
1 parent ac9fd5d commit 052dbfa
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repositories {
maven { url 'https://jitpack.io' }
}
compile 'com.github.clubobsidian:wrappy:2.3.2'
compile 'com.github.clubobsidian:wrappy:2.4.0'
```

### Maven
Expand All @@ -43,7 +43,7 @@ compile 'com.github.clubobsidian:wrappy:2.3.2'
<dependency>
<groupId>com.github.clubobsidian</groupId>
<artifactId>wrappy</artifactId>
<version>2.3.2</version>
<version>2.4.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
shadowJar {
baseName = 'wrappy'
classifier = null
version = '2.3.2'
version = '2.4.0'
}

artifacts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ public ConfigurationSection getConfigurationSection(String path) {
section.node = NodeUtil.parsePath(this.node, path);
return section;
}

public ConfigurationSection combine(ConfigurationSection from) {
this.node.mergeFrom(from.node);
return this;
}

public boolean exists(String path) {
return !NodeUtil.parsePath(this.node, path).virtual();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.junit.Test;

import java.io.File;
import java.time.DayOfWeek;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -262,4 +261,16 @@ public void testParsePath() {
public void testGetName() {
assertEquals(config.getConfigurationSection("section").getName(), "section");
}

@Test
public void testCombine() {
ConfigurationSection first = config.getConfigurationSection("section");
ConfigurationSection second = config.getConfigurationSection("section2");
second.combine(first);
assertNotEquals(5, first.getInteger("value2"));
assertEquals(7, second.getInteger("value"));
assertEquals(5, second.getInteger("value2"));
assertEquals(1, second.getInteger("map-value.test"));
assertEquals("section2", second.getName());
}
}
4 changes: 4 additions & 0 deletions test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
section:
value: 7
map-value:
test: 1
section2:
value2: 5
key: value
integer: 5
long: 6
Expand Down

0 comments on commit 052dbfa

Please sign in to comment.