@Test public void testBuildTypeName() { assertThat(buildTypeName("uint256"), is(ClassName.get(Uint256.class))); assertThat(buildTypeName("uint64"), is(ClassName.get(Uint64.class))); assertThat(buildTypeName("string"), is(ClassName.get(Utf8String.class))); assertThat(buildTypeName("uint256[]"), is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class))); assertThat(buildTypeName("uint256[] storage"), is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class))); assertThat(buildTypeName("uint256[] memory"), is(ParameterizedTypeName.get(DynamicArray.class, Uint256.class))); assertThat(buildTypeName("uint256[10]"), is(ParameterizedTypeName.get(StaticArray10.class, Uint256.class))); assertThat(buildTypeName("uint256[33]"), is(ParameterizedTypeName.get(StaticArray.class, Uint256.class))); assertThat(buildTypeName("uint256[10][3]"), is(ParameterizedTypeName.get(ClassName.get(StaticArray3.class), ParameterizedTypeName.get(StaticArray10.class, Uint256.class)))); assertThat(buildTypeName("uint256[2][]"), is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class), ParameterizedTypeName.get(StaticArray2.class, Uint256.class)))); assertThat(buildTypeName("uint256[33][]"), is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class), ParameterizedTypeName.get(StaticArray.class, Uint256.class)))); assertThat(buildTypeName("uint256[][]"), is(ParameterizedTypeName.get(ClassName.get(DynamicArray.class), ParameterizedTypeName.get(DynamicArray.class, Uint256.class)))); }
static TypeName buildTypeName(String typeDeclaration) { String type = trimStorageDeclaration(typeDeclaration); Matcher matcher = pattern.matcher(type); if (matcher.find()) { Class<?> baseType = AbiTypes.getType(matcher.group(1)); String firstArrayDimension = matcher.group(2); String secondArrayDimension = matcher.group(3); TypeName typeName; if ("".equals(firstArrayDimension)) { typeName = ParameterizedTypeName.get(DynamicArray.class, baseType); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(firstArrayDimension); typeName = ParameterizedTypeName.get(rawType, baseType); } if (secondArrayDimension != null) { if ("".equals(secondArrayDimension)) { return ParameterizedTypeName.get(ClassName.get(DynamicArray.class), typeName); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(secondArrayDimension); return ParameterizedTypeName.get(ClassName.get(rawType), typeName); } } return typeName; } else { Class<?> cls = AbiTypes.getType(type); return ClassName.get(cls); } }
SolidityFunctionWrapper extends Generator { static TypeName buildTypeName(String typeDeclaration) { String type = trimStorageDeclaration(typeDeclaration); Matcher matcher = pattern.matcher(type); if (matcher.find()) { Class<?> baseType = AbiTypes.getType(matcher.group(1)); String firstArrayDimension = matcher.group(2); String secondArrayDimension = matcher.group(3); TypeName typeName; if ("".equals(firstArrayDimension)) { typeName = ParameterizedTypeName.get(DynamicArray.class, baseType); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(firstArrayDimension); typeName = ParameterizedTypeName.get(rawType, baseType); } if (secondArrayDimension != null) { if ("".equals(secondArrayDimension)) { return ParameterizedTypeName.get(ClassName.get(DynamicArray.class), typeName); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(secondArrayDimension); return ParameterizedTypeName.get(ClassName.get(rawType), typeName); } } return typeName; } else { Class<?> cls = AbiTypes.getType(type); return ClassName.get(cls); } } }
SolidityFunctionWrapper extends Generator { static TypeName buildTypeName(String typeDeclaration) { String type = trimStorageDeclaration(typeDeclaration); Matcher matcher = pattern.matcher(type); if (matcher.find()) { Class<?> baseType = AbiTypes.getType(matcher.group(1)); String firstArrayDimension = matcher.group(2); String secondArrayDimension = matcher.group(3); TypeName typeName; if ("".equals(firstArrayDimension)) { typeName = ParameterizedTypeName.get(DynamicArray.class, baseType); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(firstArrayDimension); typeName = ParameterizedTypeName.get(rawType, baseType); } if (secondArrayDimension != null) { if ("".equals(secondArrayDimension)) { return ParameterizedTypeName.get(ClassName.get(DynamicArray.class), typeName); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(secondArrayDimension); return ParameterizedTypeName.get(ClassName.get(rawType), typeName); } } return typeName; } else { Class<?> cls = AbiTypes.getType(type); return ClassName.get(cls); } } SolidityFunctionWrapper(boolean useNativeJavaTypes);   SolidityFunctionWrapper(boolean useNativeJavaTypes, GenerationReporter reporter); }
SolidityFunctionWrapper extends Generator { static TypeName buildTypeName(String typeDeclaration) { String type = trimStorageDeclaration(typeDeclaration); Matcher matcher = pattern.matcher(type); if (matcher.find()) { Class<?> baseType = AbiTypes.getType(matcher.group(1)); String firstArrayDimension = matcher.group(2); String secondArrayDimension = matcher.group(3); TypeName typeName; if ("".equals(firstArrayDimension)) { typeName = ParameterizedTypeName.get(DynamicArray.class, baseType); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(firstArrayDimension); typeName = ParameterizedTypeName.get(rawType, baseType); } if (secondArrayDimension != null) { if ("".equals(secondArrayDimension)) { return ParameterizedTypeName.get(ClassName.get(DynamicArray.class), typeName); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(secondArrayDimension); return ParameterizedTypeName.get(ClassName.get(rawType), typeName); } } return typeName; } else { Class<?> cls = AbiTypes.getType(type); return ClassName.get(cls); } } SolidityFunctionWrapper(boolean useNativeJavaTypes);   SolidityFunctionWrapper(boolean useNativeJavaTypes, GenerationReporter reporter); @SuppressWarnings("unchecked") void generateJavaFiles(
            String contractName, String bin, String abi, String destinationDir,
            String basePackageName); }
SolidityFunctionWrapper extends Generator { static TypeName buildTypeName(String typeDeclaration) { String type = trimStorageDeclaration(typeDeclaration); Matcher matcher = pattern.matcher(type); if (matcher.find()) { Class<?> baseType = AbiTypes.getType(matcher.group(1)); String firstArrayDimension = matcher.group(2); String secondArrayDimension = matcher.group(3); TypeName typeName; if ("".equals(firstArrayDimension)) { typeName = ParameterizedTypeName.get(DynamicArray.class, baseType); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(firstArrayDimension); typeName = ParameterizedTypeName.get(rawType, baseType); } if (secondArrayDimension != null) { if ("".equals(secondArrayDimension)) { return ParameterizedTypeName.get(ClassName.get(DynamicArray.class), typeName); } else { Class<?> rawType = getStaticArrayTypeReferenceClass(secondArrayDimension); return ParameterizedTypeName.get(ClassName.get(rawType), typeName); } } return typeName; } else { Class<?> cls = AbiTypes.getType(type); return ClassName.get(cls); } } SolidityFunctionWrapper(boolean useNativeJavaTypes);   SolidityFunctionWrapper(boolean useNativeJavaTypes, GenerationReporter reporter); @SuppressWarnings("unchecked") void generateJavaFiles(
            String contractName, String bin, String abi, String destinationDir,
            String basePackageName);  }