Make MethodName package-private

Closes gh-28832
This commit is contained in:
Phillip Webb
2022-07-18 11:20:43 +01:00
parent 0ea4ee163c
commit 87b83e8291
5 changed files with 8 additions and 34 deletions

View File

@@ -68,17 +68,6 @@ public class GeneratedMethods {
* @return the newly added {@link GeneratedMethod}
*/
public GeneratedMethod add(String suggestedName, Consumer<Builder> method) {
Assert.notNull(suggestedName, "'suggestedName' must not be null");
return add(MethodName.of(suggestedName), method);
}
/**
* Add a new {@link GeneratedMethod}.
* @param suggestedName the suggested name for the method
* @param method a {@link Consumer} used to build the method
* @return the newly added {@link GeneratedMethod}
*/
public GeneratedMethod add(MethodName suggestedName, Consumer<Builder> method) {
Assert.notNull(suggestedName, "'suggestedName' must not be null");
Assert.notNull(method, "'method' must not be null");
String generatedName = this.methodNameGenerator.apply(this.prefix.and(suggestedName));

View File

@@ -28,7 +28,7 @@ import org.springframework.util.StringUtils;
* @author Phillip Webb
* @since 6.0
*/
public final class MethodName {
final class MethodName {
private static final String[] PREFIXES = { "get", "set", "is" };
@@ -51,7 +51,7 @@ public final class MethodName {
* @param parts the parts the form the name
* @return a method name instance
*/
public static MethodName of(String... parts) {
static MethodName of(String... parts) {
Assert.notNull(parts, "'parts' must not be null");
return new MethodName(join(parts));
}
@@ -61,7 +61,7 @@ public final class MethodName {
* @param name the name to concatenate
* @return a new method name instance
*/
public MethodName and(MethodName name) {
MethodName and(MethodName name) {
Assert.notNull(name, "'name' must not be null");
return and(name.value);
}
@@ -71,7 +71,7 @@ public final class MethodName {
* @param parts the parts to concatenate
* @return a new method name instance
*/
public MethodName and(String... parts) {
MethodName and(String... parts) {
Assert.notNull(parts, "'parts' must not be null");
String joined = join(parts);
String prefix = getPrefix(joined);

View File

@@ -52,20 +52,6 @@ class GeneratedMethodsTests {
assertThat(methods.add("test", methodSpecCustomizer).getName()).hasToString("__test");
}
@Test
void addWithMethodNameWhenSuggestedMethodIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
this.methods.add((MethodName) null, methodSpecCustomizer))
.withMessage("'suggestedName' must not be null");
}
@Test
void addWithMethodNameWhenMethodIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
this.methods.add(MethodName.of("test"), null))
.withMessage("'method' must not be null");
}
@Test
void addWithStringNameWhenSuggestedMethodIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->