Skip to content

Commit

Permalink
improve javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Sep 19, 2024
1 parent 5fdd24c commit 7a7bcbd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/esaulpaugh/headlong/abi/IntType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.nio.ByteBuffer;

/** Represents a small integer type such as int8, int32, uint8 or uint24. */
public final class IntType extends UnitType<Integer> {

static final IntType UINT21 = new IntType("uint21", 21, true); // small bit length for Denial-of-Service protection
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/esaulpaugh/headlong/abi/LongType.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.nio.ByteBuffer;

/** Represents a long integer type such as int40, int64, uint32, or uint56. */
public final class LongType extends UnitType<Long> {

LongType(String canonicalType, int bitLength, boolean unsigned) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/esaulpaugh/headlong/abi/TupleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public String getElementInternalType(int index) {
}

/**
* If the compiler can't infer the return type, use a type witness.
* Returns the {@link ABIType} at the given index. If the compiler can't infer the return type, use a type witness.
* <p>
* From Java:
* <blockquote><pre>
Expand All @@ -87,9 +87,9 @@ public String getElementInternalType(int index) {
* {@code TypeFactory.create<TupleType<*>>("(int8)").get<IntType>(0).encode(12)}
* </pre></blockquote>
*
* @param index
* @return
* @param <T>
* @param index the type's index
* @return the type
* @param <T> the expected return type, e.g. {@link BooleanType} or {@link ABIType}&#60;Boolean&#62;
*/
@SuppressWarnings("unchecked")
public <T extends ABIType<?>> T get(int index) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/esaulpaugh/headlong/abi/TypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.esaulpaugh.headlong.abi;

/** Enum representing the variants of {@link ABIObject}. */
public enum TypeEnum {

FUNCTION(ABIJSON.FUNCTION, true),
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/esaulpaugh/headlong/abi/TypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private static void mapByteArray(Map<String, ABIType<?>> map, String type, int a
}

/**
* If the compiler can't infer the return type, use a type witness.
* Creates an {@link ABIType}. If the compiler can't infer the return type, use a type witness.
* <p>
* From Java:
* <blockquote><pre>
Expand All @@ -120,9 +120,9 @@ private static void mapByteArray(Map<String, ABIType<?>> map, String type, int a
* {@code TypeFactory.create<TupleType<*>>("(int8)").get<IntType>(0).encode(12)}
* </pre></blockquote>
*
* @param rawType
* @return
* @param <T>
* @param rawType the type's string representation, e.g. "int" or "(address,bytes)[]"
* @return the type
* @param <T> the expected return type, e.g. {@link IntType} or {@link ABIType}&#60;Integer&#62;
*/
public static <T extends ABIType<?>> T create(String rawType) {
return create(ABIType.FLAGS_NONE, rawType);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/esaulpaugh/headlong/abi/DecodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void testUint() {
Function foo2 = new Function("()", "(uint)");
byte[] _big_ = Strings.decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
BigInteger expected = BigInteger.valueOf(2L).pow(256).subtract(BigInteger.ONE);
BigInteger bi = ((UnitType<?>) foo2.getOutputs().get(0)).maxValue();
BigInteger bi = foo2.getOutputs().<UnitType<?>>get(0).maxValue();
assertEquals(expected, bi);
assertEquals(expected, foo2.decodeReturn(_big_, 0));
BigInteger n = foo2.decodeSingletonReturn(_big_);
Expand Down

0 comments on commit 7a7bcbd

Please sign in to comment.