diff options
Diffstat (limited to 'src/main/java/org/zwobble')
| -rw-r--r-- | src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java index ce64b5e..8b89966 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java @@ -98,7 +98,7 @@ public class JavaPreciselyMatchersGenerator implements Generator { matcherTypeName, List.of( JavaTypeRef.topLevelGeneric( - List.of("org", "zwobble", "precisely"), + PRECISELY_PACKAGE_NAME, "Matcher", List.of(JavaTypeRef.OBJECT) ) @@ -108,7 +108,7 @@ public class JavaPreciselyMatchersGenerator implements Generator { "match", JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, - JavaTypeRef.topLevel(List.of("org", "zwobble", "precisely"), "MatchResult"), + MATCH_RESULT_REF, List.of(new JavaParam(JavaTypeRef.OBJECT, "actual")), new JavaBlock(List.of( new JavaReturn( @@ -124,7 +124,7 @@ public class JavaPreciselyMatchersGenerator implements Generator { "describe", JavaVisibility.PUBLIC, JavaMethodKind.INSTANCE, - JavaTypeRef.topLevel(List.of("org", "zwobble", "precisely"), "TextTree"), + JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, "TextTree"), List.of(), new JavaBlock(List.of( new JavaReturn( @@ -140,11 +140,11 @@ public class JavaPreciselyMatchersGenerator implements Generator { "toMatcher", JavaVisibility.PRIVATE, JavaMethodKind.INSTANCE, - JavaTypeRef.topLevelGeneric(List.of("org", "zwobble", "precisely"), "Matcher", List.of(JavaTypeRef.OBJECT)), + matcherRef(JavaTypeRef.OBJECT), List.of(), new JavaBlock(List.of( new JavaReturn(new JavaStaticMethodCall( - JavaTypeRef.topLevel(List.of("org", "zwobble", "precisely"), "Matchers"), + JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, "Matchers"), "instanceOf", List.of(new JavaStaticFieldAccess(javaStructTypeRef, "class")) )) @@ -179,4 +179,13 @@ public class JavaPreciselyMatchersGenerator implements Generator { return this.typesInfo.variants(type); } } + + + private static final List<String> PRECISELY_PACKAGE_NAME = List.of("org", "zwobble", "precisely"); + private static final JavaTypeRef MATCH_RESULT_REF = JavaTypeRef.topLevel(PRECISELY_PACKAGE_NAME, "MatchResult"); + + private static JavaTypeRef matcherRef(JavaTypeRef arg) { + return JavaTypeRef.topLevelGeneric(PRECISELY_PACKAGE_NAME, "Matcher", List.of(arg)); + } + } |
