summaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-06-12 16:14:03 +0100
committerMichael Williamson <mike@zwobble.org>2026-06-12 16:14:03 +0100
commit89b30c6837e0fc3021df5e1a33ba362d45760f00 (patch)
tree735be9a63bc01069e5fcf8a5d81eea6776931337 /src/main/java/org
parent49297716e2ccd2ad75bd1f64c9eb788d2754a4fd (diff)
Extract refs
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/generators/javapreciselymatchers/JavaPreciselyMatchersGenerator.java19
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));
+ }
+
}