Skip to content

Commit

Permalink
rename some type params
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Sep 19, 2024
1 parent 1bfbf13 commit b7ea9aa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/esaulpaugh/headlong/abi/ContractError.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

import java.util.Objects;

public final class ContractError<T extends Tuple> implements ABIObject {
public final class ContractError<J extends Tuple> implements ABIObject {

private final String name;
private final TupleType<T> inputs;
private final TupleType<J> inputs;

public ContractError(String name, TupleType<T> inputs) {
public ContractError(String name, TupleType<J> inputs) {
this.name = Objects.requireNonNull(name);
this.inputs = Objects.requireNonNull(inputs);
}
Expand All @@ -41,7 +41,7 @@ public String getName() {

@SuppressWarnings("unchecked")
@Override
public TupleType<T> getInputs() {
public TupleType<J> getInputs() {
return inputs;
}

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/com/esaulpaugh/headlong/abi/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
import java.util.Objects;

/** Represents an event in Ethereum. */
public final class Event<T extends Tuple> implements ABIObject {
public final class Event<J extends Tuple> implements ABIObject {

private static final ArrayType<ByteType, Byte, byte[]> BYTES_32 = TypeFactory.create("bytes32");
public static final byte[][] EMPTY_TOPICS = new byte[0][];

private final String name;
private final boolean anonymous;
private final TupleType<T> inputs;
private final TupleType<J> inputs;
private final TupleType<?> indexedParams;
private final TupleType<?> nonIndexedParams;
private final boolean[] indexManifest;
Expand All @@ -46,7 +46,7 @@ public static <X extends Tuple> Event<X> createAnonymous(String name, TupleType<
return new Event<>(name, true, inputs, indexed);
}

public Event(String name, boolean anonymous, TupleType<T> inputs, boolean... indexed) {
public Event(String name, boolean anonymous, TupleType<J> inputs, boolean... indexed) {
this.name = Objects.requireNonNull(name);
this.inputs = Objects.requireNonNull(inputs);
if (indexed.length != inputs.size()) {
Expand All @@ -71,7 +71,7 @@ public String getName() {

@SuppressWarnings("unchecked")
@Override
public TupleType<T> getInputs() {
public TupleType<J> getInputs() {
return inputs;
}

Expand Down Expand Up @@ -128,13 +128,13 @@ public String toString() {
return toJson(true);
}

public <X extends Tuple> X decodeTopics(byte[][] topics) {
public <T extends Tuple> T decodeTopics(byte[][] topics) {
return Tuple.create(decodeTopicsArray(topics));
}

@SuppressWarnings("unchecked")
public <X extends Tuple> X decodeData(byte[] data) {
return (X) (data == null && nonIndexedParams.isEmpty()
public <T extends Tuple> T decodeData(byte[] data) {
return (T) (data == null && nonIndexedParams.isEmpty()
? Tuple.EMPTY
: nonIndexedParams.decode(data));
}
Expand All @@ -148,8 +148,8 @@ public <X extends Tuple> X decodeData(byte[] data) {
* @return the decoded arguments
*/
@SuppressWarnings("unchecked")
public <X extends Tuple> X decodeArgs(byte[][] topics, byte[] data) {
return (X) mergeDecodedArgs(decodeTopicsArray(topics), decodeData(data));
public <T extends Tuple> T decodeArgs(byte[][] topics, byte[] data) {
return (T) mergeDecodedArgs(decodeTopicsArray(topics), decodeData(data));
}

private Tuple mergeDecodedArgs(Object[] decodedTopics, Tuple decodedData) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/esaulpaugh/headlong/abi/Single.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class Single<A> extends Tuple {
super(elements);
}

public static <A> Single<A> of(A a) {
public static <V> Single<V> of(V a) {
return new Single<>(new Object[] { Tuple.requireNotNull(a, 0) });
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/esaulpaugh/headlong/abi/Tuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Tuple of() {
* @see Single#of(Object)
* @return a tuple with one element
*/
public static <T> Single<T> singleton(T element) {
public static <V> Single<V> singleton(V element) {
return Single.of(element);
}

Expand Down Expand Up @@ -75,15 +75,15 @@ public static <T extends Tuple> T from(Object... elements) {
}

@SuppressWarnings("unchecked")
static <T extends Tuple> T create(Object[] elements) {
static <J extends Tuple> J create(Object[] elements) {
switch (elements.length) {
case 1: return (T) new Single<>(elements);
case 2: return (T) new Pair<>(elements);
case 3: return (T) new Triple<>(elements);
case 4: return (T) new Quadruple<>(elements);
case 5: return (T) new Quintuple<>(elements);
case 6: return (T) new Sextuple<>(elements);
default: return (T) new Tuple(elements);
case 1: return (J) new Single<>(elements);
case 2: return (J) new Pair<>(elements);
case 3: return (J) new Triple<>(elements);
case 4: return (J) new Quadruple<>(elements);
case 5: return (J) new Quintuple<>(elements);
case 6: return (J) new Sextuple<>(elements);
default: return (J) new Tuple(elements);
}
}

Expand Down Expand Up @@ -196,7 +196,7 @@ public final Iterator<Object> iterator() {
*
* @return an independent copy of this tuple
*/
public final <T extends Tuple> T deepCopy() {
public final <J extends Tuple> J deepCopy() {
return create(copy(new Object[elements.length], i -> deepCopyElement(elements[i])));
}

Expand Down

0 comments on commit b7ea9aa

Please sign in to comment.