From 252eef5c9fc4fdf1739a1758a9204b3b0f7c4b1c Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Sat, 30 Mar 2019 11:33:37 -0700 Subject: [PATCH] Use JDK7+ Objects.hash() and equals() rather than the Guava variants. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Guava variants are “deprecated” for JDK7+. (cherry picked from commit 686a10ccd2c6bd06a7c785e1c637b611a6b8c0d0) Signed-off-by: HashEngineering --- core/src/main/java/org/bitcoinj/core/Address.java | 4 ++-- .../main/java/org/bitcoinj/core/BloomFilter.java | 4 ++-- core/src/main/java/org/bitcoinj/core/ECKey.java | 14 +++++++------- .../main/java/org/bitcoinj/core/FilteredBlock.java | 3 +-- .../java/org/bitcoinj/core/GetUTXOsMessage.java | 4 ++-- .../main/java/org/bitcoinj/core/InventoryItem.java | 4 ++-- .../java/org/bitcoinj/core/NetworkParameters.java | 6 ++++-- .../java/org/bitcoinj/core/PartialMerkleTree.java | 4 ++-- core/src/main/java/org/bitcoinj/core/Peer.java | 9 ++++----- .../main/java/org/bitcoinj/core/PeerAddress.java | 4 ++-- .../bitcoinj/core/PrefixedChecksummedBytes.java | 4 ++-- .../main/java/org/bitcoinj/core/RejectMessage.java | 4 ++-- .../main/java/org/bitcoinj/core/StoredBlock.java | 4 ++-- .../java/org/bitcoinj/core/TransactionInput.java | 4 ++-- .../org/bitcoinj/core/TransactionOutPoint.java | 4 ++-- .../java/org/bitcoinj/core/TransactionOutput.java | 4 ++-- core/src/main/java/org/bitcoinj/core/UTXO.java | 4 ++-- .../main/java/org/bitcoinj/core/UTXOsMessage.java | 4 ++-- .../java/org/bitcoinj/core/VersionMessage.java | 4 ++-- .../java/org/bitcoinj/crypto/DeterministicKey.java | 6 +++--- .../java/org/bitcoinj/crypto/EncryptedData.java | 4 ++-- .../java/org/bitcoinj/crypto/KeyCrypterScrypt.java | 6 +++--- .../bitcoinj/crypto/bls/BLSDeterministicKey.java | 6 +++--- .../main/java/org/bitcoinj/crypto/bls/BLSKey.java | 12 ++++++------ .../crypto/ed25519/Ed25519DeterministicKey.java | 6 +++--- .../org/bitcoinj/crypto/ed25519/Ed25519Key.java | 8 ++++---- .../main/java/org/bitcoinj/script/ScriptChunk.java | 4 ++-- .../bitcoinj/store/MemoryFullPrunedBlockStore.java | 5 ++--- .../java/org/bitcoinj/utils/BtcFixedFormat.java | 4 ++-- .../main/java/org/bitcoinj/utils/BtcFormat.java | 4 ++-- .../main/java/org/bitcoinj/utils/ExchangeRate.java | 6 +++--- core/src/main/java/org/bitcoinj/utils/Fiat.java | 4 ++-- .../org/bitcoinj/wallet/DeterministicSeed.java | 8 ++++---- .../protocols/channels/ChannelTestUtils.java | 6 +++--- 34 files changed, 90 insertions(+), 91 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/Address.java b/core/src/main/java/org/bitcoinj/core/Address.java index 798f99b0f3..65976b7d6d 100644 --- a/core/src/main/java/org/bitcoinj/core/Address.java +++ b/core/src/main/java/org/bitcoinj/core/Address.java @@ -30,7 +30,7 @@ import org.bitcoinj.script.Script.ScriptType; import org.bitcoinj.script.ScriptPattern; -import com.google.common.base.Objects; +import java.util.Objects; /** *

A Bitcoin address looks like 1MsScoe2fTJoq4ZPdQgqyhgWeoNamYPevy and is derived from an elliptic curve public key @@ -284,7 +284,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), p2sh); + return Objects.hash(super.hashCode(), p2sh); } @Override diff --git a/core/src/main/java/org/bitcoinj/core/BloomFilter.java b/core/src/main/java/org/bitcoinj/core/BloomFilter.java index bdb99c9cde..f008d52b7d 100644 --- a/core/src/main/java/org/bitcoinj/core/BloomFilter.java +++ b/core/src/main/java/org/bitcoinj/core/BloomFilter.java @@ -23,7 +23,6 @@ import org.bitcoinj.script.ScriptPattern; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.collect.Lists; import java.io.IOException; @@ -31,6 +30,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.Math.*; @@ -373,7 +373,7 @@ public synchronized boolean equals(Object o) { @Override public synchronized int hashCode() { - return Objects.hashCode(hashFuncs, nTweak, Arrays.hashCode(data)); + return Objects.hash(hashFuncs, nTweak, Arrays.hashCode(data)); } public final byte[] getData() { diff --git a/core/src/main/java/org/bitcoinj/core/ECKey.java b/core/src/main/java/org/bitcoinj/core/ECKey.java index 39c293cf2a..01352fe52f 100644 --- a/core/src/main/java/org/bitcoinj/core/ECKey.java +++ b/core/src/main/java/org/bitcoinj/core/ECKey.java @@ -25,7 +25,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.primitives.UnsignedBytes; import org.bitcoin.NativeSecp256k1; @@ -62,6 +61,7 @@ import java.security.SignatureException; import java.util.Arrays; import java.util.Comparator; +import java.util.Objects; import static com.google.common.base.Preconditions.*; @@ -611,7 +611,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(r, s); + return Objects.hash(r, s); } } @@ -1340,11 +1340,11 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ECKey)) return false; ECKey other = (ECKey) o; - return Objects.equal(this.priv, other.priv) - && Objects.equal(this.pub, other.pub) - && Objects.equal(this.creationTimeSeconds, other.creationTimeSeconds) - && Objects.equal(this.keyCrypter, other.keyCrypter) - && Objects.equal(this.encryptedPrivateKey, other.encryptedPrivateKey); + return Objects.equals(this.priv, other.priv) + && Objects.equals(this.pub, other.pub) + && Objects.equals(this.creationTimeSeconds, other.creationTimeSeconds) + && Objects.equals(this.keyCrypter, other.keyCrypter) + && Objects.equals(this.encryptedPrivateKey, other.encryptedPrivateKey); } @Override diff --git a/core/src/main/java/org/bitcoinj/core/FilteredBlock.java b/core/src/main/java/org/bitcoinj/core/FilteredBlock.java index bb570617a0..b121783a82 100644 --- a/core/src/main/java/org/bitcoinj/core/FilteredBlock.java +++ b/core/src/main/java/org/bitcoinj/core/FilteredBlock.java @@ -17,7 +17,6 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; import java.io.IOException; import java.io.OutputStream; import java.util.*; @@ -136,7 +135,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(associatedTransactions, header, merkleTree); + return Objects.hash(associatedTransactions, header, merkleTree); } @Override diff --git a/core/src/main/java/org/bitcoinj/core/GetUTXOsMessage.java b/core/src/main/java/org/bitcoinj/core/GetUTXOsMessage.java index 200a241299..98f455da4f 100644 --- a/core/src/main/java/org/bitcoinj/core/GetUTXOsMessage.java +++ b/core/src/main/java/org/bitcoinj/core/GetUTXOsMessage.java @@ -16,12 +16,12 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import java.io.IOException; import java.io.OutputStream; import java.util.List; +import java.util.Objects; /** *

This command is supported only by Bitcoin XT nodes, which @@ -100,6 +100,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(includeMempool, outPoints); + return Objects.hash(includeMempool, outPoints); } } diff --git a/core/src/main/java/org/bitcoinj/core/InventoryItem.java b/core/src/main/java/org/bitcoinj/core/InventoryItem.java index bae60c72fc..d318d56597 100644 --- a/core/src/main/java/org/bitcoinj/core/InventoryItem.java +++ b/core/src/main/java/org/bitcoinj/core/InventoryItem.java @@ -16,7 +16,7 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; +import java.util.Objects; public class InventoryItem { @@ -86,6 +86,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(type, hash); + return Objects.hash(type, hash); } } diff --git a/core/src/main/java/org/bitcoinj/core/NetworkParameters.java b/core/src/main/java/org/bitcoinj/core/NetworkParameters.java index 2d53c71ec0..3ebeff0e7f 100644 --- a/core/src/main/java/org/bitcoinj/core/NetworkParameters.java +++ b/core/src/main/java/org/bitcoinj/core/NetworkParameters.java @@ -17,8 +17,10 @@ package org.bitcoinj.core; +import org.bitcoinj.core.Block; +import org.bitcoinj.core.StoredBlock; +import org.bitcoinj.core.VerificationException; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Objects; import org.bitcoinj.net.discovery.*; import org.bitcoinj.params.*; import org.bitcoinj.script.*; @@ -298,7 +300,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(getId()); + return Objects.hash(getId()); } /** Returns the network parameters for the given string ID or NULL if not recognized. */ diff --git a/core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java b/core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java index 7d402e513d..01f06441ed 100644 --- a/core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java +++ b/core/src/main/java/org/bitcoinj/core/PartialMerkleTree.java @@ -23,9 +23,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import static org.bitcoinj.core.Utils.*; -import com.google.common.base.Objects; /** *

A data structure that contains proofs of block inclusion for one or more transactions, in an efficient manner.

@@ -275,7 +275,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(transactionCount, hashes, Arrays.hashCode(matchedChildBits)); + return Objects.hash(transactionCount, hashes, Arrays.hashCode(matchedChildBits)); } @Override diff --git a/core/src/main/java/org/bitcoinj/core/Peer.java b/core/src/main/java/org/bitcoinj/core/Peer.java index 20185654f9..997707fe3a 100644 --- a/core/src/main/java/org/bitcoinj/core/Peer.java +++ b/core/src/main/java/org/bitcoinj/core/Peer.java @@ -16,9 +16,6 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; -import com.google.common.collect.Lists; - import org.bitcoinj.coinjoin.CoinJoinQueue; import org.bitcoinj.core.listeners.*; import org.bitcoinj.evolution.SimplifiedMasternodeListDiff; @@ -42,10 +39,12 @@ import org.bitcoinj.wallet.Wallet; import com.google.common.base.Function; +import com.google.common.base.Joiner; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.base.Throwables; +import com.google.common.collect.Lists; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -1764,7 +1763,7 @@ private void blockChainDownloadLocked(Sha256Hash toHash) { StoredBlock chainHead = blockChain.getChainHead(); Sha256Hash chainHeadHash = chainHead.getHeader().getHash(); // Did we already make this request? If so, don't do it again. - if (Objects.equal(lastGetBlocksBegin, chainHeadHash) && Objects.equal(lastGetBlocksEnd, toHash)) { + if (Objects.equals(lastGetBlocksBegin, chainHeadHash) && Objects.equals(lastGetBlocksEnd, toHash)) { log.info("blockChainDownloadLocked({}): ignoring duplicated request: {}", toHash, chainHeadHash); for (Sha256Hash hash : pendingBlockDownloads) log.info("Pending block download: {}", hash); @@ -1841,7 +1840,7 @@ private void blockChainHeaderDownloadLocked(Sha256Hash toHash) { StoredBlock chainHead = headerChain.getChainHead(); Sha256Hash chainHeadHash = chainHead.getHeader().getHash(); // Did we already make this request? If so, don't do it again. - if (Objects.equal(lastGetHeadersBegin, chainHeadHash) && Objects.equal(lastGetHeadersEnd, toHash)) { + if (Objects.equals(lastGetHeadersBegin, chainHeadHash) && Objects.equals(lastGetHeadersEnd, toHash)) { log.info("blockChainDownloadLocked({}): ignoring duplicated request: {}", toHash, chainHeadHash); for (Sha256Hash hash : pendingBlockDownloads) log.info("Pending block download: {}", hash); diff --git a/core/src/main/java/org/bitcoinj/core/PeerAddress.java b/core/src/main/java/org/bitcoinj/core/PeerAddress.java index 3f278b77dc..a730beb37b 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerAddress.java +++ b/core/src/main/java/org/bitcoinj/core/PeerAddress.java @@ -17,7 +17,6 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; import java.io.IOException; import java.io.OutputStream; @@ -25,6 +24,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; +import java.util.Objects; import static com.google.common.base.Preconditions.checkNotNull; @@ -209,7 +209,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(addr, port, time, services); + return Objects.hash(addr, port, time, services); } public InetSocketAddress toSocketAddress() { diff --git a/core/src/main/java/org/bitcoinj/core/PrefixedChecksummedBytes.java b/core/src/main/java/org/bitcoinj/core/PrefixedChecksummedBytes.java index 0e8950a283..b4fd001b4d 100644 --- a/core/src/main/java/org/bitcoinj/core/PrefixedChecksummedBytes.java +++ b/core/src/main/java/org/bitcoinj/core/PrefixedChecksummedBytes.java @@ -23,8 +23,8 @@ import java.io.Serializable; import java.lang.reflect.Field; import java.util.Arrays; +import java.util.Objects; -import com.google.common.base.Objects; import com.google.common.primitives.UnsignedBytes; import static com.google.common.base.Preconditions.checkNotNull; @@ -59,7 +59,7 @@ public final NetworkParameters getParameters() { @Override public int hashCode() { - return Objects.hashCode(params, Arrays.hashCode(bytes)); + return Objects.hash(params, Arrays.hashCode(bytes)); } @Override diff --git a/core/src/main/java/org/bitcoinj/core/RejectMessage.java b/core/src/main/java/org/bitcoinj/core/RejectMessage.java index 96b15334f2..ea6d97c385 100644 --- a/core/src/main/java/org/bitcoinj/core/RejectMessage.java +++ b/core/src/main/java/org/bitcoinj/core/RejectMessage.java @@ -17,11 +17,11 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.Locale; +import java.util.Objects; /** *

A message sent by nodes when a message we sent was rejected (ie a transaction had too little fee/was invalid/etc).

@@ -164,6 +164,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(message, code, reason, messageHash); + return Objects.hash(message, code, reason, messageHash); } } diff --git a/core/src/main/java/org/bitcoinj/core/StoredBlock.java b/core/src/main/java/org/bitcoinj/core/StoredBlock.java index f090c70629..0d29246091 100644 --- a/core/src/main/java/org/bitcoinj/core/StoredBlock.java +++ b/core/src/main/java/org/bitcoinj/core/StoredBlock.java @@ -18,11 +18,11 @@ import org.bitcoinj.store.BlockStore; import org.bitcoinj.store.BlockStoreException; -import com.google.common.base.Objects; import java.math.BigInteger; import java.nio.ByteBuffer; import java.util.Locale; +import java.util.Objects; import static com.google.common.base.Preconditions.checkState; @@ -91,7 +91,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(header, chainWork, height); + return Objects.hash(header, chainWork, height); } /** diff --git a/core/src/main/java/org/bitcoinj/core/TransactionInput.java b/core/src/main/java/org/bitcoinj/core/TransactionInput.java index d06219267f..4d46fcf659 100644 --- a/core/src/main/java/org/bitcoinj/core/TransactionInput.java +++ b/core/src/main/java/org/bitcoinj/core/TransactionInput.java @@ -24,7 +24,6 @@ import org.bitcoinj.wallet.RedeemData; import com.google.common.base.Joiner; -import com.google.common.base.Objects; import javax.annotation.Nullable; import java.io.IOException; @@ -32,6 +31,7 @@ import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.Map; +import java.util.Objects; import static com.google.common.base.Preconditions.checkElementIndex; import static com.google.common.base.Preconditions.checkNotNull; @@ -505,7 +505,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(sequence, outpoint, Arrays.hashCode(scriptBytes)); + return Objects.hash(sequence, outpoint, Arrays.hashCode(scriptBytes)); } /** diff --git a/core/src/main/java/org/bitcoinj/core/TransactionOutPoint.java b/core/src/main/java/org/bitcoinj/core/TransactionOutPoint.java index da8908b6f4..b1ebcb54a3 100644 --- a/core/src/main/java/org/bitcoinj/core/TransactionOutPoint.java +++ b/core/src/main/java/org/bitcoinj/core/TransactionOutPoint.java @@ -17,12 +17,12 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; import org.bitcoinj.script.*; import org.bitcoinj.wallet.*; import javax.annotation.*; import java.io.*; +import java.util.Objects; import static com.google.common.base.Preconditions.*; @@ -223,6 +223,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(getIndex(), getHash()); + return Objects.hash(getIndex(), getHash()); } } diff --git a/core/src/main/java/org/bitcoinj/core/TransactionOutput.java b/core/src/main/java/org/bitcoinj/core/TransactionOutput.java index 0fa07becbe..30f90daf14 100644 --- a/core/src/main/java/org/bitcoinj/core/TransactionOutput.java +++ b/core/src/main/java/org/bitcoinj/core/TransactionOutput.java @@ -17,7 +17,6 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; import org.bitcoinj.script.*; import org.bitcoinj.wallet.Wallet; import org.slf4j.*; @@ -26,6 +25,7 @@ import java.io.*; import java.util.Arrays; import java.util.List; +import java.util.Objects; import static com.google.common.base.Preconditions.*; @@ -408,6 +408,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(value, parent, Arrays.hashCode(scriptBytes)); + return Objects.hash(value, parent, Arrays.hashCode(scriptBytes)); } } diff --git a/core/src/main/java/org/bitcoinj/core/UTXO.java b/core/src/main/java/org/bitcoinj/core/UTXO.java index 292854d40e..b6fd8b8e09 100644 --- a/core/src/main/java/org/bitcoinj/core/UTXO.java +++ b/core/src/main/java/org/bitcoinj/core/UTXO.java @@ -17,11 +17,11 @@ package org.bitcoinj.core; import org.bitcoinj.script.*; -import com.google.common.base.Objects; import java.io.*; import java.math.*; import java.util.Locale; +import java.util.Objects; // TODO: Fix this class: should not talk about addresses, height should be optional/support mempool height etc @@ -133,7 +133,7 @@ public String toString() { @Override public int hashCode() { - return Objects.hashCode(getIndex(), getHash()); + return Objects.hash(getIndex(), getHash()); } @Override diff --git a/core/src/main/java/org/bitcoinj/core/UTXOsMessage.java b/core/src/main/java/org/bitcoinj/core/UTXOsMessage.java index 5cf348610a..569a2b30cb 100644 --- a/core/src/main/java/org/bitcoinj/core/UTXOsMessage.java +++ b/core/src/main/java/org/bitcoinj/core/UTXOsMessage.java @@ -16,7 +16,6 @@ package org.bitcoinj.core; -import com.google.common.base.Objects; import org.bitcoinj.net.discovery.HttpDiscovery; import java.io.IOException; @@ -24,6 +23,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; /** *

Message representing a list of unspent transaction outputs ("utxos"), returned in response to sending a @@ -166,6 +166,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(height, chainHead, Arrays.hashCode(heights), Arrays.hashCode(hits), outputs); + return Objects.hash(height, chainHead, Arrays.hashCode(heights), Arrays.hashCode(hits), outputs); } } diff --git a/core/src/main/java/org/bitcoinj/core/VersionMessage.java b/core/src/main/java/org/bitcoinj/core/VersionMessage.java index 125ca2625a..b611d4939e 100644 --- a/core/src/main/java/org/bitcoinj/core/VersionMessage.java +++ b/core/src/main/java/org/bitcoinj/core/VersionMessage.java @@ -17,7 +17,6 @@ package org.bitcoinj.core; import com.google.common.base.Joiner; -import com.google.common.base.Objects; import com.google.common.net.InetAddresses; import javax.annotation.Nullable; @@ -29,6 +28,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Locale; +import java.util.Objects; /** *

A VersionMessage holds information exchanged during connection setup with another peer. Most of the fields are not @@ -214,7 +214,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(bestHeight, clientVersion, localServices, + return Objects.hash(bestHeight, clientVersion, localServices, time, subVer, receivingAddr, fromAddr, relayTxesBeforeFilter); } diff --git a/core/src/main/java/org/bitcoinj/crypto/DeterministicKey.java b/core/src/main/java/org/bitcoinj/crypto/DeterministicKey.java index 9a9317bb01..e7b2de77bf 100644 --- a/core/src/main/java/org/bitcoinj/crypto/DeterministicKey.java +++ b/core/src/main/java/org/bitcoinj/crypto/DeterministicKey.java @@ -24,7 +24,6 @@ import org.bitcoinj.script.Script; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import org.bouncycastle.crypto.params.KeyParameter; import org.bouncycastle.math.ec.ECPoint; @@ -34,6 +33,7 @@ import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Comparator; +import java.util.Objects; import static org.bitcoinj.core.Utils.HEX; import static com.google.common.base.Preconditions.*; @@ -750,12 +750,12 @@ public boolean equals(Object o) { DeterministicKey other = (DeterministicKey) o; return super.equals(other) && Arrays.equals(this.chainCode, other.chainCode) - && Objects.equal(this.childNumberPath, other.childNumberPath); + && Objects.equals(this.childNumberPath, other.childNumberPath); } @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), Arrays.hashCode(chainCode), childNumberPath); + return Objects.hash(super.hashCode(), Arrays.hashCode(chainCode), childNumberPath); } @Override diff --git a/core/src/main/java/org/bitcoinj/crypto/EncryptedData.java b/core/src/main/java/org/bitcoinj/crypto/EncryptedData.java index 9214e3a46f..7874fcf4b1 100644 --- a/core/src/main/java/org/bitcoinj/crypto/EncryptedData.java +++ b/core/src/main/java/org/bitcoinj/crypto/EncryptedData.java @@ -16,8 +16,8 @@ package org.bitcoinj.crypto; -import com.google.common.base.Objects; import java.util.Arrays; +import java.util.Objects; /** *

An instance of EncryptedData is a holder for an initialization vector and encrypted bytes. It is typically @@ -45,7 +45,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(Arrays.hashCode(encryptedBytes), Arrays.hashCode(initialisationVector)); + return Objects.hash(Arrays.hashCode(encryptedBytes), Arrays.hashCode(initialisationVector)); } @Override diff --git a/core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java b/core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java index 0bebf1be38..b5099d4fb5 100644 --- a/core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java +++ b/core/src/main/java/org/bitcoinj/crypto/KeyCrypterScrypt.java @@ -17,7 +17,6 @@ package org.bitcoinj.crypto; -import com.google.common.base.Objects; import com.google.common.base.Stopwatch; import com.google.protobuf.ByteString; import com.lambdaworks.crypto.SCrypt; @@ -37,6 +36,7 @@ import java.security.SecureRandom; import java.util.Arrays; +import java.util.Objects; import static com.google.common.base.Preconditions.checkNotNull; @@ -273,13 +273,13 @@ private String scryptParametersString() { @Override public int hashCode() { - return Objects.hashCode(scryptParameters); + return Objects.hash(scryptParameters); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - return Objects.equal(scryptParameters, ((KeyCrypterScrypt)o).scryptParameters); + return Objects.equals(scryptParameters, ((KeyCrypterScrypt)o).scryptParameters); } } diff --git a/core/src/main/java/org/bitcoinj/crypto/bls/BLSDeterministicKey.java b/core/src/main/java/org/bitcoinj/crypto/bls/BLSDeterministicKey.java index d133288567..0805a6e2e5 100644 --- a/core/src/main/java/org/bitcoinj/crypto/bls/BLSDeterministicKey.java +++ b/core/src/main/java/org/bitcoinj/crypto/bls/BLSDeterministicKey.java @@ -19,7 +19,6 @@ package org.bitcoinj.crypto.bls; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import org.bitcoinj.core.Address; import org.bitcoinj.core.Base58; @@ -49,6 +48,7 @@ import javax.annotation.Nullable; import java.nio.ByteBuffer; import java.util.Arrays; +import java.util.Objects; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -869,12 +869,12 @@ public boolean equals(Object o) { BLSDeterministicKey other = (BLSDeterministicKey) o; return super.equals(other) && Arrays.equals(this.chainCode, other.chainCode) - && Objects.equal(this.childNumberPath, other.childNumberPath); + && Objects.equals(this.childNumberPath, other.childNumberPath); } @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), Arrays.hashCode(chainCode), childNumberPath); + return Objects.hash(super.hashCode(), Arrays.hashCode(chainCode), childNumberPath); } @Override diff --git a/core/src/main/java/org/bitcoinj/crypto/bls/BLSKey.java b/core/src/main/java/org/bitcoinj/crypto/bls/BLSKey.java index ed9d513bc8..24cdd96625 100644 --- a/core/src/main/java/org/bitcoinj/crypto/bls/BLSKey.java +++ b/core/src/main/java/org/bitcoinj/crypto/bls/BLSKey.java @@ -21,7 +21,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.io.BaseEncoding; import org.bitcoinj.core.Address; import org.bitcoinj.core.DumpedPrivateKey; @@ -52,6 +51,7 @@ import java.security.SecureRandom; import java.security.SignatureException; import java.util.Arrays; +import java.util.Objects; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; @@ -764,11 +764,11 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof BLSKey)) return false; BLSKey other = (BLSKey) o; - return Objects.equal(this.priv, other.priv) - && Objects.equal(this.pub, other.pub) - && Objects.equal(this.creationTimeSeconds, other.creationTimeSeconds) - && Objects.equal(this.keyCrypter, other.keyCrypter) - && Objects.equal(this.encryptedPrivateKey, other.encryptedPrivateKey); + return Objects.equals(this.priv, other.priv) + && Objects.equals(this.pub, other.pub) + && Objects.equals(this.creationTimeSeconds, other.creationTimeSeconds) + && Objects.equals(this.keyCrypter, other.keyCrypter) + && Objects.equals(this.encryptedPrivateKey, other.encryptedPrivateKey); } @Override diff --git a/core/src/main/java/org/bitcoinj/crypto/ed25519/Ed25519DeterministicKey.java b/core/src/main/java/org/bitcoinj/crypto/ed25519/Ed25519DeterministicKey.java index 48594fb46a..af8c774201 100644 --- a/core/src/main/java/org/bitcoinj/crypto/ed25519/Ed25519DeterministicKey.java +++ b/core/src/main/java/org/bitcoinj/crypto/ed25519/Ed25519DeterministicKey.java @@ -19,7 +19,6 @@ package org.bitcoinj.crypto.ed25519; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.io.BaseEncoding; import org.bitcoinj.core.Address; @@ -44,6 +43,7 @@ import javax.annotation.Nullable; import java.nio.ByteBuffer; import java.util.Arrays; +import java.util.Objects; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -744,12 +744,12 @@ public boolean equals(Object o) { Ed25519DeterministicKey other = (Ed25519DeterministicKey) o; return super.equals(other) && Arrays.equals(this.chainCode, other.chainCode) - && Objects.equal(this.childNumberPath, other.childNumberPath); + && Objects.equals(this.childNumberPath, other.childNumberPath); } @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), Arrays.hashCode(chainCode), childNumberPath); + return Objects.hash(super.hashCode(), Arrays.hashCode(chainCode), childNumberPath); } @Override diff --git a/core/src/main/java/org/bitcoinj/crypto/ed25519/Ed25519Key.java b/core/src/main/java/org/bitcoinj/crypto/ed25519/Ed25519Key.java index a7aadfe87b..abac658f58 100644 --- a/core/src/main/java/org/bitcoinj/crypto/ed25519/Ed25519Key.java +++ b/core/src/main/java/org/bitcoinj/crypto/ed25519/Ed25519Key.java @@ -21,7 +21,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import org.bitcoinj.core.Address; import org.bitcoinj.core.DumpedPrivateKey; import org.bitcoinj.core.NetworkParameters; @@ -55,6 +54,7 @@ import java.security.SecureRandom; import java.security.SignatureException; import java.util.Arrays; +import java.util.Objects; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -785,9 +785,9 @@ public boolean equals(Object o) { privateKeysEqual = true; } return privateKeysEqual && Arrays.equals(this.pub.getEncoded(), other.pub.getEncoded()) - && Objects.equal(this.creationTimeSeconds, other.creationTimeSeconds) - && Objects.equal(this.keyCrypter, other.keyCrypter) - && Objects.equal(this.encryptedPrivateKey, other.encryptedPrivateKey); + && Objects.equals(this.creationTimeSeconds, other.creationTimeSeconds) + && Objects.equals(this.keyCrypter, other.keyCrypter) + && Objects.equals(this.encryptedPrivateKey, other.encryptedPrivateKey); } @Override diff --git a/core/src/main/java/org/bitcoinj/script/ScriptChunk.java b/core/src/main/java/org/bitcoinj/script/ScriptChunk.java index fc54d4d5c6..660632459a 100644 --- a/core/src/main/java/org/bitcoinj/script/ScriptChunk.java +++ b/core/src/main/java/org/bitcoinj/script/ScriptChunk.java @@ -18,7 +18,6 @@ package org.bitcoinj.script; import org.bitcoinj.core.Utils; -import com.google.common.base.Objects; import javax.annotation.Nullable; @@ -26,6 +25,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; +import java.util.Objects; import static com.google.common.base.Preconditions.checkState; import static org.bitcoinj.script.ScriptOpCodes.*; @@ -176,6 +176,6 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hashCode(opcode, startLocationInProgram, Arrays.hashCode(data)); + return Objects.hash(opcode, startLocationInProgram, Arrays.hashCode(data)); } } diff --git a/core/src/main/java/org/bitcoinj/store/MemoryFullPrunedBlockStore.java b/core/src/main/java/org/bitcoinj/store/MemoryFullPrunedBlockStore.java index 6f02c1af6f..8298f6e350 100644 --- a/core/src/main/java/org/bitcoinj/store/MemoryFullPrunedBlockStore.java +++ b/core/src/main/java/org/bitcoinj/store/MemoryFullPrunedBlockStore.java @@ -17,7 +17,6 @@ package org.bitcoinj.store; import org.bitcoinj.core.*; -import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -61,7 +60,7 @@ long getIndex() { @Override public int hashCode() { - return Objects.hashCode(getIndex(), getHash()); + return Objects.hash(getIndex(), getHash()); } @Override @@ -74,7 +73,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StoredTransactionOutPoint other = (StoredTransactionOutPoint) o; - return getIndex() == other.getIndex() && Objects.equal(getHash(), other.getHash()); + return getIndex() == other.getIndex() && Objects.equals(getHash(), other.getHash()); } } diff --git a/core/src/main/java/org/bitcoinj/utils/BtcFixedFormat.java b/core/src/main/java/org/bitcoinj/utils/BtcFixedFormat.java index a4c706c545..490edc8c95 100644 --- a/core/src/main/java/org/bitcoinj/utils/BtcFixedFormat.java +++ b/core/src/main/java/org/bitcoinj/utils/BtcFixedFormat.java @@ -18,7 +18,7 @@ import static org.bitcoinj.core.Coin.SMALLEST_UNIT_EXPONENT; import static com.google.common.base.Preconditions.checkArgument; -import com.google.common.base.Objects; +import java.util.Objects; import org.bitcoinj.core.Coin; import java.math.BigInteger; @@ -146,7 +146,7 @@ public int[] fractionPlaceGroups() { * @see java.lang.Object#hashCode */ @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), scale); + return Objects.hash(super.hashCode(), scale); } private static String prefixLabel(int scale) { diff --git a/core/src/main/java/org/bitcoinj/utils/BtcFormat.java b/core/src/main/java/org/bitcoinj/utils/BtcFormat.java index 9271642628..cd34fd5aa0 100644 --- a/core/src/main/java/org/bitcoinj/utils/BtcFormat.java +++ b/core/src/main/java/org/bitcoinj/utils/BtcFormat.java @@ -20,7 +20,7 @@ import static org.bitcoinj.utils.BtcAutoFormat.Style.*; import org.bitcoinj.core.Coin; -import com.google.common.base.Objects; +import java.util.Objects; import com.google.common.collect.ImmutableList; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -1588,7 +1588,7 @@ public DecimalFormatSymbols symbols() { synchronized(numberFormat) { * @see java.lang.Object#hashCode */ @Override public int hashCode() { - return Objects.hashCode(pattern(), symbols(), minimumFractionDigits, decimalGroups); + return Objects.hash(pattern(), symbols(), minimumFractionDigits, decimalGroups); } } diff --git a/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java b/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java index 7ef780117c..f4eddb6460 100644 --- a/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java +++ b/core/src/main/java/org/bitcoinj/utils/ExchangeRate.java @@ -23,7 +23,7 @@ import org.bitcoinj.core.Coin; -import com.google.common.base.Objects; +import java.util.Objects; /** * An exchange rate is expressed as a ratio of a {@link Coin} and a {@link Fiat} amount. @@ -86,11 +86,11 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ExchangeRate other = (ExchangeRate) o; - return Objects.equal(this.coin, other.coin) && Objects.equal(this.fiat, other.fiat); + return Objects.equals(this.coin, other.coin) && Objects.equals(this.fiat, other.fiat); } @Override public int hashCode() { - return Objects.hashCode(coin, fiat); + return Objects.hash(coin, fiat); } } diff --git a/core/src/main/java/org/bitcoinj/utils/Fiat.java b/core/src/main/java/org/bitcoinj/utils/Fiat.java index 1e2b171662..a6c6fa997b 100644 --- a/core/src/main/java/org/bitcoinj/utils/Fiat.java +++ b/core/src/main/java/org/bitcoinj/utils/Fiat.java @@ -23,7 +23,7 @@ import org.bitcoinj.core.Coin; import org.bitcoinj.core.Monetary; -import com.google.common.base.Objects; +import java.util.Objects; import com.google.common.math.LongMath; /** @@ -226,7 +226,7 @@ public boolean equals(final Object o) { @Override public int hashCode() { - return Objects.hashCode(value, currencyCode); + return Objects.hash(value, currencyCode); } @Override diff --git a/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java b/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java index 3743c7f481..6b858c4d14 100644 --- a/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java +++ b/core/src/main/java/org/bitcoinj/wallet/DeterministicSeed.java @@ -21,7 +21,7 @@ import org.bitcoinj.crypto.*; import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; +import java.util.Objects; import com.google.common.base.Splitter; import org.bouncycastle.crypto.params.KeyParameter; @@ -217,13 +217,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; DeterministicSeed other = (DeterministicSeed) o; return creationTimeSeconds == other.creationTimeSeconds - && Objects.equal(encryptedMnemonicCode, other.encryptedMnemonicCode) - && Objects.equal(mnemonicCode, other.mnemonicCode); + && Objects.equals(encryptedMnemonicCode, other.encryptedMnemonicCode) + && Objects.equals(mnemonicCode, other.mnemonicCode); } @Override public int hashCode() { - return Objects.hashCode(creationTimeSeconds, encryptedMnemonicCode, mnemonicCode); + return Objects.hash(creationTimeSeconds, encryptedMnemonicCode, mnemonicCode); } /** diff --git a/core/src/test/java/org/bitcoinj/protocols/channels/ChannelTestUtils.java b/core/src/test/java/org/bitcoinj/protocols/channels/ChannelTestUtils.java index 11af092583..20e6860164 100644 --- a/core/src/test/java/org/bitcoinj/protocols/channels/ChannelTestUtils.java +++ b/core/src/test/java/org/bitcoinj/protocols/channels/ChannelTestUtils.java @@ -19,7 +19,7 @@ import org.bitcoinj.core.TransactionBroadcaster; import org.bitcoinj.wallet.Wallet; -import com.google.common.base.Objects; +import java.util.Objects; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.protobuf.ByteString; @@ -168,12 +168,12 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; UpdatePair other = (UpdatePair) o; - return Objects.equal(amount, other.amount) && Objects.equal(info, other.info); + return Objects.equals(amount, other.amount) && Objects.equals(info, other.info); } @Override public int hashCode() { - return Objects.hashCode(amount, info); + return Objects.hash(amount, info); } public void assertPair(Coin amount, ByteString info) {