diff --git a/src/main/java/com/esaulpaugh/headlong/cli/Main.java b/src/main/java/com/esaulpaugh/headlong/cli/Main.java index 6e51ee1..a3eb7d1 100644 --- a/src/main/java/com/esaulpaugh/headlong/cli/Main.java +++ b/src/main/java/com/esaulpaugh/headlong/cli/Main.java @@ -136,7 +136,7 @@ private static String parseVals(String raw, boolean machine, boolean extend) { } private static String validateCommand(String command) { - if(command.charAt(0) == '-') { + if (command.charAt(0) == '-') { return command; } throw new IllegalArgumentException("commands must start with a hyphen: -"); @@ -159,7 +159,7 @@ private static String encodeABI(String[] args, boolean machine, boolean function final String signature = DATA_FIRST.from(args); final String values = parseVals(DATA_SECOND.from(args), machine, true); final ByteBuffer abi; - if(function) { + if (function) { Function f = Function.parse(signature); abi = f.encodeCall(SuperSerial.deserialize(f.getInputs(), values, machine)); } else { @@ -174,7 +174,7 @@ private static String decodeABI(String[] args, boolean machine, boolean function final byte[] abiBytes = Strings.decode(DATA_SECOND.from(args)); final TupleType tt; final Tuple values; - if(function) { + if (function) { Function f = Function.parse(signature); tt = f.getInputs(); values = f.decodeCall(abiBytes); @@ -219,9 +219,9 @@ private static String hexToDec(String[] args, boolean compact) { final char delimiter = compact ? ' ' : '\n'; final String signedStr = DATA_SECOND.from(args); boolean signed = false; - if("signed".equals(signedStr)) { + if ("signed".equals(signedStr)) { signed = true; - } else if(!"unsigned".equals(signedStr)) { + } else if (!"unsigned".equals(signedStr)) { throw new IllegalArgumentException("second datum must be either \"signed\" or \"unsigned\""); } final int start = DATA_SECOND.ordinal() + 1; @@ -229,7 +229,7 @@ private static String hexToDec(String[] args, boolean compact) { final StringBuilder sb = new StringBuilder(); for (int i = start; i < end; i++) { BigInteger val = new BigInteger(args[i], 16); - if(signed) { + if (signed) { val = uint.toSigned(val); } sb.append(val.toString(10)).append(delimiter); @@ -268,9 +268,9 @@ private static int parseTypeBits(String val) { } private static int checkTypeBits(int typeBits) { - if(typeBits > 0) { - if(typeBits <= 256) { - if(typeBits % 8 == 0) { + if (typeBits > 0) { + if (typeBits <= 256) { + if (typeBits % 8 == 0) { return typeBits; } throw new IllegalArgumentException("specified bit length must be a multiple of 8"); @@ -281,7 +281,7 @@ private static int checkTypeBits(int typeBits) { } private static String trimmed(StringBuilder sb, boolean trim) { - if(trim) { + if (trim) { sb.setLength(sb.length() - 1); } return sb.toString(); @@ -392,7 +392,7 @@ private static String makeVersionString(String buildDate, String headlongVersion " │ │ └─ └─┘─ └─┘ │ └─┘ │ │ └─┤ ── └─ │ │\n"; String versionLine = "version " + Main.class.getPackage().getImplementationVersion(); final int padding = 28 - versionLine.length(); - if(padding > 0) { + if (padding > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < padding; i++) { sb.append(' '); diff --git a/src/main/java/com/esaulpaugh/headlong/cli/SugarSerial.java b/src/main/java/com/esaulpaugh/headlong/cli/SugarSerial.java index 0e3d8f8..eb7fa3d 100644 --- a/src/main/java/com/esaulpaugh/headlong/cli/SugarSerial.java +++ b/src/main/java/com/esaulpaugh/headlong/cli/SugarSerial.java @@ -36,7 +36,7 @@ static String desugar(String values, boolean extend) { final StringBuilder sb = new StringBuilder(); final int end = values.length(); int i = 0; - while(i < end) { + while (i < end) { final int q = values.indexOf(SINGLE_QUOTE, i); if (q <= 0) { break; @@ -67,8 +67,8 @@ static String desugar(String values, boolean extend) { sb.append(hex); break; case 'b': - if(val.equals("true")) sb.append("01"); - else if(!val.equals("false")) throw new IllegalArgumentException("unexpected boolean syntax"); + if (val.equals("true")) sb.append("01"); + else if (!val.equals("false")) throw new IllegalArgumentException("unexpected boolean syntax"); break; case '[': throw new IllegalArgumentException("expected space between [ and '"); @@ -81,10 +81,10 @@ static String desugar(String values, boolean extend) { } private static byte[] serializeBigInteger(BigInteger val, boolean extend) { - if(val.signum() > 0) { + if (val.signum() > 0) { return Integers.toBytesUnsigned(val); } - if(val.signum() != 0) { + if (val.signum() != 0) { final byte[] bytes = val.toByteArray(); return extend ? signExtend(bytes) : bytes; }