diff --git a/configlib-core/src/main/java/de/exlll/configlib/CommentNodeExtractor.java b/configlib-core/src/main/java/de/exlll/configlib/CommentNodeExtractor.java index 403eb56..437a6f8 100644 --- a/configlib-core/src/main/java/de/exlll/configlib/CommentNodeExtractor.java +++ b/configlib-core/src/main/java/de/exlll/configlib/CommentNodeExtractor.java @@ -44,12 +44,12 @@ final class CommentNodeExtractor { while (state.iterator.hasNext()) { final var component = state.iterator.next(); - final var componentValue = component.componentValue(state.componentHolder); + final var componentValue = component.value(state.componentHolder); if ((componentValue == null) && !outputNull) continue; - final var componentName = component.componentName(); + final var componentName = component.name(); final var commentNode = createNodeIfCommentPresent( component.component(), componentName, @@ -57,7 +57,7 @@ final class CommentNodeExtractor { ); commentNode.ifPresent(result::add); - final var componentType = component.componentType(); + final var componentType = component.type(); if ((componentValue != null) && (Reflect.isConfiguration(componentType) || componentType.isRecord())) { diff --git a/configlib-core/src/main/java/de/exlll/configlib/ConfigurationSerializer.java b/configlib-core/src/main/java/de/exlll/configlib/ConfigurationSerializer.java index 92dbbed..828afe9 100644 --- a/configlib-core/src/main/java/de/exlll/configlib/ConfigurationSerializer.java +++ b/configlib-core/src/main/java/de/exlll/configlib/ConfigurationSerializer.java @@ -15,7 +15,7 @@ final class ConfigurationSerializer extends TypeSerializer extends for (int i = 0, size = components.size(); i < size; i++) { final var component = components.get(i); - final var formattedName = formatter.format(component.componentName()); + final var formattedName = formatter.format(component.name()); if (!element.containsKey(formattedName)) { - constructorArguments[i] = Reflect.getDefaultValue(component.componentType()); + constructorArguments[i] = Reflect.getDefaultValue(component.type()); continue; } @@ -34,7 +34,7 @@ final class RecordSerializer extends requireNonPrimitiveComponentType(recordComponent); constructorArguments[i] = null; } else if (serializedValue == null) { - constructorArguments[i] = Reflect.getDefaultValue(component.componentType()); + constructorArguments[i] = Reflect.getDefaultValue(component.type()); } else { constructorArguments[i] = deserialize(component, serializedValue); } @@ -84,4 +84,4 @@ final class RecordSerializer extends Class getRecordType() { return type; } -} \ No newline at end of file +} diff --git a/configlib-core/src/main/java/de/exlll/configlib/TypeComponent.java b/configlib-core/src/main/java/de/exlll/configlib/TypeComponent.java index e9cc786..c3f5d7a 100644 --- a/configlib-core/src/main/java/de/exlll/configlib/TypeComponent.java +++ b/configlib-core/src/main/java/de/exlll/configlib/TypeComponent.java @@ -27,21 +27,21 @@ sealed interface TypeComponent { * * @return name of the component */ - String componentName(); + String name(); /** * Returns the type of the component. * * @return type of the component */ - Class componentType(); + Class type(); /** * Returns the generic type of the component. * * @return generic type of the component */ - Type componentGenericType(); + Type genericType(); /** * Returns the value the component is holding. @@ -51,7 +51,7 @@ sealed interface TypeComponent { * @throws IllegalArgumentException if {@code componentHolder} is not an instance of the type to * which this component belongs */ - Object componentValue(Object componentHolder); + Object value(Object componentHolder); /** * Returns the type that declares this component. @@ -79,22 +79,22 @@ sealed interface TypeComponent { } @Override - public String componentName() { + public String name() { return component.getName(); } @Override - public Class componentType() { + public Class type() { return component.getType(); } @Override - public Type componentGenericType() { + public Type genericType() { return component.getGenericType(); } @Override - public Object componentValue(Object componentHolder) { + public Object value(Object componentHolder) { return Reflect.getValue(component, componentHolder); } @@ -111,22 +111,22 @@ sealed interface TypeComponent { } @Override - public String componentName() { + public String name() { return component.getName(); } @Override - public Class componentType() { + public Class type() { return component.getType(); } @Override - public Type componentGenericType() { + public Type genericType() { return component.getGenericType(); } @Override - public Object componentValue(Object componentHolder) { + public Object value(Object componentHolder) { return Reflect.getValue(component, componentHolder); } diff --git a/configlib-core/src/main/java/de/exlll/configlib/TypeSerializer.java b/configlib-core/src/main/java/de/exlll/configlib/TypeSerializer.java index c047a17..ff9c8ff 100644 --- a/configlib-core/src/main/java/de/exlll/configlib/TypeSerializer.java +++ b/configlib-core/src/main/java/de/exlll/configlib/TypeSerializer.java @@ -35,13 +35,13 @@ sealed abstract class TypeSerializer> final Map result = new LinkedHashMap<>(); for (final TC component : components()) { - final Object componentValue = component.componentValue(element); + final Object componentValue = component.value(element); if ((componentValue == null) && !properties.outputNulls()) continue; final Object serializedValue = serialize(component, componentValue); - final String formattedName = formatter.format(component.componentName()); + final String formattedName = formatter.format(component.name()); result.put(formattedName, serializedValue); } @@ -53,7 +53,7 @@ sealed abstract class TypeSerializer> // are selected based on the component type. @SuppressWarnings("unchecked") final var serializer = (Serializer) - serializers.get(component.componentName()); + serializers.get(component.name()); return (value != null) ? serializer.serialize(value) : null; } @@ -62,7 +62,7 @@ sealed abstract class TypeSerializer> // is deserialized is not a subtype of the type the deserializer expects. @SuppressWarnings("unchecked") final var serializer = (Serializer) - serializers.get(component.componentName()); + serializers.get(component.name()); final Object deserialized; try { diff --git a/configlib-core/src/test/java/de/exlll/configlib/TypeComponentTest.java b/configlib-core/src/test/java/de/exlll/configlib/TypeComponentTest.java index d8a06d1..16bfb0f 100644 --- a/configlib-core/src/test/java/de/exlll/configlib/TypeComponentTest.java +++ b/configlib-core/src/test/java/de/exlll/configlib/TypeComponentTest.java @@ -27,24 +27,24 @@ class TypeComponentTest { @Test void componentName() { - assertThat(COMPONENT.componentName(), is("field")); + assertThat(COMPONENT.name(), is("field")); } @Test void componentType() { - assertThat(COMPONENT.componentType(), equalTo(List.class)); + assertThat(COMPONENT.type(), equalTo(List.class)); } @Test void componentGenericType() { - ParameterizedType type = (ParameterizedType) COMPONENT.componentGenericType(); + ParameterizedType type = (ParameterizedType) COMPONENT.genericType(); Type argument = type.getActualTypeArguments()[0]; assertThat(argument, equalTo(String.class)); } @Test void componentValue() { - assertThat(COMPONENT.componentValue(new C()), is(List.of("20"))); + assertThat(COMPONENT.value(new C()), is(List.of("20"))); } @Test @@ -67,24 +67,24 @@ class TypeComponentTest { @Test void componentName() { - assertThat(COMPONENT.componentName(), is("comp")); + assertThat(COMPONENT.name(), is("comp")); } @Test void componentType() { - assertThat(COMPONENT.componentType(), equalTo(Set.class)); + assertThat(COMPONENT.type(), equalTo(Set.class)); } @Test void componentGenericType() { - ParameterizedType type = (ParameterizedType) COMPONENT.componentGenericType(); + ParameterizedType type = (ParameterizedType) COMPONENT.genericType(); Type argument = type.getActualTypeArguments()[0]; assertThat(argument, equalTo(Integer.class)); } @Test void componentValue() { - assertThat(COMPONENT.componentValue(new R(Set.of(1))), is(Set.of(1))); + assertThat(COMPONENT.value(new R(Set.of(1))), is(Set.of(1))); } @Test