Skip to content

Commit d0b891d

Browse files
committed
#482 Use "no-arg constructor" everywhere
1 parent 89d1f7e commit d0b891d

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

src/main/java/ch/jalu/configme/SettingsHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* of {@link ch.jalu.configme.properties.Property} type in a class
1111
* which implements this interface.
1212
* <p>
13-
* Classes implementing this interface must have a no-args constructor (any visibility).
13+
* Classes implementing this interface must have a no-arg constructor (any visibility).
1414
*
1515
* @see ch.jalu.configme.properties.PropertyInitializer
1616
* @see ch.jalu.configme.configurationdata.ConfigurationDataBuilder

src/main/java/ch/jalu/configme/configurationdata/ConfigurationDataBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ protected void collectSectionComments(@NotNull Class<? extends SettingsHolder> c
181181
ReflectionHelper.setAccessibleIfNeeded(constructor);
182182
return constructor.newInstance();
183183
} catch (NoSuchMethodException e) {
184-
throw new ConfigMeException("Expected no-args constructor to be available for " + clazz, e);
184+
throw new ConfigMeException("Expected no-arg constructor to be available for " + clazz, e);
185185
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
186186
throw new ConfigMeException("Could not create instance of " + clazz, e);
187187
}

src/main/java/ch/jalu/configme/utils/SettingsHolderClassValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void validateSettingsHolderClassesFinal(@NotNull Iterable<Class<? extends
141141

142142
/**
143143
* Throws an exception if any of the provided setting holder classes does not have a single private
144-
* no-args constructor.
144+
* no-arg constructor.
145145
*
146146
* @param settingHolders the classes to check
147147
*/
@@ -156,7 +156,7 @@ public void validateClassesHaveHiddenNoArgConstructor(
156156
}
157157

158158
if (!invalidClasses.isEmpty()) {
159-
throw new IllegalStateException("The following classes do not have a single no-args private constructor:"
159+
throw new IllegalStateException("The following classes do not have a single no-arg private constructor:"
160160
+ "\n- " + String.join("\n- ", invalidClasses));
161161
}
162162
}

src/test/java/ch/jalu/configme/configurationdata/ConfigurationDataBuilderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ void shouldGetAllProperties() {
6161
void shouldHandleSettingsHolderConstructorIssues() {
6262
ConfigMeException ex;
6363

64-
// Missing no-args constructor
64+
// Missing no-arg constructor
6565
ex = assertThrows(ConfigMeException.class,
66-
() -> ConfigurationDataBuilder.createConfiguration(IllegalSettingsHolderConstructorClasses.MissingNoArgsConstructor.class));
67-
assertThat(ex.getMessage(), startsWith("Expected no-args constructor to be available for class "));
66+
() -> ConfigurationDataBuilder.createConfiguration(IllegalSettingsHolderConstructorClasses.MissingNoArgConstructor.class));
67+
assertThat(ex.getMessage(), startsWith("Expected no-arg constructor to be available for class "));
6868

6969
// Constructor throws exception
7070
ex = assertThrows(ConfigMeException.class,
@@ -79,7 +79,7 @@ void shouldHandleSettingsHolderConstructorIssues() {
7979
// Class is interface
8080
ex = assertThrows(ConfigMeException.class,
8181
() -> ConfigurationDataBuilder.createConfiguration(IllegalSettingsHolderConstructorClasses.InterfaceSettingsHolder.class));
82-
assertThat(ex.getMessage(), startsWith("Expected no-args constructor to be available for interface "));
82+
assertThat(ex.getMessage(), startsWith("Expected no-arg constructor to be available for interface "));
8383
}
8484

8585
@Test

src/test/java/ch/jalu/configme/configurationdata/samples/IllegalSettingsHolderConstructorClasses.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ private IllegalSettingsHolderConstructorClasses() {
1212
}
1313

1414
/**
15-
* Class doesn't have a no-args constructor.
15+
* Class doesn't have a no-arg constructor.
1616
*/
17-
public final static class MissingNoArgsConstructor implements SettingsHolder {
17+
public final static class MissingNoArgConstructor implements SettingsHolder {
1818

19-
MissingNoArgsConstructor(String str) {
19+
MissingNoArgConstructor(String str) {
2020
}
2121
}
2222

src/test/java/ch/jalu/configme/properties/PropertyInitializerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void shouldInstantiateBuilders() {
8989
}
9090

9191
@Test
92-
void shouldHaveAccessibleNoArgsConstructorForExtensions() {
92+
void shouldHaveAccessibleNoArgConstructorForExtensions() {
9393
// given / when
9494
new PropertyInitializer() { };
9595

src/test/java/ch/jalu/configme/samples/settingsholders/SettingsHolderWithInvalidConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class SettingsHolderWithInvalidConstants implements SettingsHolder {
2323
private SettingsHolderWithInvalidConstants() {
2424
}
2525

26-
// used for test ensuring classes only have a sole no-args private constructor
26+
// used for test ensuring classes only have a sole no-arg private constructor
2727
private SettingsHolderWithInvalidConstants(boolean other) {
2828
}
2929

src/test/java/ch/jalu/configme/utils/SettingsHolderClassValidatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void shouldThrowForClassWithoutPrivateConstructor() {
203203
() -> validator.validateClassesHaveHiddenNoArgConstructor(classes));
204204

205205
// then
206-
assertThat(e.getMessage(), equalTo("The following classes do not have a single no-args private constructor:"
206+
assertThat(e.getMessage(), equalTo("The following classes do not have a single no-arg private constructor:"
207207
+ "\n- ch.jalu.configme.samples.settingsholders.SettingsHolderWithEnumPropertyComments"
208208
+ "\n- ch.jalu.configme.samples.settingsholders.SettingsHolderWithInvalidConstants"));
209209
}

0 commit comments

Comments
 (0)