Skip to content

Commit f27c8f4

Browse files
committed
renamed field
1 parent 891d375 commit f27c8f4

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/main/java/net/azalealibrary/configuration/ConfigureCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private static String getMessage(List<ConfigurableProperty<?, ?>> properties, St
8989
}
9090

9191
private enum Action {
92-
SET((s, a, i, c) -> c.getName().matches(i) && c.getType().test(s, a)),
92+
SET((s, a, i, c) -> c.getName().matches(i) && c.getPropertyType().test(s, a)),
9393
RESET((s, a, i, c) -> c.getName().matches(i)),
9494
INFO((s, a, i, c) -> c.getName().equals(i));
9595

src/main/java/net/azalealibrary/configuration/FileConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void save(Configurable configurable) {
5454
for (ConfigurableProperty<?, ?> property : configurable.getProperties()) {
5555
property.serialize(configuration);
5656
List<String> comments = new ArrayList<>();
57-
String type = property.getType().getExpected() + (property instanceof ListProperty<?> ? " (list)" : "");
57+
String type = property.getPropertyType().getExpected() + (property instanceof ListProperty<?> ? " (list)" : "");
5858
comments.add("Property: " + property.getName() + " of " + type);
5959
comments.add("Default: " + property.getDefault());
6060
property.getDescription().forEach(l -> comments.addAll(TextUtil.split(l, 55).stream().map(i -> " " + i).toList()));

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414

1515
public abstract class ConfigurableProperty<T, P> {
1616

17-
protected final PropertyType<T> type;
17+
protected final PropertyType<T> propertyType;
1818
protected final List<AssignmentPolicy<T>> policies;
1919
protected final String name;
2020
protected final Consumer<P> callback;
2121
private final List<String> description;
2222
private final Supplier<P> defaultValue;
2323
private @Nullable P value;
2424

25-
protected ConfigurableProperty(PropertyType<T> type, Supplier<P> defaultValue, String name, List<String> description, Consumer<P> callback, List<AssignmentPolicy<T>> policies) {
26-
this.type = type;
25+
protected ConfigurableProperty(PropertyType<T> propertyType, Supplier<P> defaultValue, String name, List<String> description, Consumer<P> callback, List<AssignmentPolicy<T>> policies) {
26+
this.propertyType = propertyType;
2727
this.name = name;
2828
this.description = description;
2929
this.defaultValue = defaultValue;
@@ -32,8 +32,8 @@ protected ConfigurableProperty(PropertyType<T> type, Supplier<P> defaultValue, S
3232
this.value = defaultValue.get();
3333
}
3434

35-
public PropertyType<T> getType() {
36-
return type;
35+
public PropertyType<T> getPropertyType() {
36+
return propertyType;
3737
}
3838

3939
public String getName() {
@@ -81,7 +81,7 @@ public void onExecute(CommandSender sender, Arguments arguments) {
8181

8282
@SuppressWarnings("unchecked")
8383
public List<String> onComplete(CommandSender sender, Arguments arguments) {
84-
return type.complete(sender, arguments, (T) get());
84+
return propertyType.complete(sender, arguments, (T) get());
8585
}
8686

8787
protected abstract void set(CommandSender sender, Arguments arguments);

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected void set(CommandSender sender, Arguments arguments) {
2828
String action = arguments.matchesAny(0, "list operation", ADD, REMOVE, REPLACE);
2929

3030
if (action.equals(ADD)) {
31-
get().add(verify(getType().parse(sender, arguments.subArguments(1), null)));
31+
get().add(verify(propertyType.parse(sender, arguments.subArguments(1), null)));
3232
callback.accept(get());
3333
} else {
3434
int index = arguments.find(1, "position", input -> Integer.parseInt(input.replace("@", "")));
@@ -38,7 +38,7 @@ protected void set(CommandSender sender, Arguments arguments) {
3838
}
3939

4040
if (action.equals(REPLACE)) {
41-
get().set(index, verify(getType().parse(sender, arguments.subArguments(2), null)));
41+
get().set(index, verify(propertyType.parse(sender, arguments.subArguments(2), null)));
4242
callback.accept(get());
4343
} else {
4444
get().remove(index);
@@ -56,15 +56,15 @@ public List<String> onComplete(CommandSender sender, Arguments arguments) {
5656
} else if (arguments.is(0, ADD) || arguments.is(0, REPLACE)) {
5757
// avoid suggesting more than necessary
5858
Arguments data = arguments.subArguments(arguments.is(0, ADD) ? 0 : 1);
59-
List<String> suggestion = getType().complete(sender, data, null);
59+
List<String> suggestion = propertyType.complete(sender, data, null);
6060
return arguments.size() -1 <= suggestion.size() ? suggestion : List.of();
6161
}
6262
return List.of();
6363
}
6464

6565
@Override
6666
public void serialize(@Nonnull ConfigurationSection configuration) {
67-
Optional.ofNullable(get()).ifPresent(value -> configuration.set(getName(), value.stream().map(getType()::serialize).toList()));
67+
Optional.ofNullable(get()).ifPresent(value -> configuration.set(getName(), value.stream().map(propertyType::serialize).toList()));
6868
}
6969

7070
@SuppressWarnings("unchecked")
@@ -73,7 +73,7 @@ public void deserialize(@Nonnull ConfigurationSection configuration) {
7373
List<Object> objects = (List<Object>) configuration.getList(getName());
7474

7575
if (objects != null) {
76-
set(objects.stream().map(object -> getType().deserialize(object)).collect(Collectors.toList()));
76+
set(objects.stream().map(propertyType::deserialize).collect(Collectors.toList()));
7777
} else {
7878
set(new ArrayList<>(getDefault()));
7979
}
@@ -82,14 +82,14 @@ public void deserialize(@Nonnull ConfigurationSection configuration) {
8282
@Override
8383
public boolean equals(Object object) {
8484
if (object instanceof ListProperty<?> property) {
85-
return property.name.equals(name) && property.type.getType().equals(type.getType());
85+
return property.name.equals(name) && property.propertyType.getType().equals(propertyType.getType());
8686
}
8787
return super.equals(object);
8888
}
8989

9090
@Override
9191
public String toString() {
92-
return isSet() ? get().stream().map(getType()::print).collect(Collectors.joining(", ")) : "<empty>";
92+
return isSet() ? get().stream().map(propertyType::print).collect(Collectors.joining(", ")) : "<empty>";
9393
}
9494

9595
public static <T> Builder<T> create(PropertyType<T> type, String name, Supplier<List<T>> defaultValue) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ private Property(PropertyType<T> type, Supplier<T> defaultValue, String name, Li
1919

2020
@Override
2121
protected void set(CommandSender sender, Arguments arguments) {
22-
set(verify(getType().parse(sender, arguments, get())));
22+
set(verify(propertyType.parse(sender, arguments, get())));
2323
callback.accept(get());
2424
}
2525

2626
@Override
2727
public void serialize(@Nonnull ConfigurationSection configuration) {
28-
Optional.ofNullable(get()).ifPresent(value -> configuration.set(getName(), getType().serialize(value)));
28+
Optional.ofNullable(get()).ifPresent(value -> configuration.set(getName(), propertyType.serialize(value)));
2929
}
3030

3131
@Override
3232
public void deserialize(@Nonnull ConfigurationSection configuration) {
33-
Optional.ofNullable(configuration.get(getName())).ifPresent(object -> set(getType().deserialize(object)));
33+
Optional.ofNullable(configuration.get(getName())).ifPresent(object -> set(propertyType.deserialize(object)));
3434
}
3535

3636
@Override
3737
public boolean equals(Object object) {
3838
if (object instanceof Property<?> property) {
39-
return property.name.equals(name) && property.type.getType().equals(type.getType());
39+
return property.name.equals(name) && property.propertyType.getType().equals(propertyType.getType());
4040
}
4141
return super.equals(object);
4242
}
4343

4444
@Override
4545
public String toString() {
46-
return isSet() ? getType().print(get()) : "<empty>";
46+
return isSet() ? propertyType.print(get()) : "<empty>";
4747
}
4848

4949
public static <T> Builder<T> create(PropertyType<T> type, String name, Supplier<T> defaultValue) {

0 commit comments

Comments
 (0)