From 7e24c57dc8c881b9ec20f2053957d585605ad4c1 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Tue, 29 Dec 2020 12:39:08 -0300 Subject: [PATCH 1/4] Adjust lombok annotations to reduce build warnings This change fixes the underlying problems behind five compiler warnings: "Generating equals/hashCode implementation but without a call to superclass". Some core classes use @Value and @Data annotations where not necessary, for example, where equals, hashCode, and toString are implemented by the developer, and where final class and field modifiers are defined by the developer. From lombok classes and documents for the shortcut annotations @Value https://projectlombok.org/features/Value and @Data https://projectlombok.org/features/Data, we find some implicit annotations applied by these shortcuts are not needed. Adjustments are described below. - Tx Replace @Value with @Getter. - TxOutput Replace @Data with @Getter and @Setter. - ChangeParamProposal Replace @Value with @Getter. - GetInventoryRequest, GetInventoryResponse An @EqualsAndHashCode(callSuper = false) is added to supress build warnings. --- .../main/java/bisq/core/dao/state/model/blockchain/Tx.java | 4 ++-- .../java/bisq/core/dao/state/model/blockchain/TxOutput.java | 6 ++++-- .../dao/state/model/governance/ChangeParamProposal.java | 6 ++++-- .../network/p2p/inventory/messages/GetInventoryRequest.java | 2 ++ .../p2p/inventory/messages/GetInventoryResponse.java | 2 ++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/dao/state/model/blockchain/Tx.java b/core/src/main/java/bisq/core/dao/state/model/blockchain/Tx.java index 48c1d4979e8..a90db560481 100644 --- a/core/src/main/java/bisq/core/dao/state/model/blockchain/Tx.java +++ b/core/src/main/java/bisq/core/dao/state/model/blockchain/Tx.java @@ -29,7 +29,7 @@ import java.util.Optional; import java.util.stream.Collectors; -import lombok.Value; +import lombok.Getter; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; @@ -39,7 +39,7 @@ * Gets persisted. */ @Immutable -@Value +@Getter public final class Tx extends BaseTx implements PersistablePayload, ImmutableDaoStateModel { // Created after parsing of a tx is completed. We store only the immutable tx in the block. public static Tx fromTempTx(TempTx tempTx) { diff --git a/core/src/main/java/bisq/core/dao/state/model/blockchain/TxOutput.java b/core/src/main/java/bisq/core/dao/state/model/blockchain/TxOutput.java index 4cdc953661a..d35956e7e68 100644 --- a/core/src/main/java/bisq/core/dao/state/model/blockchain/TxOutput.java +++ b/core/src/main/java/bisq/core/dao/state/model/blockchain/TxOutput.java @@ -24,7 +24,8 @@ import java.util.Objects; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; @@ -36,7 +37,8 @@ * Gets persisted. */ @Immutable -@Data +@Getter +@Setter public class TxOutput extends BaseTxOutput implements PersistablePayload, ImmutableDaoStateModel { public static TxOutput fromTempOutput(TempTxOutput tempTxOutput) { return new TxOutput(tempTxOutput.getIndex(), diff --git a/core/src/main/java/bisq/core/dao/state/model/governance/ChangeParamProposal.java b/core/src/main/java/bisq/core/dao/state/model/governance/ChangeParamProposal.java index 243ec18f713..04972fe150e 100644 --- a/core/src/main/java/bisq/core/dao/state/model/governance/ChangeParamProposal.java +++ b/core/src/main/java/bisq/core/dao/state/model/governance/ChangeParamProposal.java @@ -29,14 +29,16 @@ import java.util.Map; import java.util.Objects; -import lombok.Value; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.experimental.FieldDefaults; import lombok.extern.slf4j.Slf4j; import javax.annotation.concurrent.Immutable; @Immutable @Slf4j -@Value +@Getter public final class ChangeParamProposal extends Proposal implements ImmutableDaoStateModel { private final Param param; private final String paramValue; diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java index fee7f827040..125730e9125 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java @@ -21,9 +21,11 @@ import bisq.common.app.Version; import bisq.common.proto.network.NetworkEnvelope; +import lombok.EqualsAndHashCode; import lombok.Value; @Value +@EqualsAndHashCode(callSuper = false) public class GetInventoryRequest extends NetworkEnvelope { private final String version; diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java index b9c5cf9ce34..4abf04c2045 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java @@ -28,9 +28,11 @@ import java.util.HashMap; import java.util.Map; +import lombok.EqualsAndHashCode; import lombok.Value; @Value +@EqualsAndHashCode(callSuper = false) public class GetInventoryResponse extends NetworkEnvelope { private final Map inventory; From bb07f1099009f5cf8f6d8664fd6e30ba34be9aef Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Tue, 29 Dec 2020 12:52:03 -0300 Subject: [PATCH 2/4] Remove unused imports --- .../core/dao/state/model/governance/ChangeParamProposal.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/src/main/java/bisq/core/dao/state/model/governance/ChangeParamProposal.java b/core/src/main/java/bisq/core/dao/state/model/governance/ChangeParamProposal.java index 04972fe150e..d39fc726044 100644 --- a/core/src/main/java/bisq/core/dao/state/model/governance/ChangeParamProposal.java +++ b/core/src/main/java/bisq/core/dao/state/model/governance/ChangeParamProposal.java @@ -29,9 +29,7 @@ import java.util.Map; import java.util.Objects; -import lombok.AccessLevel; import lombok.Getter; -import lombok.experimental.FieldDefaults; import lombok.extern.slf4j.Slf4j; import javax.annotation.concurrent.Immutable; From c2c1ac2087a8862dbf02007adf299aba460f92f5 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sun, 3 Jan 2021 12:01:10 -0300 Subject: [PATCH 3/4] Adjust class level annoations as per suggested changes https://github.com/bisq-network/bisq/pull/5021#discussion_r550903787 https://github.com/bisq-network/bisq/pull/5021#discussion_r550903843 https://github.com/bisq-network/bisq/pull/5021#discussion_r550903860 --- .../bisq/core/dao/state/model/blockchain/TxOutput.java | 2 -- .../p2p/inventory/messages/GetInventoryRequest.java | 8 ++++---- .../p2p/inventory/messages/GetInventoryResponse.java | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/bisq/core/dao/state/model/blockchain/TxOutput.java b/core/src/main/java/bisq/core/dao/state/model/blockchain/TxOutput.java index d35956e7e68..566216314ef 100644 --- a/core/src/main/java/bisq/core/dao/state/model/blockchain/TxOutput.java +++ b/core/src/main/java/bisq/core/dao/state/model/blockchain/TxOutput.java @@ -25,7 +25,6 @@ import java.util.Objects; import lombok.Getter; -import lombok.Setter; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; @@ -38,7 +37,6 @@ */ @Immutable @Getter -@Setter public class TxOutput extends BaseTxOutput implements PersistablePayload, ImmutableDaoStateModel { public static TxOutput fromTempOutput(TempTxOutput tempTxOutput) { return new TxOutput(tempTxOutput.getIndex(), diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java index 125730e9125..a8cbde00612 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java @@ -21,11 +21,11 @@ import bisq.common.app.Version; import bisq.common.proto.network.NetworkEnvelope; -import lombok.EqualsAndHashCode; -import lombok.Value; +import lombok.Getter; +import lombok.ToString; -@Value -@EqualsAndHashCode(callSuper = false) +@Getter +@ToString public class GetInventoryRequest extends NetworkEnvelope { private final String version; diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java index 4abf04c2045..47a64fead4c 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java @@ -28,11 +28,11 @@ import java.util.HashMap; import java.util.Map; -import lombok.EqualsAndHashCode; -import lombok.Value; +import lombok.Getter; +import lombok.ToString; -@Value -@EqualsAndHashCode(callSuper = false) +@Getter +@ToString public class GetInventoryResponse extends NetworkEnvelope { private final Map inventory; From 0c9c96165b2df15d9bd4c8a671d3083192f11403 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sun, 3 Jan 2021 13:39:37 -0300 Subject: [PATCH 4/4] Re-add @EqualsAndHashCode --- .../network/p2p/inventory/messages/GetInventoryRequest.java | 2 ++ .../network/p2p/inventory/messages/GetInventoryResponse.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java index a8cbde00612..7b46d04fecc 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryRequest.java @@ -21,10 +21,12 @@ import bisq.common.app.Version; import bisq.common.proto.network.NetworkEnvelope; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @Getter +@EqualsAndHashCode(callSuper = false) @ToString public class GetInventoryRequest extends NetworkEnvelope { private final String version; diff --git a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java index 47a64fead4c..2dd79bfc1d4 100644 --- a/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java +++ b/core/src/main/java/bisq/core/network/p2p/inventory/messages/GetInventoryResponse.java @@ -28,10 +28,12 @@ import java.util.HashMap; import java.util.Map; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @Getter +@EqualsAndHashCode(callSuper = false) @ToString public class GetInventoryResponse extends NetworkEnvelope { private final Map inventory;