当前位置: 首页>>代码示例>>Java>>正文


Java TypeName.VOID属性代码示例

本文整理汇总了Java中com.squareup.javapoet.TypeName.VOID属性的典型用法代码示例。如果您正苦于以下问题:Java TypeName.VOID属性的具体用法?Java TypeName.VOID怎么用?Java TypeName.VOID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.squareup.javapoet.TypeName的用法示例。


在下文中一共展示了TypeName.VOID属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bestGuess

private static TypeName bestGuess(String type) {
  switch (type) {
    case "void": return TypeName.VOID;
    case "boolean": return TypeName.BOOLEAN;
    case "byte": return TypeName.BYTE;
    case "char": return TypeName.CHAR;
    case "double": return TypeName.DOUBLE;
    case "float": return TypeName.FLOAT;
    case "int": return TypeName.INT;
    case "long": return TypeName.LONG;
    case "short": return TypeName.SHORT;
    default:
      int left = type.indexOf('<');
      if (left != -1) {
        ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
        List<TypeName> typeArguments = new ArrayList<>();
        do {
          typeArguments.add(WildcardTypeName.subtypeOf(Object.class));
          left = type.indexOf('<', left + 1);
        } while (left != -1);
        return ParameterizedTypeName.get(typeClassName,
            typeArguments.toArray(new TypeName[typeArguments.size()]));
      }
      return ClassName.bestGuess(type);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:BindingSet.java

示例2: classToTypeName

public static TypeName classToTypeName(Class scalar) {
    if (scalar.isPrimitive()) {
        switch (scalar.getSimpleName()) {
            case "int":
                return TypeName.INT;

            case "boolean":
                return TypeName.BOOLEAN;

            case "double":
                return TypeName.DOUBLE;

            case "float":
                return TypeName.FLOAT;

            case "byte":
                return TypeName.BYTE;

            case "char":
                return TypeName.CHAR;

            case "short":
                return TypeName.SHORT;

            case "long":
                return TypeName.LONG;

            case "void":
                return TypeName.VOID; // ?

            default:
                throw new GenerationException("can't handle type: " + scalar);
        }
    } else {
        return ClassName.get(scalar);
    }
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:37,代码来源:Scalars.java

示例3: bestGuess

public static TypeName bestGuess(String type) {
    switch (type) {
        case "void":
            return TypeName.VOID;
        case "boolean":
            return TypeName.BOOLEAN;
        case "byte":
            return TypeName.BYTE;
        case "char":
            return TypeName.CHAR;
        case "double":
            return TypeName.DOUBLE;
        case "float":
            return TypeName.FLOAT;
        case "int":
            return TypeName.INT;
        case "long":
            return TypeName.LONG;
        case "short":
            return TypeName.SHORT;
        default:
            int left = type.indexOf('<');
            if (left != -1) {
                ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
                List<TypeName> typeArguments = new ArrayList<>();
                do {
                    typeArguments.add(WildcardTypeName.subtypeOf(Object.class));
                    left = type.indexOf('<', left + 1);
                } while (left != -1);
                return ParameterizedTypeName.get(typeClassName,
                        typeArguments.toArray(new TypeName[typeArguments.size()]));
            }
            return ClassName.bestGuess(type);
    }
}
 
开发者ID:wangjiegulu,项目名称:RapidRouter,代码行数:35,代码来源:EasyType.java

示例4: bestGuessDeep

/**
 * @param type
 * @return
 */
public static TypeName bestGuessDeep(String type) {
    switch (type) {
        case "void":
            return TypeName.VOID;
        case "boolean":
            return TypeName.BOOLEAN;
        case "byte":
            return TypeName.BYTE;
        case "char":
            return TypeName.CHAR;
        case "double":
            return TypeName.DOUBLE;
        case "float":
            return TypeName.FLOAT;
        case "int":
            return TypeName.INT;
        case "long":
            return TypeName.LONG;
        case "short":
            return TypeName.SHORT;
        default:
            int left = type.indexOf('<');
            int right = type.indexOf('>');
            if (-1 != left && -1 != right) {
                ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
                List<TypeName> typeArguments = new ArrayList<>();
                do {
                    typeArguments.add(WildcardTypeName.subtypeOf(bestGuess(type.substring(left + 1, right))));
                    left = type.indexOf('<', left + 1);
                    right = type.indexOf('>', right - 1);
                } while (left != -1);
                return ParameterizedTypeName.get(typeClassName,
                        typeArguments.toArray(new TypeName[typeArguments.size()]));
            }
            return ClassName.bestGuess(type);
    }
}
 
开发者ID:wangjiegulu,项目名称:RapidRouter,代码行数:41,代码来源:EasyType.java

示例5: getTypeName

public static TypeName getTypeName(String type){
    switch (type){
        case NAME_int:
            return TypeName.INT;

        case NAME_long:
            return TypeName.LONG;

        case NAME_short:
            return TypeName.SHORT;

        case NAME_byte:
            return TypeName.BYTE;

        case NAME_boolean:
            return TypeName.BOOLEAN;

        case NAME_float:
            return TypeName.FLOAT;

        case NAME_double:
            return TypeName.DOUBLE;

        case NAME_char:
            return TypeName.CHAR;

        case NAME_void:
            return TypeName.VOID;
    }
    return ClassName.bestGuess(type);
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:31,代码来源:TypeUtils.java

示例6: generateInitMapMethod

/**
 * create init map method
 */
private MethodSpec generateInitMapMethod() {
    TypeName returnType = TypeName.VOID;

    MethodSpec.Builder openUriMethodSpecBuilder = MethodSpec.methodBuilder("initMap")
            .returns(returnType)
            .addAnnotation(Override.class)
            .addModifiers(Modifier.PUBLIC);

    openUriMethodSpecBuilder.addStatement("super.initMap()");

    for (Node node : routerNodes) {
        openUriMethodSpecBuilder.addStatement(
                mRouteMapperFieldName + ".put($S,$T.class)",
                node.getPath(),
                ClassName.get((TypeElement) node.getRawType()));

        // Make map body for paramsType
        StringBuilder mapBodyBuilder = new StringBuilder();
        Map<String, Integer> paramsType = node.getParamsType();
        if (MapUtils.isNotEmpty(paramsType)) {
            for (Map.Entry<String, Integer> types : paramsType.entrySet()) {
                mapBodyBuilder.append("put(\"").append(types.getKey()).append("\", ").append(types.getValue()).append("); ");
            }
        }
        String mapBody = mapBodyBuilder.toString();
        logger.info(">>> mapBody: " + mapBody + " <<<");
        if (!StringUtils.isEmpty(mapBody)) {
            openUriMethodSpecBuilder.addStatement(
                    mParamsMapperFieldName + ".put($T.class,"
                            + "new java.util.HashMap<String, Integer>(){{" + mapBody + "}}" + ")",
                    ClassName.get((TypeElement) node.getRawType()));
        }
    }

    return openUriMethodSpecBuilder.build();
}
 
开发者ID:luojilab,项目名称:DDComponentForAndroid,代码行数:39,代码来源:RouterProcessor.java

示例7: bestGuess

private static TypeName bestGuess(String type) {
    switch (type) {
        case "void":
            return TypeName.VOID;
        case "boolean":
            return TypeName.BOOLEAN;
        case "byte":
            return TypeName.BYTE;
        case "char":
            return TypeName.CHAR;
        case "double":
            return TypeName.DOUBLE;
        case "float":
            return TypeName.FLOAT;
        case "int":
            return TypeName.INT;
        case "long":
            return TypeName.LONG;
        case "short":
            return TypeName.SHORT;
        default:
            int left = type.indexOf('<');
            if (left != -1) {
                ClassName typeClassName = ClassName.bestGuess(type.substring(0, left));
                List<TypeName> typeArguments = new ArrayList<>();
                do {
                    typeArguments.add(WildcardTypeName.subtypeOf(Object.class));
                    left = type.indexOf('<', left + 1);
                } while (left != -1);
                return ParameterizedTypeName.get(typeClassName,
                        typeArguments.toArray(new TypeName[typeArguments.size()]));
            }
            return ClassName.bestGuess(type);
    }
}
 
开发者ID:qq542391099,项目名称:butterknife-parent,代码行数:35,代码来源:BindingSet.java

示例8: isVoid

public boolean isVoid(TypeName returnType) {
    return returnType == TypeName.VOID || ClassName.get("java.lang", "Void").equals(returnType);
}
 
开发者ID:florent37,项目名称:Rx.Observe,代码行数:3,代码来源:ProcessUtils.java

示例9: prepareNewThreadMethod

private void prepareNewThreadMethod(MethodThreadStitching binding,
        MethodSpec.Builder methodSpecBuilder, String returnStatement) {
    if (binding.getReturnType() == TypeName.VOID) {
        methodSpecBuilder
                .returns(TypeName.VOID);
        methodSpecBuilder
                .addStatement("$T.getInstance().submitVoidTask($L)",
                        mNewThreadExecutor,
                        TypeSpec.anonymousClassBuilder("")
                                .addSuperinterface(ClassName.get(Runnable.class))
                                .addMethod(MethodSpec.methodBuilder("run")
                                        .addAnnotation(Override.class)
                                        .addModifiers(Modifier.PUBLIC)
                                        .returns(binding.getReturnType())
                                        .addStatement("$L", returnStatement)
                                        .build())
                                .build());
    } else {
        methodSpecBuilder
                .returns(binding.getReturnType().box());
        methodSpecBuilder
                .beginControlFlow("try")
                .addStatement("return $T.getInstance().submitCallableTask($L)",
                        mNewThreadExecutor,
                        TypeSpec.anonymousClassBuilder("")
                                .addSuperinterface(ParameterizedTypeName
                                        .get(ClassName.get(Callable.class),
                                                binding.getReturnType().box()))
                                .addMethod(MethodSpec.methodBuilder("call")
                                        .addAnnotation(Override.class)
                                        .addModifiers(Modifier.PUBLIC)
                                        .addException(Exception.class)
                                        .returns(binding.getReturnType().box())
                                        .addStatement("return $L", returnStatement)
                                        .build())
                                .build())
                .nextControlFlow(Constants.CATCH_BLOCK, InterruptedException.class)
                .addStatement(Constants.PRINT_STACKTRACE)
                .addStatement(Constants.RETURN_NULL)
                .nextControlFlow(Constants.CATCH_BLOCK, ExecutionException.class)
                .addStatement(Constants.PRINT_STACKTRACE)
                .addStatement(Constants.RETURN_NULL)
                .endControlFlow();
    }

}
 
开发者ID:amitkma,项目名称:Stitch,代码行数:46,代码来源:StitchGenerator.java

示例10: prepareAnyThreadMethod

private void prepareAnyThreadMethod(MethodThreadStitching binding,
        MethodSpec.Builder methodSpecBuilder, String returnStatement) {
    if (binding.getReturnType() == TypeName.VOID) {
        methodSpecBuilder
                .returns(TypeName.VOID);
        methodSpecBuilder
                .addStatement("$T.getInstance().submitVoidTask($L)",
                        mBackgroundExecutor,
                        TypeSpec.anonymousClassBuilder("")
                                .addSuperinterface(ClassName.get(Runnable.class))
                                .addMethod(MethodSpec.methodBuilder("run")
                                        .addAnnotation(Override.class)
                                        .addModifiers(Modifier.PUBLIC)
                                        .returns(binding.getReturnType())
                                        .addStatement("$L", returnStatement)
                                        .build())
                                .build());
    } else {
        methodSpecBuilder
                .returns(binding.getReturnType().box());
        methodSpecBuilder
                .beginControlFlow("try")
                .addStatement("return $T.getInstance().submitCallableTask($L)",
                        mBackgroundExecutor,
                        TypeSpec.anonymousClassBuilder("")
                                .addSuperinterface(ParameterizedTypeName
                                        .get(ClassName.get(Callable.class),
                                                binding.getReturnType().box()))
                                .addMethod(MethodSpec.methodBuilder("call")
                                        .addAnnotation(Override.class)
                                        .addModifiers(Modifier.PUBLIC)
                                        .addException(Exception.class)
                                        .returns(binding.getReturnType().box())
                                        .addStatement("return $L", returnStatement)
                                        .build())
                                .build())
                .nextControlFlow(Constants.CATCH_BLOCK, InterruptedException.class)
                .addStatement(Constants.PRINT_STACKTRACE)
                .addStatement(Constants.RETURN_NULL)
                .nextControlFlow(Constants.CATCH_BLOCK, ExecutionException.class)
                .addStatement(Constants.PRINT_STACKTRACE)
                .addStatement(Constants.RETURN_NULL)
                .endControlFlow();
    }
}
 
开发者ID:amitkma,项目名称:Stitch,代码行数:45,代码来源:StitchGenerator.java


注:本文中的com.squareup.javapoet.TypeName.VOID属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。