Equals cleanup (#1434)

* Don't copy collections if we don't need to.  Change types higher up if needed.
* Don't use Guava's Object.equal, use Java's Objects.equals.
** add errorprone test to enforce the banning of Guava's Objects class.

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Danno Ferrin 6 years ago committed by GitHub
parent 9bc8d8531b
commit 16982ebad2
  1. 4
      consensus/ibft/src/integration-test/java/tech/pegasys/pantheon/consensus/ibft/tests/GossipTest.java
  2. 5
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/Vote.java
  3. 10
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificate.java
  4. 11
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/payload/RoundChangeCertificate.java
  5. 8
      consensus/ibft/src/main/java/tech/pegasys/pantheon/consensus/ibft/statemachine/RoundChangeArtifacts.java
  6. 4
      consensus/ibft/src/test/java/tech/pegasys/pantheon/consensus/ibft/payload/PreparedCertificateTest.java
  7. 6
      crypto/src/main/java/tech/pegasys/pantheon/crypto/SECP256K1.java
  8. 6
      crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFieldPoint.java
  9. 4
      crypto/src/main/java/tech/pegasys/pantheon/crypto/altbn128/AbstractFqp.java
  10. 55
      errorprone-checks/src/main/java/tech/pegasys/errorpronechecks/BannedMethod.java
  11. 37
      errorprone-checks/src/test/java/tech/pegasys/errorpronechecks/BannedMethodTest.java
  12. 26
      errorprone-checks/src/test/resources/tech/pegasys/errorpronechecks/BannedMethodNegativeCases.java
  13. 30
      errorprone-checks/src/test/resources/tech/pegasys/errorpronechecks/BannedMethodPositiveCases.java
  14. 4
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/SyncStatus.java
  15. 14
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/CallParameter.java
  16. 6
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/transaction/TransactionSimulatorResult.java
  17. 5
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/worldstate/TrieNodeDataRequest.java
  18. 22
      ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/GraphQLRpcConfiguration.java
  19. 4
      ethereum/graphqlrpc/src/main/java/tech/pegasys/pantheon/ethereum/graphqlrpc/internal/response/GraphQLRpcResponse.java
  20. 28
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcConfiguration.java
  21. 4
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApi.java
  22. 4
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/RpcApis.java
  23. 10
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequest.java
  24. 4
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/JsonRpcRequestId.java
  25. 7
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcErrorResponse.java
  26. 7
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcSuccessResponse.java
  27. 7
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/internal/response/JsonRpcUnauthorizedResponse.java
  28. 22
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/WebSocketConfiguration.java
  29. 7
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/Subscription.java
  30. 10
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/SubscribeRequest.java
  31. 8
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/subscription/request/UnsubscribeRequest.java
  32. 1
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/rlpx/handshake/HandshakeSecrets.java
  33. 4
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/wire/AbstractMessageData.java
  34. 9
      ethereum/permissioning/src/main/java/tech/pegasys/pantheon/ethereum/permissioning/node/NodeWhitelistUpdatedEvent.java
  35. 10
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java
  36. 3
      pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java
  37. 2
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  38. 9
      pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/CorsAllowedOriginsProperty.java
  39. 9
      pantheon/src/main/java/tech/pegasys/pantheon/cli/custom/JsonRPCWhitelistHostsProperty.java
  40. 3
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java
  41. 18
      util/src/main/java/tech/pegasys/pantheon/util/enode/EnodeURL.java

@ -13,7 +13,7 @@
package tech.pegasys.pantheon.consensus.ibft.tests; package tech.pegasys.pantheon.consensus.ibft.tests;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static java.util.Collections.singleton; import static java.util.Collections.singletonList;
import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier; import tech.pegasys.pantheon.consensus.ibft.ConsensusRoundIdentifier;
import tech.pegasys.pantheon.consensus.ibft.IbftHelpers; import tech.pegasys.pantheon.consensus.ibft.IbftHelpers;
@ -90,7 +90,7 @@ public class GossipTest {
final RoundChange roundChange = msgFactory.createRoundChange(roundId, Optional.empty()); final RoundChange roundChange = msgFactory.createRoundChange(roundId, Optional.empty());
final RoundChangeCertificate roundChangeCert = final RoundChangeCertificate roundChangeCert =
new RoundChangeCertificate(singleton(roundChange.getSignedPayload())); new RoundChangeCertificate(singletonList(roundChange.getSignedPayload()));
final Proposal nextRoundProposal = final Proposal nextRoundProposal =
sender.injectProposalForFutureRound(roundId, roundChangeCert, proposal.getBlock()); sender.injectProposalForFutureRound(roundId, roundChangeCert, proposal.getBlock());

@ -18,7 +18,8 @@ import tech.pegasys.pantheon.ethereum.rlp.RLPException;
import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RLPOutput; import tech.pegasys.pantheon.ethereum.rlp.RLPOutput;
import com.google.common.base.Objects; import java.util.Objects;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
/** /**
@ -76,7 +77,7 @@ public class Vote {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(recipient, voteType); return Objects.hash(recipient, voteType);
} }
public void writeTo(final RLPOutput rlpOutput) { public void writeTo(final RLPOutput rlpOutput) {

@ -15,25 +15,25 @@ package tech.pegasys.pantheon.consensus.ibft.payload;
import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RLPOutput; import tech.pegasys.pantheon.ethereum.rlp.RLPOutput;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.StringJoiner; import java.util.StringJoiner;
public class PreparedCertificate { public class PreparedCertificate {
private final SignedData<ProposalPayload> proposalPayload; private final SignedData<ProposalPayload> proposalPayload;
private final Collection<SignedData<PreparePayload>> preparePayloads; private final List<SignedData<PreparePayload>> preparePayloads;
public PreparedCertificate( public PreparedCertificate(
final SignedData<ProposalPayload> proposalPayload, final SignedData<ProposalPayload> proposalPayload,
final Collection<SignedData<PreparePayload>> preparePayloads) { final List<SignedData<PreparePayload>> preparePayloads) {
this.proposalPayload = proposalPayload; this.proposalPayload = proposalPayload;
this.preparePayloads = preparePayloads; this.preparePayloads = preparePayloads;
} }
public static PreparedCertificate readFrom(final RLPInput rlpInput) { public static PreparedCertificate readFrom(final RLPInput rlpInput) {
final SignedData<ProposalPayload> proposalMessage; final SignedData<ProposalPayload> proposalMessage;
final Collection<SignedData<PreparePayload>> prepareMessages; final List<SignedData<PreparePayload>> prepareMessages;
rlpInput.enterList(); rlpInput.enterList();
proposalMessage = SignedData.readSignedProposalPayloadFrom(rlpInput); proposalMessage = SignedData.readSignedProposalPayloadFrom(rlpInput);
@ -68,7 +68,7 @@ public class PreparedCertificate {
} }
final PreparedCertificate that = (PreparedCertificate) o; final PreparedCertificate that = (PreparedCertificate) o;
return Objects.equals(proposalPayload, that.proposalPayload) return Objects.equals(proposalPayload, that.proposalPayload)
&& Objects.equals(new ArrayList<>(preparePayloads), new ArrayList<>(that.preparePayloads)); && Objects.equals(preparePayloads, that.preparePayloads);
} }
@Override @Override

@ -16,7 +16,6 @@ import tech.pegasys.pantheon.consensus.ibft.messagewrappers.RoundChange;
import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
import tech.pegasys.pantheon.ethereum.rlp.RLPOutput; import tech.pegasys.pantheon.ethereum.rlp.RLPOutput;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -27,15 +26,14 @@ import com.google.common.collect.Lists;
public class RoundChangeCertificate { public class RoundChangeCertificate {
private final Collection<SignedData<RoundChangePayload>> roundChangePayloads; private final List<SignedData<RoundChangePayload>> roundChangePayloads;
public RoundChangeCertificate( public RoundChangeCertificate(final List<SignedData<RoundChangePayload>> roundChangePayloads) {
final Collection<SignedData<RoundChangePayload>> roundChangePayloads) {
this.roundChangePayloads = roundChangePayloads; this.roundChangePayloads = roundChangePayloads;
} }
public static RoundChangeCertificate readFrom(final RLPInput rlpInput) { public static RoundChangeCertificate readFrom(final RLPInput rlpInput) {
final Collection<SignedData<RoundChangePayload>> roundChangePayloads; final List<SignedData<RoundChangePayload>> roundChangePayloads;
rlpInput.enterList(); rlpInput.enterList();
roundChangePayloads = rlpInput.readList(SignedData::readSignedRoundChangePayloadFrom); roundChangePayloads = rlpInput.readList(SignedData::readSignedRoundChangePayloadFrom);
@ -81,8 +79,7 @@ public class RoundChangeCertificate {
return false; return false;
} }
final RoundChangeCertificate that = (RoundChangeCertificate) o; final RoundChangeCertificate that = (RoundChangeCertificate) o;
return Objects.equals( return Objects.equals(roundChangePayloads, that.roundChangePayloads);
new ArrayList<>(roundChangePayloads), new ArrayList<>(that.roundChangePayloads));
} }
@Override @Override

@ -20,17 +20,17 @@ import tech.pegasys.pantheon.ethereum.core.Block;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class RoundChangeArtifacts { public class RoundChangeArtifacts {
private final Optional<Block> block; private final Optional<Block> block;
private final Collection<SignedData<RoundChangePayload>> roundChangePayloads; private final List<SignedData<RoundChangePayload>> roundChangePayloads;
public RoundChangeArtifacts( public RoundChangeArtifacts(
final Optional<Block> block, final Optional<Block> block, final List<SignedData<RoundChangePayload>> roundChangePayloads) {
final Collection<SignedData<RoundChangePayload>> roundChangePayloads) {
this.block = block; this.block = block;
this.roundChangePayloads = roundChangePayloads; this.roundChangePayloads = roundChangePayloads;
} }
@ -58,7 +58,7 @@ public class RoundChangeArtifacts {
.compareTo(o2.getPreparedCertificateRound().get()); .compareTo(o2.getPreparedCertificateRound().get());
}; };
final Collection<SignedData<RoundChangePayload>> payloads = final List<SignedData<RoundChangePayload>> payloads =
roundChanges.stream().map(RoundChange::getSignedPayload).collect(Collectors.toList()); roundChanges.stream().map(RoundChange::getSignedPayload).collect(Collectors.toList());
final Optional<RoundChange> roundChangeWithNewestPrepare = final Optional<RoundChange> roundChangeWithNewestPrepare =

@ -26,8 +26,8 @@ import tech.pegasys.pantheon.ethereum.rlp.RLP;
import tech.pegasys.pantheon.ethereum.rlp.RLPInput; import tech.pegasys.pantheon.ethereum.rlp.RLPInput;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import org.assertj.core.util.Lists; import org.assertj.core.util.Lists;
import org.junit.Test; import org.junit.Test;
@ -40,7 +40,7 @@ public class PreparedCertificateTest {
@Test @Test
public void roundTripRlpWithNoPreparePayloads() { public void roundTripRlpWithNoPreparePayloads() {
final SignedData<ProposalPayload> signedProposalPayload = signedProposal(); final SignedData<ProposalPayload> signedProposalPayload = signedProposal();
final Collection<SignedData<PreparePayload>> preparePayloads = Collections.emptyList(); final List<SignedData<PreparePayload>> preparePayloads = Collections.emptyList();
final PreparedCertificate preparedCert = final PreparedCertificate preparedCert =
new PreparedCertificate(signedProposalPayload, preparePayloads); new PreparedCertificate(signedProposalPayload, preparePayloads);

@ -37,10 +37,10 @@ import java.security.Security;
import java.security.spec.ECGenParameterSpec; import java.security.spec.ECGenParameterSpec;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
import com.google.common.base.Objects;
import org.bouncycastle.asn1.sec.SECNamedCurves; import org.bouncycastle.asn1.sec.SECNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters; import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.asn1.x9.X9IntegerConverter; import org.bouncycastle.asn1.x9.X9IntegerConverter;
@ -552,7 +552,7 @@ public class SECP256K1 {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(privateKey, publicKey); return Objects.hash(privateKey, publicKey);
} }
@Override @Override
@ -664,7 +664,7 @@ public class SECP256K1 {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(r, s, recId); return Objects.hash(r, s, recId);
} }
public byte getRecId() { public byte getRecId() {

@ -13,9 +13,9 @@
package tech.pegasys.pantheon.crypto.altbn128; package tech.pegasys.pantheon.crypto.altbn128;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Objects;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/** /**
* Adapted from the pc_ecc (Apache 2 License) implementation: * Adapted from the pc_ecc (Apache 2 License) implementation:
@ -120,7 +120,7 @@ public abstract class AbstractFieldPoint<U extends AbstractFieldPoint> implement
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(x, y); return Objects.hash(x, y);
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -134,6 +134,6 @@ public abstract class AbstractFieldPoint<U extends AbstractFieldPoint> implement
} }
final AbstractFieldPoint other = (AbstractFieldPoint) obj; final AbstractFieldPoint other = (AbstractFieldPoint) obj;
return Objects.equal(x, other.x) && Objects.equal(y, other.y); return Objects.equals(x, other.x) && Objects.equals(y, other.y);
} }
} }

@ -14,9 +14,9 @@ package tech.pegasys.pantheon.crypto.altbn128;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
/** /**
* Adapted from the pc_ecc (Apache 2 License) implementation: * Adapted from the pc_ecc (Apache 2 License) implementation:
@ -266,7 +266,7 @@ public abstract class AbstractFqp<T extends AbstractFqp> implements FieldElement
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode( return Objects.hash(
degree, Arrays.hashCode(modulusCoefficients), Arrays.hashCode(coefficients)); degree, Arrays.hashCode(modulusCoefficients), Arrays.hashCode(coefficients));
} }

@ -0,0 +1,55 @@
/*
* Copyright 2019 ConsenSys AG.
*
* 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 tech.pegasys.errorpronechecks;
import static com.google.errorprone.BugPattern.SeverityLevel.WARNING;
import static com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher;
import static com.google.errorprone.matchers.Description.NO_MATCH;
import static com.google.errorprone.matchers.Matchers.allOf;
import static com.google.errorprone.matchers.method.MethodMatchers.staticMethod;
import java.util.Map;
import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.BugPattern;
import com.google.errorprone.VisitorState;
import com.google.errorprone.bugpatterns.BugChecker;
import com.google.errorprone.matchers.Description;
import com.google.errorprone.matchers.Matcher;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.MethodInvocationTree;
@AutoService(BugChecker.class)
@BugPattern(
name = "BannedMethod",
summary = "Some methods should not be used, make sure that doesn't happen.",
severity = WARNING)
public class BannedMethod extends BugChecker implements MethodInvocationTreeMatcher {
private static final ImmutableMap<Matcher<ExpressionTree>, String> BANNED_METHOD_LIST =
ImmutableMap.of(
allOf(staticMethod().onClass("com.google.common.base.Objects").withAnyName()),
"Do not use com.google.common.base.Objects methods, use java.util.Objects methods instead.");
@Override
public Description matchMethodInvocation(
final MethodInvocationTree tree, final VisitorState state) {
for (final Map.Entry<Matcher<ExpressionTree>, String> entry : BANNED_METHOD_LIST.entrySet()) {
if (entry.getKey().matches(tree, state)) {
return buildDescriptionFromChecker(tree, this).setMessage(entry.getValue()).build();
}
}
return NO_MATCH;
}
}

@ -0,0 +1,37 @@
/*
* Copyright 2018 ConsenSys AG.
*
* 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 tech.pegasys.errorpronechecks;
import com.google.errorprone.CompilationTestHelper;
import org.junit.Before;
import org.junit.Test;
public class BannedMethodTest {
private CompilationTestHelper compilationHelper;
@Before
public void setup() {
compilationHelper = CompilationTestHelper.newInstance(BannedMethod.class, getClass());
}
@Test
public void doNotReturnNullPositiveCases() {
compilationHelper.addSourceFile("BannedMethodPositiveCases.java").doTest();
}
@Test
public void doNotReturnNullNegativeCases() {
compilationHelper.addSourceFile("BannedMethodNegativeCases.java").doTest();
}
}

@ -0,0 +1,26 @@
/*
* Copyright 2018 ConsenSys AG.
*
* 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 tech.pegasys.errorpronechecks;
import java.util.Objects;
public class BannedMethodNegativeCases {
public void callsObjectsEquals() throws Exception {
Objects.equals("1", "1");
}
public void callsObjectsHashCode() throws Exception {
Objects.hash("1", "1");
}
}

@ -0,0 +1,30 @@
/*
* Copyright 2018 ConsenSys AG.
*
* 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 tech.pegasys.errorpronechecks;
import com.google.common.base.Objects;
public class BannedMethodPositiveCases {
public void callsObjectsEquals() throws Exception {
// BUG: Diagnostic contains: Do not use com.google.common.base.Objects methods, use
// java.util.Objects methods instead.
Objects.equal("1", "1");
}
public void callsObjectsHashCode() throws Exception {
// BUG: Diagnostic contains: Do not use com.google.common.base.Objects methods, use
// java.util.Objects methods instead.
Objects.hashCode("1", "1");
}
}

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.ethereum.core; package tech.pegasys.pantheon.ethereum.core;
import com.google.common.base.Objects; import java.util.Objects;
public final class SyncStatus { public final class SyncStatus {
@ -58,6 +58,6 @@ public final class SyncStatus {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(startingBlock, currentBlock, highestBlock); return Objects.hash(startingBlock, currentBlock, highestBlock);
} }
} }

@ -16,7 +16,7 @@ import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.Wei; import tech.pegasys.pantheon.ethereum.core.Wei;
import tech.pegasys.pantheon.util.bytes.BytesValue; import tech.pegasys.pantheon.util.bytes.BytesValue;
import com.google.common.base.Objects; import java.util.Objects;
// Represents parameters for a eth_call or eth_estimateGas JSON-RPC methods. // Represents parameters for a eth_call or eth_estimateGas JSON-RPC methods.
public class CallParameter { public class CallParameter {
@ -82,15 +82,15 @@ public class CallParameter {
} }
final CallParameter that = (CallParameter) o; final CallParameter that = (CallParameter) o;
return gasLimit == that.gasLimit return gasLimit == that.gasLimit
&& Objects.equal(from, that.from) && Objects.equals(from, that.from)
&& Objects.equal(to, that.to) && Objects.equals(to, that.to)
&& Objects.equal(gasPrice, that.gasPrice) && Objects.equals(gasPrice, that.gasPrice)
&& Objects.equal(value, that.value) && Objects.equals(value, that.value)
&& Objects.equal(payload, that.payload); && Objects.equals(payload, that.payload);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(from, to, gasLimit, gasPrice, value, payload); return Objects.hash(from, to, gasLimit, gasPrice, value, payload);
} }
} }

@ -18,7 +18,7 @@ import tech.pegasys.pantheon.ethereum.mainnet.TransactionValidator.TransactionIn
import tech.pegasys.pantheon.ethereum.mainnet.ValidationResult; import tech.pegasys.pantheon.ethereum.mainnet.ValidationResult;
import tech.pegasys.pantheon.util.bytes.BytesValue; import tech.pegasys.pantheon.util.bytes.BytesValue;
import com.google.common.base.Objects; import java.util.Objects;
public class TransactionSimulatorResult { public class TransactionSimulatorResult {
@ -59,11 +59,11 @@ public class TransactionSimulatorResult {
return false; return false;
} }
final TransactionSimulatorResult that = (TransactionSimulatorResult) o; final TransactionSimulatorResult that = (TransactionSimulatorResult) o;
return Objects.equal(transaction, that.transaction) && Objects.equal(result, that.result); return Objects.equals(transaction, that.transaction) && Objects.equals(result, that.result);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(transaction, result); return Objects.hash(transaction, result);
} }
} }

@ -18,10 +18,9 @@ import tech.pegasys.pantheon.ethereum.trie.TrieNodeDecoder;
import tech.pegasys.pantheon.util.bytes.BytesValue; import tech.pegasys.pantheon.util.bytes.BytesValue;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.google.common.base.Objects;
abstract class TrieNodeDataRequest extends NodeDataRequest { abstract class TrieNodeDataRequest extends NodeDataRequest {
TrieNodeDataRequest(final RequestType kind, final Hash hash) { TrieNodeDataRequest(final RequestType kind, final Hash hash) {
@ -50,7 +49,7 @@ abstract class TrieNodeDataRequest extends NodeDataRequest {
} }
private boolean nodeIsHashReferencedDescendant(final Node<BytesValue> node) { private boolean nodeIsHashReferencedDescendant(final Node<BytesValue> node) {
return !Objects.equal(node.getHash(), getHash()) && node.isReferencedByHash(); return !Objects.equals(node.getHash(), getHash()) && node.isReferencedByHash();
} }
protected abstract NodeDataRequest createChildNodeDataRequest(final Hash childHash); protected abstract NodeDataRequest createChildNodeDataRequest(final Hash childHash);

@ -17,10 +17,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Objects;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
public class GraphQLRpcConfiguration { public class GraphQLRpcConfiguration {
private static final String DEFAULT_GRAPHQL_RPC_HOST = "127.0.0.1"; private static final String DEFAULT_GRAPHQL_RPC_HOST = "127.0.0.1";
@ -29,8 +29,8 @@ public class GraphQLRpcConfiguration {
private boolean enabled; private boolean enabled;
private int port; private int port;
private String host; private String host;
private Collection<String> corsAllowedDomains = Collections.emptyList(); private List<String> corsAllowedDomains = Collections.emptyList();
private Collection<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); private List<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1");
public static GraphQLRpcConfiguration createDefault() { public static GraphQLRpcConfiguration createDefault() {
final GraphQLRpcConfiguration config = new GraphQLRpcConfiguration(); final GraphQLRpcConfiguration config = new GraphQLRpcConfiguration();
@ -70,7 +70,7 @@ public class GraphQLRpcConfiguration {
return corsAllowedDomains; return corsAllowedDomains;
} }
public void setCorsAllowedDomains(final Collection<String> corsAllowedDomains) { public void setCorsAllowedDomains(final List<String> corsAllowedDomains) {
checkNotNull(corsAllowedDomains); checkNotNull(corsAllowedDomains);
this.corsAllowedDomains = corsAllowedDomains; this.corsAllowedDomains = corsAllowedDomains;
} }
@ -79,7 +79,7 @@ public class GraphQLRpcConfiguration {
return Collections.unmodifiableCollection(this.hostsWhitelist); return Collections.unmodifiableCollection(this.hostsWhitelist);
} }
public void setHostsWhitelist(final Collection<String> hostsWhitelist) { public void setHostsWhitelist(final List<String> hostsWhitelist) {
checkNotNull(hostsWhitelist); checkNotNull(hostsWhitelist);
this.hostsWhitelist = hostsWhitelist; this.hostsWhitelist = hostsWhitelist;
} }
@ -106,15 +106,13 @@ public class GraphQLRpcConfiguration {
final GraphQLRpcConfiguration that = (GraphQLRpcConfiguration) o; final GraphQLRpcConfiguration that = (GraphQLRpcConfiguration) o;
return enabled == that.enabled return enabled == that.enabled
&& port == that.port && port == that.port
&& Objects.equal(host, that.host) && Objects.equals(host, that.host)
&& Objects.equal( && Objects.equals(corsAllowedDomains, that.corsAllowedDomains)
Lists.newArrayList(corsAllowedDomains), Lists.newArrayList(that.corsAllowedDomains)) && Objects.equals(hostsWhitelist, that.hostsWhitelist);
&& Objects.equal(
Lists.newArrayList(hostsWhitelist), Lists.newArrayList(that.hostsWhitelist));
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(enabled, port, host, corsAllowedDomains, hostsWhitelist); return Objects.hash(enabled, port, host, corsAllowedDomains, hostsWhitelist);
} }
} }

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.ethereum.graphqlrpc.internal.response; package tech.pegasys.pantheon.ethereum.graphqlrpc.internal.response;
import com.google.common.base.Objects; import java.util.Objects;
public abstract class GraphQLRpcResponse { public abstract class GraphQLRpcResponse {
public abstract GraphQLRpcResponseType getType(); public abstract GraphQLRpcResponseType getType();
@ -36,7 +36,7 @@ public abstract class GraphQLRpcResponse {
return false; return false;
} }
final GraphQLRpcResponse that = (GraphQLRpcResponse) o; final GraphQLRpcResponse that = (GraphQLRpcResponse) o;
return Objects.equal(result, that.result); return Objects.equals(result, that.result);
} }
@Override @Override

@ -16,10 +16,10 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Objects;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
public class JsonRpcConfiguration { public class JsonRpcConfiguration {
private static final String DEFAULT_JSON_RPC_HOST = "127.0.0.1"; private static final String DEFAULT_JSON_RPC_HOST = "127.0.0.1";
@ -28,9 +28,9 @@ public class JsonRpcConfiguration {
private boolean enabled; private boolean enabled;
private int port; private int port;
private String host; private String host;
private Collection<String> corsAllowedDomains = Collections.emptyList(); private List<String> corsAllowedDomains = Collections.emptyList();
private Collection<RpcApi> rpcApis; private List<RpcApi> rpcApis;
private Collection<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1");; private List<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1");
private boolean authenticationEnabled = false; private boolean authenticationEnabled = false;
private String authenticationCredentialsFile; private String authenticationCredentialsFile;
@ -73,7 +73,7 @@ public class JsonRpcConfiguration {
return corsAllowedDomains; return corsAllowedDomains;
} }
public void setCorsAllowedDomains(final Collection<String> corsAllowedDomains) { public void setCorsAllowedDomains(final List<String> corsAllowedDomains) {
if (corsAllowedDomains != null) { if (corsAllowedDomains != null) {
this.corsAllowedDomains = corsAllowedDomains; this.corsAllowedDomains = corsAllowedDomains;
} }
@ -83,7 +83,7 @@ public class JsonRpcConfiguration {
return rpcApis; return rpcApis;
} }
public void setRpcApis(final Collection<RpcApi> rpcApis) { public void setRpcApis(final List<RpcApi> rpcApis) {
this.rpcApis = rpcApis; this.rpcApis = rpcApis;
} }
@ -96,7 +96,7 @@ public class JsonRpcConfiguration {
return Collections.unmodifiableCollection(this.hostsWhitelist); return Collections.unmodifiableCollection(this.hostsWhitelist);
} }
public void setHostsWhitelist(final Collection<String> hostsWhitelist) { public void setHostsWhitelist(final List<String> hostsWhitelist) {
this.hostsWhitelist = hostsWhitelist; this.hostsWhitelist = hostsWhitelist;
} }
@ -125,17 +125,15 @@ public class JsonRpcConfiguration {
final JsonRpcConfiguration that = (JsonRpcConfiguration) o; final JsonRpcConfiguration that = (JsonRpcConfiguration) o;
return enabled == that.enabled return enabled == that.enabled
&& port == that.port && port == that.port
&& Objects.equal(host, that.host) && Objects.equals(host, that.host)
&& Objects.equal( && Objects.equals(corsAllowedDomains, that.corsAllowedDomains)
Lists.newArrayList(corsAllowedDomains), Lists.newArrayList(that.corsAllowedDomains)) && Objects.equals(hostsWhitelist, that.hostsWhitelist)
&& Objects.equal( && Objects.equals(rpcApis, that.rpcApis);
Lists.newArrayList(hostsWhitelist), Lists.newArrayList(that.hostsWhitelist))
&& Objects.equal(Lists.newArrayList(rpcApis), Lists.newArrayList(that.rpcApis));
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(enabled, port, host, corsAllowedDomains, hostsWhitelist, rpcApis); return Objects.hash(enabled, port, host, corsAllowedDomains, hostsWhitelist, rpcApis);
} }
public boolean isAuthenticationEnabled() { public boolean isAuthenticationEnabled() {

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc; package tech.pegasys.pantheon.ethereum.jsonrpc;
import com.google.common.base.Objects; import java.util.Objects;
public class RpcApi { public class RpcApi {
private final String cliValue; private final String cliValue;
@ -34,7 +34,7 @@ public class RpcApi {
return false; return false;
} }
final RpcApi rpcApi = (RpcApi) o; final RpcApi rpcApi = (RpcApi) o;
return Objects.equal(cliValue, rpcApi.cliValue); return Objects.equals(cliValue, rpcApi.cliValue);
} }
@Override @Override

@ -13,7 +13,7 @@
package tech.pegasys.pantheon.ethereum.jsonrpc; package tech.pegasys.pantheon.ethereum.jsonrpc;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.List;
import java.util.Optional; import java.util.Optional;
public class RpcApis { public class RpcApis {
@ -28,7 +28,7 @@ public class RpcApis {
public static final RpcApi EEA = new RpcApi("EEA"); public static final RpcApi EEA = new RpcApi("EEA");
public static final RpcApi TX_POOL = new RpcApi("TXPOOL"); public static final RpcApi TX_POOL = new RpcApi("TXPOOL");
public static final Collection<RpcApi> DEFAULT_JSON_RPC_APIS = Arrays.asList(ETH, NET, WEB3); public static final List<RpcApi> DEFAULT_JSON_RPC_APIS = Arrays.asList(ETH, NET, WEB3);
public static Optional<RpcApi> valueOf(final String name) { public static Optional<RpcApi> valueOf(final String name) {
if (name.equals(ETH.getCliValue())) { if (name.equals(ETH.getCliValue())) {

@ -15,6 +15,7 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.internal;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcRequestException; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonGetter;
@ -24,7 +25,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonSetter;
import com.google.common.base.Objects;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class JsonRpcRequest { public class JsonRpcRequest {
@ -112,14 +112,14 @@ public class JsonRpcRequest {
} }
final JsonRpcRequest that = (JsonRpcRequest) o; final JsonRpcRequest that = (JsonRpcRequest) o;
return isNotification == that.isNotification return isNotification == that.isNotification
&& Objects.equal(id, that.id) && Objects.equals(id, that.id)
&& Objects.equal(method, that.method) && Objects.equals(method, that.method)
&& Arrays.equals(params, that.params) && Arrays.equals(params, that.params)
&& Objects.equal(version, that.version); && Objects.equals(version, that.version);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(id, method, Arrays.hashCode(params), version, isNotification); return Objects.hash(id, method, Arrays.hashCode(params), version, isNotification);
} }
} }

@ -15,10 +15,10 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.internal;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcRequestException; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Objects;
public class JsonRpcRequestId { public class JsonRpcRequestId {
@ -73,7 +73,7 @@ public class JsonRpcRequestId {
return false; return false;
} }
final JsonRpcRequestId that = (JsonRpcRequestId) o; final JsonRpcRequestId that = (JsonRpcRequestId) o;
return Objects.equal(id, that.id); return Objects.equals(id, that.id);
} }
@Override @Override

@ -12,10 +12,11 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response; package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.Objects;
@JsonPropertyOrder({"jsonrpc", "id", "error"}) @JsonPropertyOrder({"jsonrpc", "id", "error"})
public class JsonRpcErrorResponse implements JsonRpcResponse { public class JsonRpcErrorResponse implements JsonRpcResponse {
@ -53,11 +54,11 @@ public class JsonRpcErrorResponse implements JsonRpcResponse {
return false; return false;
} }
final JsonRpcErrorResponse that = (JsonRpcErrorResponse) o; final JsonRpcErrorResponse that = (JsonRpcErrorResponse) o;
return Objects.equal(id, that.id) && error == that.error; return Objects.equals(id, that.id) && error == that.error;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(id, error); return Objects.hash(id, error);
} }
} }

@ -12,10 +12,11 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response; package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.Objects;
@JsonPropertyOrder({"jsonrpc", "id", "result"}) @JsonPropertyOrder({"jsonrpc", "id", "result"})
public class JsonRpcSuccessResponse implements JsonRpcResponse { public class JsonRpcSuccessResponse implements JsonRpcResponse {
@ -58,11 +59,11 @@ public class JsonRpcSuccessResponse implements JsonRpcResponse {
return false; return false;
} }
final JsonRpcSuccessResponse that = (JsonRpcSuccessResponse) o; final JsonRpcSuccessResponse that = (JsonRpcSuccessResponse) o;
return Objects.equal(id, that.id) && Objects.equal(result, that.result); return Objects.equals(id, that.id) && Objects.equals(result, that.result);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(id, result); return Objects.hash(id, result);
} }
} }

@ -12,10 +12,11 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response; package tech.pegasys.pantheon.ethereum.jsonrpc.internal.response;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.base.Objects;
@JsonPropertyOrder({"jsonrpc", "id", "error"}) @JsonPropertyOrder({"jsonrpc", "id", "error"})
public class JsonRpcUnauthorizedResponse implements JsonRpcResponse { public class JsonRpcUnauthorizedResponse implements JsonRpcResponse {
@ -53,11 +54,11 @@ public class JsonRpcUnauthorizedResponse implements JsonRpcResponse {
return false; return false;
} }
final JsonRpcUnauthorizedResponse that = (JsonRpcUnauthorizedResponse) o; final JsonRpcUnauthorizedResponse that = (JsonRpcUnauthorizedResponse) o;
return Objects.equal(id, that.id) && error == that.error; return Objects.equals(id, that.id) && error == that.error;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(id, error); return Objects.hash(id, error);
} }
} }

@ -15,25 +15,24 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.websocket;
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi; import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApi;
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis; import tech.pegasys.pantheon.ethereum.jsonrpc.RpcApis;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Objects;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
public class WebSocketConfiguration { public class WebSocketConfiguration {
public static final String DEFAULT_WEBSOCKET_HOST = "127.0.0.1"; public static final String DEFAULT_WEBSOCKET_HOST = "127.0.0.1";
public static final int DEFAULT_WEBSOCKET_PORT = 8546; public static final int DEFAULT_WEBSOCKET_PORT = 8546;
public static final Collection<RpcApi> DEFAULT_WEBSOCKET_APIS = public static final List<RpcApi> DEFAULT_WEBSOCKET_APIS =
Arrays.asList(RpcApis.ETH, RpcApis.NET, RpcApis.WEB3); Arrays.asList(RpcApis.ETH, RpcApis.NET, RpcApis.WEB3);
private boolean enabled; private boolean enabled;
private int port; private int port;
private String host; private String host;
private Collection<RpcApi> rpcApis; private List<RpcApi> rpcApis;
private boolean authenticationEnabled = false; private boolean authenticationEnabled = false;
private String authenticationCredentialsFile; private String authenticationCredentialsFile;
private Collection<String> hostsWhitelist = Collections.singletonList("localhost"); private Collection<String> hostsWhitelist = Collections.singletonList("localhost");
@ -77,15 +76,10 @@ public class WebSocketConfiguration {
return rpcApis; return rpcApis;
} }
public void setRpcApis(final Collection<RpcApi> rpcApis) { public void setRpcApis(final List<RpcApi> rpcApis) {
this.rpcApis = rpcApis; this.rpcApis = rpcApis;
} }
public void addRpcApi(final RpcApi rpcApi) {
this.rpcApis = new ArrayList<>(rpcApis);
rpcApis.add(rpcApi);
}
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(this) return MoreObjects.toStringHelper(this)
@ -109,13 +103,13 @@ public class WebSocketConfiguration {
final WebSocketConfiguration that = (WebSocketConfiguration) o; final WebSocketConfiguration that = (WebSocketConfiguration) o;
return enabled == that.enabled return enabled == that.enabled
&& port == that.port && port == that.port
&& Objects.equal(host, that.host) && Objects.equals(host, that.host)
&& Objects.equal(Lists.newArrayList(rpcApis), Lists.newArrayList(that.rpcApis)); && Objects.equals(rpcApis, that.rpcApis);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(enabled, port, host, rpcApis); return Objects.hash(enabled, port, host, rpcApis);
} }
public boolean isAuthenticationEnabled() { public boolean isAuthenticationEnabled() {

@ -14,8 +14,9 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription;
import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.request.SubscriptionType; import tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.request.SubscriptionType;
import java.util.Objects;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
public class Subscription { public class Subscription {
@ -63,11 +64,11 @@ public class Subscription {
return false; return false;
} }
final Subscription that = (Subscription) o; final Subscription that = (Subscription) o;
return Objects.equal(id, that.id) && subscriptionType == that.subscriptionType; return Objects.equals(id, that.id) && subscriptionType == that.subscriptionType;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(id, subscriptionType); return Objects.hash(id, subscriptionType);
} }
} }

@ -14,7 +14,7 @@ package tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.request;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.FilterParameter; import tech.pegasys.pantheon.ethereum.jsonrpc.internal.parameters.FilterParameter;
import com.google.common.base.Objects; import java.util.Objects;
public class SubscribeRequest { public class SubscribeRequest {
@ -74,13 +74,13 @@ public class SubscribeRequest {
} }
final SubscribeRequest that = (SubscribeRequest) o; final SubscribeRequest that = (SubscribeRequest) o;
return subscriptionType == that.subscriptionType return subscriptionType == that.subscriptionType
&& Objects.equal(includeTransaction, that.includeTransaction) && Objects.equals(includeTransaction, that.includeTransaction)
&& Objects.equal(filterParameter, that.filterParameter) && Objects.equals(filterParameter, that.filterParameter)
&& Objects.equal(connectionId, that.connectionId); && Objects.equals(connectionId, that.connectionId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(subscriptionType, includeTransaction, filterParameter, connectionId); return Objects.hash(subscriptionType, includeTransaction, filterParameter, connectionId);
} }
} }

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.request; package tech.pegasys.pantheon.ethereum.jsonrpc.websocket.subscription.request;
import com.google.common.base.Objects; import java.util.Objects;
public class UnsubscribeRequest { public class UnsubscribeRequest {
@ -51,12 +51,12 @@ public class UnsubscribeRequest {
return false; return false;
} }
final UnsubscribeRequest that = (UnsubscribeRequest) o; final UnsubscribeRequest that = (UnsubscribeRequest) o;
return Objects.equal(subscriptionId, that.subscriptionId) return Objects.equals(subscriptionId, that.subscriptionId)
&& Objects.equal(connectionId, that.connectionId); && Objects.equals(connectionId, that.connectionId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(subscriptionId, connectionId); return Objects.hash(subscriptionId, connectionId);
} }
} }

@ -157,6 +157,7 @@ public class HandshakeSecrets {
return out; return out;
} }
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass") // checked in delegated method
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
return equals(obj, false); return equals(obj, false);

@ -15,7 +15,7 @@ package tech.pegasys.pantheon.ethereum.p2p.wire;
import tech.pegasys.pantheon.ethereum.p2p.api.MessageData; import tech.pegasys.pantheon.ethereum.p2p.api.MessageData;
import tech.pegasys.pantheon.util.bytes.BytesValue; import tech.pegasys.pantheon.util.bytes.BytesValue;
import com.google.common.base.Objects; import java.util.Objects;
public abstract class AbstractMessageData implements MessageData { public abstract class AbstractMessageData implements MessageData {
@ -44,7 +44,7 @@ public abstract class AbstractMessageData implements MessageData {
return false; return false;
} }
final AbstractMessageData that = (AbstractMessageData) o; final AbstractMessageData that = (AbstractMessageData) o;
return Objects.equal(data, that.data); return Objects.equals(data, that.data);
} }
@Override @Override

@ -16,8 +16,7 @@ import tech.pegasys.pantheon.util.enode.EnodeURL;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import com.google.common.base.Objects;
public class NodeWhitelistUpdatedEvent { public class NodeWhitelistUpdatedEvent {
@ -47,12 +46,12 @@ public class NodeWhitelistUpdatedEvent {
return false; return false;
} }
NodeWhitelistUpdatedEvent that = (NodeWhitelistUpdatedEvent) o; NodeWhitelistUpdatedEvent that = (NodeWhitelistUpdatedEvent) o;
return Objects.equal(addedNodes, that.addedNodes) return Objects.equals(addedNodes, that.addedNodes)
&& Objects.equal(removedNodes, that.removedNodes); && Objects.equals(removedNodes, that.removedNodes);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(addedNodes, removedNodes); return Objects.hash(addedNodes, removedNodes);
} }
} }

@ -19,11 +19,10 @@ import tech.pegasys.pantheon.metrics.MetricCategory;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import com.google.common.collect.Lists;
public class MetricsConfiguration { public class MetricsConfiguration {
private static final String DEFAULT_METRICS_HOST = "127.0.0.1"; private static final String DEFAULT_METRICS_HOST = "127.0.0.1";
public static final int DEFAULT_METRICS_PORT = 9545; public static final int DEFAULT_METRICS_PORT = 9545;
@ -40,7 +39,7 @@ public class MetricsConfiguration {
private String pushHost; private String pushHost;
private int pushInterval; private int pushInterval;
private String prometheusJob; private String prometheusJob;
private Collection<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1"); private List<String> hostsWhitelist = Arrays.asList("localhost", "127.0.0.1");
public static MetricsConfiguration createDefault() { public static MetricsConfiguration createDefault() {
final MetricsConfiguration metricsConfiguration = new MetricsConfiguration(); final MetricsConfiguration metricsConfiguration = new MetricsConfiguration();
@ -135,7 +134,7 @@ public class MetricsConfiguration {
return Collections.unmodifiableCollection(this.hostsWhitelist); return Collections.unmodifiableCollection(this.hostsWhitelist);
} }
public void setHostsWhitelist(final Collection<String> hostsWhitelist) { public void setHostsWhitelist(final List<String> hostsWhitelist) {
this.hostsWhitelist = hostsWhitelist; this.hostsWhitelist = hostsWhitelist;
} }
@ -182,8 +181,7 @@ public class MetricsConfiguration {
&& Objects.equals(host, that.host) && Objects.equals(host, that.host)
&& Objects.equals(pushHost, that.pushHost) && Objects.equals(pushHost, that.pushHost)
&& Objects.equals(prometheusJob, that.prometheusJob) && Objects.equals(prometheusJob, that.prometheusJob)
&& com.google.common.base.Objects.equal( && Objects.equals(hostsWhitelist, that.hostsWhitelist);
Lists.newArrayList(hostsWhitelist), Lists.newArrayList(that.hostsWhitelist));
} }
@Override @Override

@ -28,7 +28,6 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.io.Resources; import com.google.common.io.Resources;
public class EthNetworkConfig { public class EthNetworkConfig {
@ -78,7 +77,7 @@ public class EthNetworkConfig {
final EthNetworkConfig that = (EthNetworkConfig) o; final EthNetworkConfig that = (EthNetworkConfig) o;
return networkId == that.networkId return networkId == that.networkId
&& Objects.equals(genesisConfig, that.genesisConfig) && Objects.equals(genesisConfig, that.genesisConfig)
&& Objects.equals(Lists.newArrayList(bootNodes), Lists.newArrayList(that.bootNodes)); && Objects.equals(bootNodes, that.bootNodes);
} }
@Override @Override

@ -358,7 +358,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
converter = RpcApisConverter.class, converter = RpcApisConverter.class,
description = description =
"Comma separated list of APIs to enable on JSON-RPC WebSocket service (default: ${DEFAULT-VALUE})") "Comma separated list of APIs to enable on JSON-RPC WebSocket service (default: ${DEFAULT-VALUE})")
private final Collection<RpcApi> rpcWsApis = DEFAULT_JSON_RPC_APIS; private final List<RpcApi> rpcWsApis = DEFAULT_JSON_RPC_APIS;
@Option( @Option(
names = {"--rpc-ws-authentication-enabled"}, names = {"--rpc-ws-authentication-enabled"},

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.cli.custom; package tech.pegasys.pantheon.cli.custom;
import java.util.AbstractCollection; import java.util.AbstractList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -26,7 +26,7 @@ import javax.annotation.Nonnull;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
public class CorsAllowedOriginsProperty extends AbstractCollection<String> { public class CorsAllowedOriginsProperty extends AbstractList<String> {
private final List<String> domains = new ArrayList<>(); private final List<String> domains = new ArrayList<>();
@ -52,6 +52,11 @@ public class CorsAllowedOriginsProperty extends AbstractCollection<String> {
return addAll(Collections.singleton(string)); return addAll(Collections.singleton(string));
} }
@Override
public String get(final int index) {
return domains.get(index);
}
@Override @Override
public boolean addAll(final Collection<? extends String> collection) { public boolean addAll(final Collection<? extends String> collection) {
final int initialSize = domains.size(); final int initialSize = domains.size();

@ -12,7 +12,7 @@
*/ */
package tech.pegasys.pantheon.cli.custom; package tech.pegasys.pantheon.cli.custom;
import java.util.AbstractCollection; import java.util.AbstractList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -23,7 +23,7 @@ import javax.annotation.Nonnull;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
public class JsonRPCWhitelistHostsProperty extends AbstractCollection<String> { public class JsonRPCWhitelistHostsProperty extends AbstractList<String> {
private final List<String> hostnamesWhitelist = new ArrayList<>(); private final List<String> hostnamesWhitelist = new ArrayList<>();
@ -49,6 +49,11 @@ public class JsonRPCWhitelistHostsProperty extends AbstractCollection<String> {
return addAll(Collections.singleton(string)); return addAll(Collections.singleton(string));
} }
@Override
public String get(final int index) {
return hostnamesWhitelist.get(index);
}
@Override @Override
public boolean addAll(final Collection<? extends String> collection) { public boolean addAll(final Collection<? extends String> collection) {
final int initialSize = hostnamesWhitelist.size(); final int initialSize = hostnamesWhitelist.size();

@ -60,7 +60,6 @@ import java.net.URL;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -277,7 +276,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
.replace("~/genesis.json", escapeTomlString(genesisFile.toString())); .replace("~/genesis.json", escapeTomlString(genesisFile.toString()));
final Path toml = createTempFile("toml", updatedConfig.getBytes(UTF_8)); final Path toml = createTempFile("toml", updatedConfig.getBytes(UTF_8));
final Collection<RpcApi> expectedApis = asList(ETH, WEB3); final List<RpcApi> expectedApis = asList(ETH, WEB3);
final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault();
jsonRpcConfiguration.setEnabled(false); jsonRpcConfiguration.setEnabled(false);

@ -20,11 +20,11 @@ import tech.pegasys.pantheon.util.bytes.BytesValue;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URI; import java.net.URI;
import java.util.Objects;
import java.util.OptionalInt; import java.util.OptionalInt;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.google.common.base.Objects;
import com.google.common.net.InetAddresses; import com.google.common.net.InetAddresses;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
@ -128,9 +128,9 @@ public class EnodeURL {
return false; return false;
} }
return Objects.equal(enodeA.nodeId, enodeB.nodeId) return Objects.equals(enodeA.nodeId, enodeB.nodeId)
&& Objects.equal(enodeA.ip, enodeB.ip) && Objects.equals(enodeA.ip, enodeB.ip)
&& Objects.equal(enodeA.listeningPort, enodeB.listeningPort); && Objects.equals(enodeA.listeningPort, enodeB.listeningPort);
} }
public URI toURI() { public URI toURI() {
@ -209,15 +209,15 @@ public class EnodeURL {
return false; return false;
} }
EnodeURL enodeURL = (EnodeURL) o; EnodeURL enodeURL = (EnodeURL) o;
return Objects.equal(nodeId, enodeURL.nodeId) return Objects.equals(nodeId, enodeURL.nodeId)
&& Objects.equal(ip, enodeURL.ip) && Objects.equals(ip, enodeURL.ip)
&& Objects.equal(listeningPort, enodeURL.listeningPort) && Objects.equals(listeningPort, enodeURL.listeningPort)
&& Objects.equal(discoveryPort, enodeURL.discoveryPort); && Objects.equals(discoveryPort, enodeURL.discoveryPort);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(nodeId, ip, listeningPort, discoveryPort); return Objects.hash(nodeId, ip, listeningPort, discoveryPort);
} }
@Override @Override

Loading…
Cancel
Save