Skip to content

Commit 02d670c

Browse files
author
Carter Kozak
authored
Apply the Jetbrains Pattern annotation to the QosReason ctor (#932)
Apply the Jetbrains Pattern annotation to the QosReason ctor
1 parent d5f0952 commit 02d670c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type: improvement
2+
improvement:
3+
description: Apply the Jetbrains Pattern annotation to the QosReason ctor
4+
links:
5+
- https://github.com/palantir/conjure-java-runtime-api/pull/932

errors/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies {
77
api "com.fasterxml.jackson.core:jackson-databind"
88
api "com.google.code.findbugs:jsr305"
99
api "com.palantir.safe-logging:safe-logging"
10+
api "org.jetbrains:annotations"
1011
implementation "com.palantir.safe-logging:preconditions"
1112

1213
testImplementation project(":extras:jackson-support")

errors/src/main/java/com/palantir/conjure/java/api/errors/QosReason.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ public final class QosReason {
3535
@CompileTimeConstant
3636
private final String reason;
3737

38-
private static final Pattern PATTERN = Pattern.compile("^[a-z0-9\\-]{1,50}$");
38+
private static final String PATTERN_STRING = "^[a-z0-9\\-]{1,50}$";
39+
private static final Pattern PATTERN = Pattern.compile(PATTERN_STRING);
3940

4041
private QosReason(@CompileTimeConstant String reason) {
4142
this.reason = reason;
4243
}
4344

44-
public static QosReason of(@CompileTimeConstant String reason) {
45+
public static QosReason of(
46+
@CompileTimeConstant @org.intellij.lang.annotations.Pattern(PATTERN_STRING) String reason) {
4547
Preconditions.checkArgument(
4648
PATTERN.matcher(reason).matches(),
4749
"Reason must be at most 50 characters, and only contain lowercase letters, numbers, "

0 commit comments

Comments
 (0)