Java Code Examples for org.web3j.abi.datatypes.Type#MAX_BIT_LENGTH
The following examples show how to use
org.web3j.abi.datatypes.Type#MAX_BIT_LENGTH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbiTypesGenerator.java From client-sdk-java with Apache License 2.0 | 5 votes |
private <T extends Type> void generateIntTypes( Class<T> superclass, String path) throws IOException { String packageName = createPackageName(superclass); ClassName className; for (int bitSize = 8; bitSize <= Type.MAX_BIT_LENGTH; bitSize += 8) { className = ClassName.get(packageName, superclass.getSimpleName() + bitSize); MethodSpec constructorSpec = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(BigInteger.class, "value") .addStatement("super($L, $N)", bitSize, "value") .build(); MethodSpec overideConstructorSpec = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(long.class, "value") .addStatement("this(BigInteger.valueOf(value))") .build(); FieldSpec defaultFieldSpec = FieldSpec .builder(className, DEFAULT, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) .initializer("new $T(BigInteger.ZERO)", className) .build(); TypeSpec intType = TypeSpec.classBuilder(className.simpleName()) .addJavadoc(CODEGEN_WARNING) .superclass(superclass) .addModifiers(Modifier.PUBLIC) .addField(defaultFieldSpec) .addMethods(Arrays.asList(constructorSpec, overideConstructorSpec)) .build(); write(packageName, intType, path); } }
Example 2
Source File: AbiTypesMapperGenerator.java From client-sdk-java with Apache License 2.0 | 5 votes |
private MethodSpec.Builder generateIntTypes(MethodSpec.Builder builder, String packageName) { for (int bitSize = 8; bitSize <= Type.MAX_BIT_LENGTH; bitSize += 8) { builder = addStatement(builder, packageName, Uint.TYPE_NAME + bitSize, Uint.class.getSimpleName() + bitSize); builder = addStatement(builder, packageName, Int.TYPE_NAME + bitSize, Int.class.getSimpleName() + bitSize); } return builder; }
Example 3
Source File: AbiTypesMapperGenerator.java From client-sdk-java with Apache License 2.0 | 5 votes |
private MethodSpec.Builder generateFixedTypes(MethodSpec.Builder builder, String packageName) { for (int mBitSize = 8, nBitSize = Type.MAX_BIT_LENGTH - 8; mBitSize < Type.MAX_BIT_LENGTH && nBitSize > 0; mBitSize += 8, nBitSize -= 8) { String suffix = mBitSize + "x" + nBitSize; builder = addStatement( builder, packageName, Ufixed.TYPE_NAME + suffix, Ufixed.class.getSimpleName() + suffix); builder = addStatement( builder, packageName, Fixed.TYPE_NAME + suffix, Fixed.class.getSimpleName() + suffix); } return builder; }
Example 4
Source File: AbiTypesGenerator.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
private <T extends Type> void generateIntTypes( Class<T> superclass, String path) throws IOException { String packageName = createPackageName(superclass); ClassName className; for (int bitSize = 8; bitSize <= Type.MAX_BIT_LENGTH; bitSize += 8) { className = ClassName.get(packageName, superclass.getSimpleName() + bitSize); MethodSpec constructorSpec = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(BigInteger.class, "value") .addStatement("super($L, $N)", bitSize, "value") .build(); MethodSpec overideConstructorSpec = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(long.class, "value") .addStatement("this(BigInteger.valueOf(value))") .build(); FieldSpec defaultFieldSpec = FieldSpec .builder(className, DEFAULT, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) .initializer("new $T(BigInteger.ZERO)", className) .build(); TypeSpec intType = TypeSpec.classBuilder(className.simpleName()) .addJavadoc(CODEGEN_WARNING) .superclass(superclass) .addModifiers(Modifier.PUBLIC) .addField(defaultFieldSpec) .addMethods(Arrays.asList(constructorSpec, overideConstructorSpec)) .build(); write(packageName, intType, path); } }
Example 5
Source File: AbiTypesMapperGenerator.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
private MethodSpec.Builder generateIntTypes(MethodSpec.Builder builder, String packageName) { for (int bitSize = 8; bitSize <= Type.MAX_BIT_LENGTH; bitSize += 8) { builder = addStatement(builder, packageName, Uint.TYPE_NAME + bitSize, Uint.class.getSimpleName() + bitSize); builder = addStatement(builder, packageName, Int.TYPE_NAME + bitSize, Int.class.getSimpleName() + bitSize); } return builder; }
Example 6
Source File: AbiTypesMapperGenerator.java From etherscan-explorer with GNU General Public License v3.0 | 5 votes |
private MethodSpec.Builder generateFixedTypes(MethodSpec.Builder builder, String packageName) { for (int mBitSize = 8, nBitSize = Type.MAX_BIT_LENGTH - 8; mBitSize < Type.MAX_BIT_LENGTH && nBitSize > 0; mBitSize += 8, nBitSize -= 8) { String suffix = mBitSize + "x" + nBitSize; builder = addStatement( builder, packageName, Ufixed.TYPE_NAME + suffix, Ufixed.class.getSimpleName() + suffix); builder = addStatement( builder, packageName, Fixed.TYPE_NAME + suffix, Fixed.class.getSimpleName() + suffix); } return builder; }
Example 7
Source File: AbiTypesGenerator.java From client-sdk-java with Apache License 2.0 | 4 votes |
private <T extends Type> void generateFixedTypes( Class<T> superclass, String path) throws IOException { String packageName = createPackageName(superclass); ClassName className; for (int mBitSize = 8; mBitSize < Type.MAX_BIT_LENGTH; mBitSize += 8) { inner: for (int nBitSize = 8; nBitSize < Type.MAX_BIT_LENGTH; nBitSize += 8) { if (mBitSize + nBitSize > Type.MAX_BIT_LENGTH) { break inner; } MethodSpec constructorSpec1 = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(BigInteger.class, "value") .addStatement("super($L, $L, $N)", mBitSize, nBitSize, "value") .build(); MethodSpec constructorSpec2 = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(int.class, "mBitSize") .addParameter(int.class, "nBitSize") .addParameter(BigInteger.class, "m") .addParameter(BigInteger.class, "n") .addStatement("super($L, $L, $N, $N)", mBitSize, nBitSize, "m", "n") .build(); className = ClassName.get(packageName, superclass.getSimpleName() + mBitSize + "x" + nBitSize); FieldSpec defaultFieldSpec = FieldSpec .builder(className, DEFAULT, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) .initializer("new $T(BigInteger.ZERO)", className) .build(); TypeSpec fixedType = TypeSpec .classBuilder(className.simpleName()) .addJavadoc(CODEGEN_WARNING) .superclass(superclass) .addModifiers(Modifier.PUBLIC) .addField(defaultFieldSpec) .addMethod(constructorSpec1) .addMethod(constructorSpec2) .build(); write(packageName, fixedType, path); } } }
Example 8
Source File: AbiTypesGenerator.java From etherscan-explorer with GNU General Public License v3.0 | 4 votes |
private <T extends Type> void generateFixedTypes( Class<T> superclass, String path) throws IOException { String packageName = createPackageName(superclass); ClassName className; for (int mBitSize = 8; mBitSize < Type.MAX_BIT_LENGTH; mBitSize += 8) { inner: for (int nBitSize = 8; nBitSize < Type.MAX_BIT_LENGTH; nBitSize += 8) { if (mBitSize + nBitSize > Type.MAX_BIT_LENGTH) { break inner; } MethodSpec constructorSpec1 = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(BigInteger.class, "value") .addStatement("super($L, $L, $N)", mBitSize, nBitSize, "value") .build(); MethodSpec constructorSpec2 = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(int.class, "mBitSize") .addParameter(int.class, "nBitSize") .addParameter(BigInteger.class, "m") .addParameter(BigInteger.class, "n") .addStatement("super($L, $L, $N, $N)", mBitSize, nBitSize, "m", "n") .build(); className = ClassName.get(packageName, superclass.getSimpleName() + mBitSize + "x" + nBitSize); FieldSpec defaultFieldSpec = FieldSpec .builder(className, DEFAULT, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) .initializer("new $T(BigInteger.ZERO)", className) .build(); TypeSpec fixedType = TypeSpec .classBuilder(className.simpleName()) .addJavadoc(CODEGEN_WARNING) .superclass(superclass) .addModifiers(Modifier.PUBLIC) .addField(defaultFieldSpec) .addMethod(constructorSpec1) .addMethod(constructorSpec2) .build(); write(packageName, fixedType, path); } } }
Example 9
Source File: AbiTypesGenerator.java From web3j with Apache License 2.0 | 4 votes |
private <T extends Type> void generateIntTypes(Class<T> superclass, String path) throws IOException { String packageName = createPackageName(superclass); ClassName className; for (int bitSize = 8; bitSize <= Type.MAX_BIT_LENGTH; bitSize += 8) { className = ClassName.get(packageName, superclass.getSimpleName() + bitSize); MethodSpec constructorSpec = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(BigInteger.class, "value") .addStatement("super($L, $N)", bitSize, "value") .build(); MethodSpec overideConstructorSpec = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(long.class, "value") .addStatement("this(BigInteger.valueOf(value))") .build(); FieldSpec defaultFieldSpec = FieldSpec.builder( className, DEFAULT, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) .initializer("new $T(BigInteger.ZERO)", className) .build(); TypeSpec intType = TypeSpec.classBuilder(className.simpleName()) .addJavadoc(CODEGEN_WARNING) .superclass(superclass) .addModifiers(Modifier.PUBLIC) .addField(defaultFieldSpec) .addMethods(Arrays.asList(constructorSpec, overideConstructorSpec)) .build(); write(packageName, intType, path); } }
Example 10
Source File: AbiTypesGenerator.java From web3j with Apache License 2.0 | 4 votes |
private <T extends Type> void generateFixedTypes(Class<T> superclass, String path) throws IOException { String packageName = createPackageName(superclass); ClassName className; for (int mBitSize = 8; mBitSize < Type.MAX_BIT_LENGTH; mBitSize += 8) { inner: for (int nBitSize = 8; nBitSize < Type.MAX_BIT_LENGTH; nBitSize += 8) { if (mBitSize + nBitSize > Type.MAX_BIT_LENGTH) { break inner; } MethodSpec constructorSpec1 = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(BigInteger.class, "value") .addStatement("super($L, $L, $N)", mBitSize, nBitSize, "value") .build(); MethodSpec constructorSpec2 = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(int.class, "mBitSize") .addParameter(int.class, "nBitSize") .addParameter(BigInteger.class, "m") .addParameter(BigInteger.class, "n") .addStatement("super($L, $L, $N, $N)", mBitSize, nBitSize, "m", "n") .build(); className = ClassName.get( packageName, superclass.getSimpleName() + mBitSize + "x" + nBitSize); FieldSpec defaultFieldSpec = FieldSpec.builder( className, DEFAULT, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL) .initializer("new $T(BigInteger.ZERO)", className) .build(); TypeSpec fixedType = TypeSpec.classBuilder(className.simpleName()) .addJavadoc(CODEGEN_WARNING) .superclass(superclass) .addModifiers(Modifier.PUBLIC) .addField(defaultFieldSpec) .addMethod(constructorSpec1) .addMethod(constructorSpec2) .build(); write(packageName, fixedType, path); } } }