Polishing

This commit is contained in:
Phillip Webb
2022-07-18 15:01:32 +01:00
parent 444e06fa22
commit 578f155809
3 changed files with 17 additions and 5 deletions

View File

@@ -69,13 +69,25 @@ public class GeneratedMethods {
*/
public GeneratedMethod add(String suggestedName, Consumer<Builder> method) {
Assert.notNull(suggestedName, "'suggestedName' must not be null");
return add(new String[] { suggestedName }, method);
}
/**
* Add a new {@link GeneratedMethod}.
* @param suggestedNameParts the suggested name parts for the method
* @param method a {@link Consumer} used to build method
* @return the newly added {@link GeneratedMethod}
*/
public GeneratedMethod add(String[] suggestedNameParts, Consumer<Builder> method) {
Assert.notNull(suggestedNameParts, "'suggestedNameParts' must not be null");
Assert.notNull(method, "'method' must not be null");
String generatedName = this.methodNameGenerator.apply(this.prefix.and(suggestedName));
String generatedName = this.methodNameGenerator.apply(this.prefix.and(suggestedNameParts));
GeneratedMethod generatedMethod = new GeneratedMethod(generatedName, method);
this.generatedMethods.add(generatedMethod);
return generatedMethod;
}
public GeneratedMethods withPrefix(String prefix) {
Assert.notNull(prefix, "'prefix' must not be null");
return new GeneratedMethods(this.methodNameGenerator, this.prefix.and(prefix), this.generatedMethods);