Skip to content

Commit

Permalink
Strings literals should be placed on the left side when checking for …
Browse files Browse the repository at this point in the history
…equality
  • Loading branch information
kirill-vlasov authored and schildbach committed Jan 6, 2016
1 parent e3e8e80 commit 0de458d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/bitcoinj/core/RejectMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void bitcoinSerializeToStream(OutputStream stream) throws IOException {
byte[] reasonBytes = reason.getBytes("UTF-8");
stream.write(new VarInt(reasonBytes.length).encode());
stream.write(reasonBytes);
if (message.equals("block") || message.equals("tx"))
if ("block".equals(message) || "tx".equals(message))
stream.write(messageHash.getReversedBytes());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static void signPaymentRequest(Protos.PaymentRequest.Builder paymentReque
final Protos.PaymentRequest paymentRequestToSign = paymentRequest.build();

final String algorithm;
if (privateKey.getAlgorithm().equalsIgnoreCase("RSA"))
if ("RSA".equalsIgnoreCase(privateKey.getAlgorithm()))
algorithm = "SHA256withRSA";
else
throw new IllegalStateException(privateKey.getAlgorithm());
Expand Down Expand Up @@ -166,14 +166,14 @@ public static PkiVerificationData verifyPaymentRequestPki(Protos.PaymentRequest
List<X509Certificate> certs = null;
try {
final String pkiType = paymentRequest.getPkiType();
if (pkiType.equals("none"))
if ("none".equals(pkiType))
// Nothing to verify. Everything is fine. Move along.
return null;

String algorithm;
if (pkiType.equals("x509+sha256"))
if ("x509+sha256".equals(pkiType))
algorithm = "SHA256withRSA";
else if (pkiType.equals("x509+sha1"))
else if ("x509+sha1".equals(pkiType))
algorithm = "SHA1withRSA";
else
throw new PaymentProtocolException.InvalidPkiType("Unsupported PKI type: " + pkiType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ private static void dump(String arg) {
Protos.PaymentRequest request = Protos.PaymentRequest.parseFrom(stream);
stream.close();
session = new PaymentSession(request);
} else if (uri.getScheme().equals("http")) {
} else if ("http".equals(uri.getScheme())) {
session = PaymentSession.createFromUrl(arg).get();
} else if (uri.getScheme().equals("bitcoin")) {
} else if ("bitcoin".equals(uri.getScheme())) {
BitcoinURI bcuri = new BitcoinURI(arg);
final String paymentRequestUrl = bcuri.getPaymentRequestUrl();
if (paymentRequestUrl == null) {
Expand Down

0 comments on commit 0de458d

Please sign in to comment.