Skip to content

Commit

Permalink
improve error message and javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Jan 12, 2024
1 parent 0cd2fd6 commit 6b89510
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/esaulpaugh/headlong/abi/TupleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public Iterator<ABIType<?>> iterator() {
* specified with a {@code true} value in the {@code manifest}. Aside from eliminating items not selected, order is
* preserved.
*
* @param manifest the booleans specifying which elements to select
* @param manifest booleans specifying whether to include the respective elements
* @return the new {@link TupleType}
*/
public TupleType select(boolean... manifest) {
Expand All @@ -353,7 +353,7 @@ public TupleType select(boolean... manifest) {
* elements which are *not* specified with {@code true} values. Aside from eliminating excluded items, order is
* preserved.
*
* @param manifest the booleans specifying which elements to exclude
* @param manifest booleans specifying whether to exclude the respective elements
* @return the new {@link TupleType}
*/
public TupleType exclude(boolean... manifest) {
Expand All @@ -363,15 +363,15 @@ public TupleType exclude(boolean... manifest) {
private TupleType selectElements(final boolean[] manifest, final boolean negate) {
final int size = size();
if(manifest.length == size) {
final StringBuilder canonicalBuilder = new StringBuilder("(");
final StringBuilder canonicalType = new StringBuilder("(");
boolean dynamic = false;
final List<ABIType<?>> selected = new ArrayList<>(size);
final List<String> selectedNames = elementNames == null ? null : new ArrayList<>(size);
final List<String> selectedInternalTypes = elementInternalTypes == null ? null : new ArrayList<>(size);
for (int i = 0; i < size; i++) {
if (negate ^ manifest[i]) {
ABIType<?> e = get(i);
canonicalBuilder.append(e.canonicalType).append(',');
canonicalType.append(e.canonicalType).append(',');
dynamic |= e.dynamic;
selected.add(e);
if (selectedNames != null) {
Expand All @@ -383,15 +383,15 @@ private TupleType selectElements(final boolean[] manifest, final boolean negate)
}
}
return new TupleType(
completeTupleTypeString(canonicalBuilder),
completeTupleTypeString(canonicalType),
dynamic,
selected.toArray(EMPTY_ARRAY),
selectedNames == null ? null : selectedNames.toArray(EMPTY_STRING_ARRAY),
selectedInternalTypes == null ? null : selectedInternalTypes.toArray(EMPTY_STRING_ARRAY),
this.flags
);
}
throw new IllegalArgumentException("manifest.length != size(): " + manifest.length + " != " + size);
throw new IllegalArgumentException("expected manifest length " + size() + " but found length " + manifest.length);
}

private static String completeTupleTypeString(StringBuilder sb) {
Expand Down

0 comments on commit 6b89510

Please sign in to comment.