Skip to content

Commit

Permalink
quality
Browse files Browse the repository at this point in the history
  • Loading branch information
boretti committed Apr 22, 2018
1 parent 06a15d2 commit 3462b1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ private String getDslInterfaceMatcherDescription() {
private String generateAsPublicInterface() {
String fully = getFullyQualifiedNameOfClassAnnotatedWithProvideMatcherWithGeneric();
String otherMatcher = "org.hamcrest.Matcher<? super " + fully + "> otherMatcher";
String interfaceWithGeneric = getSimpleNameOfGeneratedInterfaceMatcherWithGenericParent();

StringBuilder sb = new StringBuilder(JAVADOC_ANDWITH).append(" ")
.append(getSimpleNameOfGeneratedInterfaceMatcherWithGenericParent()).append(" andWith(")
.append(otherMatcher).append(");\n\n");
StringBuilder sb = new StringBuilder(JAVADOC_ANDWITH).append(" ").append(interfaceWithGeneric)
.append(" andWith(").append(otherMatcher).append(");\n\n");

sb.append(JAVADOC_ANDWITHAS).append(" default <_TARGETOBJECT> ")
.append(getSimpleNameOfGeneratedInterfaceMatcherWithGenericParent())
sb.append(JAVADOC_ANDWITHAS).append(" default <_TARGETOBJECT> ").append(interfaceWithGeneric)
.append(" andWithAs(java.util.function.Function<").append(fully)
.append(",_TARGETOBJECT> converter,org.hamcrest.Matcher<? super _TARGETOBJECT> otherMatcher) {\n")
.append(" return andWith(asFeatureMatcher(\" <object is converted> \",converter,otherMatcher));\n")
Expand Down Expand Up @@ -191,20 +190,20 @@ private String generateMainParentPublicInterface() {
}

private String generateMainBuildPublicInterface() {
String fullyWithGeneric = getFullyQualifiedNameOfClassAnnotatedWithProvideMatcherWithGeneric();
return new StringBuilder(addPrefix(" ",
generateJavaDoc(getDslInterfaceMatcherDescription() + " to support the build syntaxic sugar",
Optional.empty(), Optional.empty(), Optional.empty(), true, false)))
.append("\n public static interface ").append(simpleNameOfGeneratedInterfaceMatcher)
.append("BuildSyntaxicSugar").append(fullGeneric)
.append(" extends org.hamcrest.Matcher<")
.append(getFullyQualifiedNameOfClassAnnotatedWithProvideMatcherWithGeneric()).append(
.append(fullyWithGeneric).append(
"> {\n")
.append(addPrefix(" ",
generateJavaDocWithoutParamNeitherParent("Method that return the matcher itself.",
JAVADOC_WARNING_SYNTAXIC_SUGAR_NO_CHANGE_ANYMORE, Optional.empty(),
Optional.of("the matcher"))))
.append("\n default org.hamcrest.Matcher<")
.append(getFullyQualifiedNameOfClassAnnotatedWithProvideMatcherWithGeneric())
.append("\n default org.hamcrest.Matcher<").append(fullyWithGeneric)
.append("> build() {\n return this;\n }\n }\n").toString();
}

Expand Down Expand Up @@ -295,6 +294,10 @@ public String getSimpleNameOfGeneratedImplementationMatcher() {
public String getSimpleNameOfGeneratedImplementationMatcherWithGenericNoParent() {
return getSimpleNameOfGeneratedImplementationMatcher() + getGenericNoParent();
}

public String getSimpleNameOfGeneratedImplementationMatcherWithGenericParent() {
return getSimpleNameOfGeneratedImplementationMatcher() + getGenericParent();
}

public RoundMirror getRoundMirror() {
return roundMirror;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,16 @@ public Collection<DSLMethod> generateDSLStarter() {
}

public String getDefaultStarterBody(boolean withParentBuilder) {
String targetImpl = withParentBuilder ? getSimpleNameOfGeneratedImplementationMatcherWithGenericParent()
: getSimpleNameOfGeneratedImplementationMatcherWithGenericNoParent();
if (withParentBuilder) {
return fullyQualifiedNameOfSuperClassOfClassAnnotatedWithProvideMatcher.isPresent()
? ("return new " + getSimpleNameOfGeneratedImplementationMatcher() + getGenericParent()
+ "(org.hamcrest.Matchers.anything(),parentBuilder);")
: ("return new " + getSimpleNameOfGeneratedImplementationMatcher() + getGenericParent()
+ "(parentBuilder);");
? ("return new " + targetImpl + "(org.hamcrest.Matchers.anything(),parentBuilder);")
: ("return new " + targetImpl + "(parentBuilder);");
} else {
return fullyQualifiedNameOfSuperClassOfClassAnnotatedWithProvideMatcher.isPresent()
? ("return new " + getSimpleNameOfGeneratedImplementationMatcherWithGenericNoParent()
+ "(org.hamcrest.Matchers.anything());")
: ("return new " + getSimpleNameOfGeneratedImplementationMatcherWithGenericNoParent() + "();");
? ("return new " + targetImpl + "(org.hamcrest.Matchers.anything());")
: ("return new " + targetImpl + "();");
}
}

Expand Down

0 comments on commit 3462b1b

Please sign in to comment.