Skip to content

Commit 6b0717c

Browse files
committed
fixed default value not set on Property
1 parent d791ad8 commit 6b0717c

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/main/java/net/azalealibrary/configuration/property/ConfigurableProperty.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ protected ConfigurableProperty(PropertyType<T> type, Supplier<P> defaultValue, S
2929
this.defaultValue = defaultValue;
3030
this.callback = callback;
3131
this.policies = policies;
32+
this.value = defaultValue.get();
3233
}
3334

3435
public PropertyType<T> getType() {

src/main/java/net/azalealibrary/configuration/property/ListProperty.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public final class ListProperty<T> extends ConfigurableProperty<T, List<T>> {
2121

2222
private ListProperty(PropertyType<T> type, Supplier<List<T>> defaultValue, String name, String description, Consumer<List<T>> callback, List<AssignmentPolicy<T>> policies) {
2323
super(type, defaultValue, name, description, callback, policies);
24-
set(defaultValue.get());
2524
}
2625

2726
@Override
@@ -93,23 +92,25 @@ public String toString() {
9392
return isSet() ? get().stream().map(getType()::print).collect(Collectors.joining(", ")) : "<empty>";
9493
}
9594

96-
public static <T> Builder<T> create(String name, PropertyType<T> type, Supplier<List<T>> defaultValue) {
97-
return new Builder<>(name, type, defaultValue);
95+
public static <T> Builder<T> create(PropertyType<T> type, String name, Supplier<List<T>> defaultValue) {
96+
return new Builder<>(type, name, defaultValue);
9897
}
9998

10099
public static final class Builder<T> {
101100

102-
private final String name;
103101
private final PropertyType<T> type;
102+
private final String name;
104103
private final Supplier<List<T>> defaultValue;
105104
private final List<AssignmentPolicy<T>> policies = new ArrayList<>();
106105
private String description;
107106
private Consumer<List<T>> callback;
108107

109-
private Builder(String name, PropertyType<T> type, Supplier<List<T>> defaultValue) {
110-
this.name = name;
108+
private Builder(PropertyType<T> type, String name, Supplier<List<T>> defaultValue) {
111109
this.type = type;
110+
this.name = name;
112111
this.defaultValue = defaultValue;
112+
this.description = name;
113+
this.callback = v -> {};
113114
}
114115

115116
public Builder<T> addPolicy(AssignmentPolicy<T> policy) {

src/main/java/net/azalealibrary/configuration/property/Property.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,25 @@ public String toString() {
4646
return isSet() ? getType().print(get()) : "<empty>";
4747
}
4848

49-
public static <T> Builder<T> create(String name, PropertyType<T> type, Supplier<T> defaultValue) {
50-
return new Builder<>(name, type, defaultValue);
49+
public static <T> Builder<T> create(PropertyType<T> type, String name, Supplier<T> defaultValue) {
50+
return new Builder<>(type, name, defaultValue);
5151
}
5252

5353
public static final class Builder<T> {
5454

55-
private final String name;
5655
private final PropertyType<T> type;
56+
private final String name;
5757
private final Supplier<T> defaultValue;
5858
private final List<AssignmentPolicy<T>> policies = new ArrayList<>();
5959
private String description;
6060
private Consumer<T> callback;
6161

62-
private Builder(String name, PropertyType<T> type, Supplier<T> defaultValue) {
63-
this.name = name;
62+
private Builder(PropertyType<T> type, String name, Supplier<T> defaultValue) {
6463
this.type = type;
64+
this.name = name;
6565
this.defaultValue = defaultValue;
66+
this.description = name;
67+
this.callback = v -> {};
6668
}
6769

6870
public Builder<T> addPolicy(AssignmentPolicy<T> policy) {

0 commit comments

Comments
 (0)