Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Nov 24, 2024
1 parent 8d3c07b commit 3dc9791
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions src/main/java/com/esaulpaugh/headlong/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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: -");
Expand All @@ -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 {
Expand All @@ -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<Tuple> tt;
final Tuple values;
if(function) {
if (function) {
Function f = Function.parse(signature);
tt = f.getInputs();
values = f.decodeCall(abiBytes);
Expand Down Expand Up @@ -219,17 +219,17 @@ 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;
final int end = args.length;
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);
Expand Down Expand Up @@ -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");
Expand All @@ -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();
Expand Down Expand Up @@ -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(' ');
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/esaulpaugh/headlong/cli/SugarSerial.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 '");
Expand All @@ -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;
}
Expand Down

0 comments on commit 3dc9791

Please sign in to comment.