From 6a1c0c1357d866f7f39636b109d656d6def7fc0c Mon Sep 17 00:00:00 2001 From: Jeremy Kong Date: Mon, 7 Jun 2021 18:56:42 +0100 Subject: [PATCH 1/8] boom --- .../atlasdb/persistent/api/PersistentStore.java | 3 ++- .../atlasdb/transaction/api/GuardedValue.java | 3 ++- .../transaction/api/RowLockDescriptorMapping.java | 3 ++- .../atlasdb/transaction/api/RowReference.java | 3 ++- .../palantir/atlasdb/cache/DefaultOffHeapCache.java | 3 ++- .../atlasdb/table/description/TableMetadata.java | 2 +- .../main/java/com/palantir/common/time/NanoTime.java | 3 ++- .../palantir/atlasdb/factory/TransactionManagers.java | 4 ++-- .../java/com/palantir/paxos/LeaderPingerContext.java | 3 ++- .../main/java/com/palantir/lock/v2/LeadershipId.java | 3 ++- .../lock/v2/StartTransactionWithWatchesResponse.java | 3 ++- .../com/palantir/lock/watch/LockWatchReferences.java | 11 ++++++----- .../com/palantir/lock/watch/LockWatchStateUpdate.java | 5 +++-- .../palantir/lock/watch/TimestampedLockResponse.java | 3 ++- .../timelock/paxos/NetworkClientFactories.java | 2 +- .../lock/watch/ValueAndLockWatchStateUpdate.java | 3 ++- .../paxos/AutobatchingPingableLeaderFactory.java | 3 ++- .../palantir/atlasdb/timelock/TemplateVariables.java | 3 ++- 18 files changed, 39 insertions(+), 24 deletions(-) diff --git a/atlasdb-api/src/main/java/com/palantir/atlasdb/persistent/api/PersistentStore.java b/atlasdb-api/src/main/java/com/palantir/atlasdb/persistent/api/PersistentStore.java index 439447eaa87..04f9175e79a 100644 --- a/atlasdb-api/src/main/java/com/palantir/atlasdb/persistent/api/PersistentStore.java +++ b/atlasdb-api/src/main/java/com/palantir/atlasdb/persistent/api/PersistentStore.java @@ -16,6 +16,7 @@ package com.palantir.atlasdb.persistent.api; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import com.palantir.logsafe.exceptions.SafeIllegalArgumentException; import java.util.List; import java.util.Map; @@ -31,7 +32,7 @@ public interface PersistentStore extends AutoCloseable { * PostgreSQL table or RocksdDb column family. Handle is linked with one underlying store space. */ @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle interface Handle { UUID id(); diff --git a/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/GuardedValue.java b/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/GuardedValue.java index be730953a38..08e3336e06f 100644 --- a/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/GuardedValue.java +++ b/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/GuardedValue.java @@ -16,10 +16,11 @@ package com.palantir.atlasdb.transaction.api; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import org.immutables.value.Value; @Value.Immutable -@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) +@PackageVisibleImmutablesStyle /** * A GuardedValue represents a value with a limited validity window. * diff --git a/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/RowLockDescriptorMapping.java b/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/RowLockDescriptorMapping.java index cc936c417b0..d047dd05177 100644 --- a/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/RowLockDescriptorMapping.java +++ b/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/RowLockDescriptorMapping.java @@ -16,13 +16,14 @@ package com.palantir.atlasdb.transaction.api; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import com.palantir.lock.LockDescriptor; import java.util.Map; import java.util.Optional; import org.immutables.value.Value; @Value.Immutable -@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) +@PackageVisibleImmutablesStyle public abstract class RowLockDescriptorMapping { abstract Map mapping(); diff --git a/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/RowReference.java b/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/RowReference.java index 3168cdd4334..0716053f9d5 100644 --- a/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/RowReference.java +++ b/atlasdb-api/src/main/java/com/palantir/atlasdb/transaction/api/RowReference.java @@ -17,10 +17,11 @@ package com.palantir.atlasdb.transaction.api; import com.palantir.atlasdb.keyvalue.api.TableReference; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import org.immutables.value.Value; @Value.Immutable -@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) +@PackageVisibleImmutablesStyle public interface RowReference { TableReference tableRef(); diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/cache/DefaultOffHeapCache.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/cache/DefaultOffHeapCache.java index 5a80d509c82..ae9fcf74193 100644 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/cache/DefaultOffHeapCache.java +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/cache/DefaultOffHeapCache.java @@ -28,6 +28,7 @@ import com.palantir.atlasdb.autobatch.CoalescingRequestFunction; import com.palantir.atlasdb.autobatch.DisruptorAutobatcher; import com.palantir.atlasdb.persistent.api.PersistentStore; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import com.palantir.common.streams.KeyedStream; import com.palantir.logsafe.exceptions.SafeIllegalArgumentException; import com.palantir.tritium.metrics.registry.MetricName; @@ -190,7 +191,7 @@ private Map.Entry serializeEntry(Map.Entry entry) } @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle interface CacheDescriptor { AtomicInteger currentSize(); diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/TableMetadata.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/TableMetadata.java index 6112eb7720f..c9d4e549fe4 100644 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/TableMetadata.java +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/TableMetadata.java @@ -28,7 +28,7 @@ import org.immutables.value.Value; @Value.Immutable -@Value.Style(get = {"get*", "is*", "has*"}) +@TableMetadataStyle public abstract class TableMetadata implements Persistable { @Value.Default diff --git a/atlasdb-commons/src/main/java/com/palantir/common/time/NanoTime.java b/atlasdb-commons/src/main/java/com/palantir/common/time/NanoTime.java index 2f95f86735f..0bc43a5e156 100644 --- a/atlasdb-commons/src/main/java/com/palantir/common/time/NanoTime.java +++ b/atlasdb-commons/src/main/java/com/palantir/common/time/NanoTime.java @@ -18,12 +18,13 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import java.time.Duration; import java.util.concurrent.locks.LockSupport; import org.immutables.value.Value; @Value.Immutable -@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) +@PackageVisibleImmutablesStyle public abstract class NanoTime implements Comparable { @JsonValue abstract long time(); diff --git a/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java b/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java index 751d5a8e081..e4c21147489 100644 --- a/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java +++ b/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java @@ -134,6 +134,7 @@ import com.palantir.atlasdb.util.MetricsManagers; import com.palantir.atlasdb.versions.AtlasDbVersion; import com.palantir.common.annotation.Output; +import com.palantir.common.annotations.ImmutablesStyles.StagedBuilderStyle; import com.palantir.common.concurrent.PTExecutors; import com.palantir.common.time.Clock; import com.palantir.conjure.java.api.config.service.ServicesConfigBlock; @@ -210,7 +211,7 @@ import org.slf4j.LoggerFactory; @Value.Immutable -@Value.Style(stagedBuilder = true) +@StagedBuilderStyle public abstract class TransactionManagers { private static final int LOGGING_INTERVAL = 60; private static final Logger log = LoggerFactory.getLogger(TransactionManagers.class); @@ -1500,7 +1501,6 @@ private static MultiTableSweepQueueWriter uninitializedTargetedSweeper( } @Value.Immutable - @Value.Style(stagedBuilder = false) public interface LockAndTimestampServices { LockService lock(); diff --git a/leader-election-impl/src/main/java/com/palantir/paxos/LeaderPingerContext.java b/leader-election-impl/src/main/java/com/palantir/paxos/LeaderPingerContext.java index 295217bfb66..c6026fea8f9 100644 --- a/leader-election-impl/src/main/java/com/palantir/paxos/LeaderPingerContext.java +++ b/leader-election-impl/src/main/java/com/palantir/paxos/LeaderPingerContext.java @@ -17,10 +17,11 @@ package com.palantir.paxos; import com.google.common.net.HostAndPort; +import com.palantir.common.annotations.ImmutablesStyles.AllParametersStyle; import org.immutables.value.Value; @Value.Immutable -@Value.Style(allParameters = true) +@AllParametersStyle public interface LeaderPingerContext { T pinger(); diff --git a/lock-api-objects/src/main/java/com/palantir/lock/v2/LeadershipId.java b/lock-api-objects/src/main/java/com/palantir/lock/v2/LeadershipId.java index b5c497e138f..d13448105d4 100644 --- a/lock-api-objects/src/main/java/com/palantir/lock/v2/LeadershipId.java +++ b/lock-api-objects/src/main/java/com/palantir/lock/v2/LeadershipId.java @@ -18,11 +18,12 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import java.util.UUID; import org.immutables.value.Value; @Value.Immutable -@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) +@PackageVisibleImmutablesStyle public abstract class LeadershipId { @JsonValue @Value.Parameter diff --git a/lock-api-objects/src/main/java/com/palantir/lock/v2/StartTransactionWithWatchesResponse.java b/lock-api-objects/src/main/java/com/palantir/lock/v2/StartTransactionWithWatchesResponse.java index 6e882bcb646..56c1c46f82d 100644 --- a/lock-api-objects/src/main/java/com/palantir/lock/v2/StartTransactionWithWatchesResponse.java +++ b/lock-api-objects/src/main/java/com/palantir/lock/v2/StartTransactionWithWatchesResponse.java @@ -18,11 +18,12 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import com.palantir.lock.watch.LockWatchStateUpdate; import org.immutables.value.Value; @Value.Immutable -@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) +@PackageVisibleImmutablesStyle @JsonSerialize(as = ImmutableStartTransactionWithWatchesResponse.class) @JsonDeserialize(as = ImmutableStartTransactionWithWatchesResponse.class) public interface StartTransactionWithWatchesResponse { diff --git a/lock-api-objects/src/main/java/com/palantir/lock/watch/LockWatchReferences.java b/lock-api-objects/src/main/java/com/palantir/lock/watch/LockWatchReferences.java index 6d49fd0fcff..6aa55ba88c4 100644 --- a/lock-api-objects/src/main/java/com/palantir/lock/watch/LockWatchReferences.java +++ b/lock-api-objects/src/main/java/com/palantir/lock/watch/LockWatchReferences.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.common.collect.Range; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import com.palantir.lock.AtlasLockDescriptorRanges; import com.palantir.lock.LockDescriptor; import org.immutables.value.Value; @@ -78,7 +79,7 @@ public interface Visitor { } @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle @JsonDeserialize(as = ImmutableEntireTable.class) @JsonSerialize(as = ImmutableEntireTable.class) @JsonTypeName(EntireTable.TYPE) @@ -95,7 +96,7 @@ public T accept(Visitor visitor) { } @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle @JsonDeserialize(as = ImmutableRowPrefix.class) @JsonSerialize(as = ImmutableRowPrefix.class) @JsonTypeName(RowPrefix.TYPE) @@ -115,7 +116,7 @@ public T accept(Visitor visitor) { } @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle @JsonDeserialize(as = ImmutableRowRange.class) @JsonSerialize(as = ImmutableRowRange.class) @JsonTypeName(RowRange.TYPE) @@ -138,7 +139,7 @@ public T accept(Visitor visitor) { } @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle @JsonDeserialize(as = ImmutableExactRow.class) @JsonSerialize(as = ImmutableExactRow.class) @JsonTypeName(ExactRow.TYPE) @@ -158,7 +159,7 @@ public T accept(Visitor visitor) { } @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle @JsonDeserialize(as = ImmutableExactCell.class) @JsonSerialize(as = ImmutableExactCell.class) @JsonTypeName(ExactCell.TYPE) diff --git a/lock-api-objects/src/main/java/com/palantir/lock/watch/LockWatchStateUpdate.java b/lock-api-objects/src/main/java/com/palantir/lock/watch/LockWatchStateUpdate.java index 25af3769192..c7d2ed11cfb 100644 --- a/lock-api-objects/src/main/java/com/palantir/lock/watch/LockWatchStateUpdate.java +++ b/lock-api-objects/src/main/java/com/palantir/lock/watch/LockWatchStateUpdate.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.google.errorprone.annotations.DoNotMock; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import com.palantir.lock.LockDescriptor; import com.palantir.lock.watch.LockWatchReferences.LockWatchReference; import java.util.List; @@ -63,7 +64,7 @@ static Snapshot snapshot( * last known version. */ @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle @JsonSerialize(as = ImmutableSuccess.class) @JsonDeserialize(as = ImmutableSuccess.class) @JsonTypeName(Success.TYPE) @@ -87,7 +88,7 @@ default T accept(Visitor visitor) { * missed, but contains all of the current lock watch information as the state of the world moving forward. */ @Value.Immutable - @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @PackageVisibleImmutablesStyle @JsonSerialize(as = ImmutableSnapshot.class) @JsonDeserialize(as = ImmutableSnapshot.class) @JsonTypeName(Snapshot.TYPE) diff --git a/lock-api-objects/src/main/java/com/palantir/lock/watch/TimestampedLockResponse.java b/lock-api-objects/src/main/java/com/palantir/lock/watch/TimestampedLockResponse.java index f6a27a23e26..0e1de9fd39e 100644 --- a/lock-api-objects/src/main/java/com/palantir/lock/watch/TimestampedLockResponse.java +++ b/lock-api-objects/src/main/java/com/palantir/lock/watch/TimestampedLockResponse.java @@ -18,12 +18,13 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import com.palantir.lock.v2.LockResponse; import java.util.Optional; import org.immutables.value.Value; @Value.Immutable -@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) +@PackageVisibleImmutablesStyle @JsonSerialize(as = ImmutableTimestampedLockResponse.class) @JsonDeserialize(as = ImmutableTimestampedLockResponse.class) public interface TimestampedLockResponse { diff --git a/timelock-agent/src/main/java/com/palantir/atlasdb/timelock/paxos/NetworkClientFactories.java b/timelock-agent/src/main/java/com/palantir/atlasdb/timelock/paxos/NetworkClientFactories.java index a56467ef308..8ad6a88d8c4 100644 --- a/timelock-agent/src/main/java/com/palantir/atlasdb/timelock/paxos/NetworkClientFactories.java +++ b/timelock-agent/src/main/java/com/palantir/atlasdb/timelock/paxos/NetworkClientFactories.java @@ -24,7 +24,7 @@ import org.immutables.value.Value; @Value.Immutable -@Value.Style(typeInnerBuilder = "DoNotMatch") +@DoNotMatchInnerBuilderStyle public interface NetworkClientFactories { Factory acceptor(); diff --git a/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/lock/watch/ValueAndLockWatchStateUpdate.java b/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/lock/watch/ValueAndLockWatchStateUpdate.java index ae689cfd83e..4c653c16f77 100644 --- a/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/lock/watch/ValueAndLockWatchStateUpdate.java +++ b/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/lock/watch/ValueAndLockWatchStateUpdate.java @@ -16,11 +16,12 @@ package com.palantir.atlasdb.timelock.lock.watch; +import com.palantir.common.annotations.ImmutablesStyles.PackageVisibleImmutablesStyle; import com.palantir.lock.watch.LockWatchStateUpdate; import org.immutables.value.Value; @Value.Immutable -@Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) +@PackageVisibleImmutablesStyle public interface ValueAndLockWatchStateUpdate { @Value.Parameter LockWatchStateUpdate lockWatchStateUpdate(); diff --git a/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/paxos/AutobatchingPingableLeaderFactory.java b/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/paxos/AutobatchingPingableLeaderFactory.java index e7d169a0dc8..2f5dfbbc4fe 100644 --- a/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/paxos/AutobatchingPingableLeaderFactory.java +++ b/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/paxos/AutobatchingPingableLeaderFactory.java @@ -18,6 +18,7 @@ import com.palantir.atlasdb.autobatch.Autobatchers; import com.palantir.atlasdb.autobatch.DisruptorAutobatcher; +import com.palantir.common.annotations.ImmutablesStyles.AllParametersStyle; import com.palantir.common.concurrent.CheckedRejectionExecutorService; import com.palantir.logsafe.SafeArg; import com.palantir.paxos.Client; @@ -138,7 +139,7 @@ public LeaderPingResult pingLeaderWithUuid(UUID uuid) { } @Value.Immutable - @Value.Style(allParameters = true) + @AllParametersStyle interface PingRequest { Client client(); diff --git a/timelock-server/src/testCommon/java/com/palantir/atlasdb/timelock/TemplateVariables.java b/timelock-server/src/testCommon/java/com/palantir/atlasdb/timelock/TemplateVariables.java index 1ed269e5739..5b8ed37f180 100644 --- a/timelock-server/src/testCommon/java/com/palantir/atlasdb/timelock/TemplateVariables.java +++ b/timelock-server/src/testCommon/java/com/palantir/atlasdb/timelock/TemplateVariables.java @@ -16,6 +16,7 @@ package com.palantir.atlasdb.timelock; +import com.palantir.common.annotations.ImmutablesStyles.AttributeBuilderDetectionStyle; import com.palantir.timelock.config.PaxosInstallConfiguration.PaxosLeaderMode; import java.util.List; import java.util.function.UnaryOperator; @@ -26,7 +27,7 @@ @Value.Immutable @Value.Enclosing -@Value.Style(attributeBuilderDetection = true) +@AttributeBuilderDetectionStyle public interface TemplateVariables { int PROXY_OFFSET = 100; From 50e1fe661ee6445a4d05d6f3fbeaa2a198349525 Mon Sep 17 00:00:00 2001 From: Jeremy Kong Date: Mon, 7 Jun 2021 18:56:50 +0100 Subject: [PATCH 2/8] big boom --- .../table/description/TableMetadataStyle.java | 28 ++++++++++++ .../common/annotations/ImmutablesStyles.java | 45 +++++++++++++++++++ .../paxos/DoNotMatchInnerBuilderStyle.java | 28 ++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/TableMetadataStyle.java create mode 100644 atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java create mode 100644 timelock-agent/src/main/java/com/palantir/atlasdb/timelock/paxos/DoNotMatchInnerBuilderStyle.java diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/TableMetadataStyle.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/TableMetadataStyle.java new file mode 100644 index 00000000000..e44b44be2c9 --- /dev/null +++ b/atlasdb-client/src/main/java/com/palantir/atlasdb/table/description/TableMetadataStyle.java @@ -0,0 +1,28 @@ +/* + * (c) Copyright 2021 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.atlasdb.table.description; + +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; + +@Target({ElementType.PACKAGE, ElementType.TYPE}) +@Retention(RetentionPolicy.SOURCE) +@Value.Style(get = {"get*", "is*", "has*"}) +public @interface TableMetadataStyle {} diff --git a/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java b/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java new file mode 100644 index 00000000000..9225357d3f7 --- /dev/null +++ b/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java @@ -0,0 +1,45 @@ +/* + * (c) Copyright 2021 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.common.annotations; + +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; + +public interface ImmutablesStyles { + @Target({ElementType.PACKAGE, ElementType.TYPE}) + @Retention(RetentionPolicy.SOURCE) + @Value.Style(visibility = Value.Style.ImplementationVisibility.PACKAGE) + @interface PackageVisibleImmutablesStyle {} + + @Target({ElementType.PACKAGE, ElementType.TYPE}) + @Retention(RetentionPolicy.SOURCE) + @Value.Style(stagedBuilder = true) + @interface StagedBuilderStyle {} + + @Target({ElementType.PACKAGE, ElementType.TYPE}) + @Retention(RetentionPolicy.SOURCE) + @Value.Style(allParameters = true) + @interface AllParametersStyle {} + + @Target({ElementType.PACKAGE, ElementType.TYPE}) + @Retention(RetentionPolicy.SOURCE) + @Value.Style(attributeBuilderDetection = true) + @interface AttributeBuilderDetectionStyle {} +} diff --git a/timelock-agent/src/main/java/com/palantir/atlasdb/timelock/paxos/DoNotMatchInnerBuilderStyle.java b/timelock-agent/src/main/java/com/palantir/atlasdb/timelock/paxos/DoNotMatchInnerBuilderStyle.java new file mode 100644 index 00000000000..a98d54ebe07 --- /dev/null +++ b/timelock-agent/src/main/java/com/palantir/atlasdb/timelock/paxos/DoNotMatchInnerBuilderStyle.java @@ -0,0 +1,28 @@ +/* + * (c) Copyright 2021 Palantir Technologies Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.palantir.atlasdb.timelock.paxos; + +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; + +@Target({ElementType.PACKAGE, ElementType.TYPE}) +@Retention(RetentionPolicy.SOURCE) +@Value.Style(typeInnerBuilder = "DoNotMatch") +public @interface DoNotMatchInnerBuilderStyle {} From 6903732248e75d0c064bfba495171bb2a4765eab Mon Sep 17 00:00:00 2001 From: Jeremy Kong Date: Mon, 7 Jun 2021 19:24:54 +0100 Subject: [PATCH 3/8] yay tests --- .../com/palantir/common/annotations/ImmutablesStyles.java | 5 +++++ .../com/palantir/atlasdb/factory/TransactionManagers.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java b/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java index 9225357d3f7..ccbe3ae6c23 100644 --- a/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java +++ b/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java @@ -33,6 +33,11 @@ public interface ImmutablesStyles { @Value.Style(stagedBuilder = true) @interface StagedBuilderStyle {} + @Target({ElementType.PACKAGE, ElementType.TYPE}) + @Retention(RetentionPolicy.SOURCE) + @Value.Style(stagedBuilder = false) // Intentional: used for e.g. inner classes of staged builder public classes. + @interface NoStagedBuilderStyle {} + @Target({ElementType.PACKAGE, ElementType.TYPE}) @Retention(RetentionPolicy.SOURCE) @Value.Style(allParameters = true) diff --git a/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java b/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java index e4c21147489..ee47047b87c 100644 --- a/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java +++ b/atlasdb-config/src/main/java/com/palantir/atlasdb/factory/TransactionManagers.java @@ -134,6 +134,7 @@ import com.palantir.atlasdb.util.MetricsManagers; import com.palantir.atlasdb.versions.AtlasDbVersion; import com.palantir.common.annotation.Output; +import com.palantir.common.annotations.ImmutablesStyles.NoStagedBuilderStyle; import com.palantir.common.annotations.ImmutablesStyles.StagedBuilderStyle; import com.palantir.common.concurrent.PTExecutors; import com.palantir.common.time.Clock; @@ -1501,6 +1502,7 @@ private static MultiTableSweepQueueWriter uninitializedTargetedSweeper( } @Value.Immutable + @NoStagedBuilderStyle public interface LockAndTimestampServices { LockService lock(); From 95760dd3dcda7b20615af305153e8a0892083861 Mon Sep 17 00:00:00 2001 From: Jeremy Kong Date: Mon, 7 Jun 2021 19:29:26 +0100 Subject: [PATCH 4/8] wat --- .../java/com/palantir/common/annotations/ImmutablesStyles.java | 1 + 1 file changed, 1 insertion(+) diff --git a/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java b/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java index ccbe3ae6c23..6b4cb29c391 100644 --- a/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java +++ b/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java @@ -36,6 +36,7 @@ public interface ImmutablesStyles { @Target({ElementType.PACKAGE, ElementType.TYPE}) @Retention(RetentionPolicy.SOURCE) @Value.Style(stagedBuilder = false) // Intentional: used for e.g. inner classes of staged builder public classes. + @SuppressWarnings("RedundantModifier") // @interface NoStagedBuilderStyle {} @Target({ElementType.PACKAGE, ElementType.TYPE}) From 9a03d26ea771b0d9ab0b65bc6a55bb3429421274 Mon Sep 17 00:00:00 2001 From: Jeremy Kong Date: Mon, 7 Jun 2021 19:36:45 +0100 Subject: [PATCH 5/8] change --- atlasdb-commons/build.gradle | 1 - .../java/com/palantir/common/annotations/ImmutablesStyles.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/atlasdb-commons/build.gradle b/atlasdb-commons/build.gradle index 83e12f70da1..f0c131b5d05 100644 --- a/atlasdb-commons/build.gradle +++ b/atlasdb-commons/build.gradle @@ -15,7 +15,6 @@ dependencies { compileOnly 'org.immutables:value::annotations' testAnnotationProcessor group: 'org.immutables', name: 'value' - testCompileOnly 'org.immutables:value::annotations' testCompile group: 'junit', name: 'junit' testCompile group: 'org.assertj', name: 'assertj-core' diff --git a/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java b/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java index 6b4cb29c391..60c673a99e3 100644 --- a/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java +++ b/atlasdb-commons/src/main/java/com/palantir/common/annotations/ImmutablesStyles.java @@ -36,7 +36,7 @@ public interface ImmutablesStyles { @Target({ElementType.PACKAGE, ElementType.TYPE}) @Retention(RetentionPolicy.SOURCE) @Value.Style(stagedBuilder = false) // Intentional: used for e.g. inner classes of staged builder public classes. - @SuppressWarnings("RedundantModifier") // + @SuppressWarnings("RedundantModifier") // Unexpected bug in baseline check? @interface NoStagedBuilderStyle {} @Target({ElementType.PACKAGE, ElementType.TYPE}) From 66231a6fdb803db018315f320e5bd56ce3c54428 Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Mon, 7 Jun 2021 18:39:40 +0000 Subject: [PATCH 6/8] Add generated changelog entries --- changelog/@unreleased/pr-5494.v2.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/@unreleased/pr-5494.v2.yml diff --git a/changelog/@unreleased/pr-5494.v2.yml b/changelog/@unreleased/pr-5494.v2.yml new file mode 100644 index 00000000000..8f305ffeef6 --- /dev/null +++ b/changelog/@unreleased/pr-5494.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Immutables annotations now have source retention. + links: + - https://github.com/palantir/atlasdb/pull/5494 From 4557522fc9da30e6fe64ebeb611b7ea0675286ba Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Mon, 7 Jun 2021 18:39:50 +0000 Subject: [PATCH 7/8] Add generated changelog entries --- changelog/@unreleased/pr-5494.v2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/@unreleased/pr-5494.v2.yml b/changelog/@unreleased/pr-5494.v2.yml index 8f305ffeef6..2e4a25e9059 100644 --- a/changelog/@unreleased/pr-5494.v2.yml +++ b/changelog/@unreleased/pr-5494.v2.yml @@ -1,5 +1,5 @@ type: improvement improvement: - description: Immutables annotations now have source retention. + description: Immutables style annotations now have source retention. links: - https://github.com/palantir/atlasdb/pull/5494 From 4dbaf00cfabd062c16de8a5465578942f1965e6a Mon Sep 17 00:00:00 2001 From: Jeremy Kong Date: Mon, 7 Jun 2021 19:40:09 +0100 Subject: [PATCH 8/8] fix --- atlasdb-commons/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/atlasdb-commons/build.gradle b/atlasdb-commons/build.gradle index f0c131b5d05..83e12f70da1 100644 --- a/atlasdb-commons/build.gradle +++ b/atlasdb-commons/build.gradle @@ -15,6 +15,7 @@ dependencies { compileOnly 'org.immutables:value::annotations' testAnnotationProcessor group: 'org.immutables', name: 'value' + testCompileOnly 'org.immutables:value::annotations' testCompile group: 'junit', name: 'junit' testCompile group: 'org.assertj', name: 'assertj-core'