diff --git a/changelog/@unreleased/pr-481.v2.yml b/changelog/@unreleased/pr-481.v2.yml new file mode 100644 index 00000000..fe52ac88 --- /dev/null +++ b/changelog/@unreleased/pr-481.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Apply automatic fixes for error-prone `ImmutablesStyle` + links: + - https://github.com/palantir/metric-schema/pull/481 diff --git a/metric-schema-java/src/main/java/com/palantir/metric/schema/JavaGeneratorArgs.java b/metric-schema-java/src/main/java/com/palantir/metric/schema/JavaGeneratorArgs.java index abc7cab3..97c0c404 100644 --- a/metric-schema-java/src/main/java/com/palantir/metric/schema/JavaGeneratorArgs.java +++ b/metric-schema-java/src/main/java/com/palantir/metric/schema/JavaGeneratorArgs.java @@ -18,18 +18,18 @@ import com.palantir.logsafe.Preconditions; import com.palantir.logsafe.SafeArg; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.nio.file.Path; import java.util.Optional; import java.util.function.Predicate; import java.util.regex.Pattern; import org.immutables.value.Value; +@JavaGeneratorArgsStyle @Value.Immutable -@Value.Style( - visibility = Value.Style.ImplementationVisibility.PACKAGE, - overshadowImplementation = true, - jdkOnly = true, - get = {"get*", "is*"}) public abstract class JavaGeneratorArgs { private static final Predicate LIBRARY_NAME = @@ -67,3 +67,13 @@ public static Builder builder() { return new Builder(); } } + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.SOURCE) +@SuppressWarnings({"checkstyle:OuterTypeFilename", "checkstyle:OneTopLevelClass"}) +@Value.Style( + visibility = Value.Style.ImplementationVisibility.PACKAGE, + overshadowImplementation = true, + jdkOnly = true, + get = {"get*", "is*"}) +@interface JavaGeneratorArgsStyle {} diff --git a/metric-schema-markdown/src/main/java/com/palantir/metric/schema/markdown/Namespace.java b/metric-schema-markdown/src/main/java/com/palantir/metric/schema/markdown/Namespace.java index 7b8c94de..fd9f0548 100644 --- a/metric-schema-markdown/src/main/java/com/palantir/metric/schema/markdown/Namespace.java +++ b/metric-schema-markdown/src/main/java/com/palantir/metric/schema/markdown/Namespace.java @@ -19,13 +19,14 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.palantir.metric.schema.MetricNamespace; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import org.immutables.value.Value; +@NamespaceStyle @Value.Immutable -@Value.Style( - overshadowImplementation = true, - jdkOnly = true, - get = {"get*", "is*"}) @JsonDeserialize(as = ImmutableNamespace.class) @JsonSerialize(as = ImmutableNamespace.class) interface Namespace { @@ -40,3 +41,12 @@ static Builder builder() { return new Builder(); } } + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.SOURCE) +@SuppressWarnings({"checkstyle:OuterTypeFilename", "checkstyle:OneTopLevelClass"}) +@Value.Style( + overshadowImplementation = true, + jdkOnly = true, + get = {"get*", "is*"}) +@interface NamespaceStyle {} diff --git a/metric-schema-markdown/src/main/java/com/palantir/metric/schema/markdown/Section.java b/metric-schema-markdown/src/main/java/com/palantir/metric/schema/markdown/Section.java index 14fd42c2..ccd80b72 100644 --- a/metric-schema-markdown/src/main/java/com/palantir/metric/schema/markdown/Section.java +++ b/metric-schema-markdown/src/main/java/com/palantir/metric/schema/markdown/Section.java @@ -18,14 +18,15 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.List; import org.immutables.value.Value; +@SectionStyle @Value.Immutable -@Value.Style( - overshadowImplementation = true, - jdkOnly = true, - get = {"get*", "is*"}) @JsonDeserialize(as = ImmutableSection.class) @JsonSerialize(as = ImmutableSection.class) interface Section { @@ -40,3 +41,12 @@ static Builder builder() { return new Builder(); } } + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.SOURCE) +@SuppressWarnings({"checkstyle:OuterTypeFilename", "checkstyle:OneTopLevelClass"}) +@Value.Style( + overshadowImplementation = true, + jdkOnly = true, + get = {"get*", "is*"}) +@interface SectionStyle {}