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


Java ClassOrInterfaceType.setTypeArgs方法代码示例

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


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

示例1: getResolvedName

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
public static ClassOrInterfaceType getResolvedName(final JavaType target,
        final JavaType current, final com.github.javaparser.ast.CompilationUnit compilationUnit) {
    final NameExpr nameExpr = JavaParserUtils.importTypeIfRequired(target,
            compilationUnit.getImports(), current);
    final ClassOrInterfaceType resolvedName = JavaParserUtils
            .getClassOrInterfaceType(nameExpr);
    if (current.getParameters() != null
            && current.getParameters().size() > 0) {
        resolvedName.setTypeArgs(new ArrayList<Type>());
        for (final JavaType param : current.getParameters()) {
            resolvedName.getTypeArgs().add(
                    getResolvedName(target, param, compilationUnit));
        }
    }

    return resolvedName;
}
 
开发者ID:BenDol,项目名称:Databind,代码行数:18,代码来源:JavaParserUtils.java

示例2: importParametersForType

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
public static ReferenceType importParametersForType(
        final JavaType targetType, final List<ImportDeclaration> imports,
        final JavaType typeToImport) {
    Validate.notNull(targetType, "Target type is required");
    Validate.notNull(imports, "Compilation unit imports required");
    Validate.notNull(typeToImport, "Java type to import is required");

    final ClassOrInterfaceType cit = getClassOrInterfaceType(importTypeIfRequired(
            targetType, imports, typeToImport));
    
    // Add any type arguments presented for the return type
    if (typeToImport.getParameters().size() > 0) {
        final List<Type> typeArgs = new ArrayList<Type>();
        cit.setTypeArgs(typeArgs);
        for (final JavaType parameter : typeToImport
                .getParameters()) {
            typeArgs.add(JavaParserUtils.importParametersForType(
                    targetType,
                    imports, parameter));
        }
    }
    return  new ReferenceType(cit);
}
 
开发者ID:BenDol,项目名称:Databind,代码行数:24,代码来源:JavaParserUtils.java

示例3: getDeclaration

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
/**
 * Creates a socket hint declaration from the constructor.
 *
 * @return The field declaration
 */
public FieldDeclaration getDeclaration() {
  final int modifiers = ModifierSet.addModifier(ModifierSet.FINAL, ModifierSet.PRIVATE);

  final ClassOrInterfaceType socketHintType = new ClassOrInterfaceType(SOCKET_HINT_CLASS_NAME);
  socketHintType.setTypeArgs(Collections.singletonList(genericType));

  final ClassOrInterfaceType socketHintBuilderType = new ClassOrInterfaceType(new
      ClassOrInterfaceType(SOCKET_HINT_CLASS_NAME), SOCKET_HINT_BUILDER_CLASS_NAME);

  final List<VariableDeclarator> variableDeclarations = new ArrayList<>();
  for (DefinedParamType paramType : paramTypes) {
    // Don't generate hint for ignored param
    if (paramType.isIgnored()) {
      continue;
    }

    String hintName = paramType.getName();
    // The variableId
    final String fullHintName = hintName
        + (isOutput() ? OUTPUT_POSTFIX : INPUT_POSTFIX)
        + HINT_POSTFIX;
    // The name hint of the socket hint
    final StringLiteralExpr stringLiteralExpr = new StringLiteralExpr(hintName);

    variableDeclarations.add(
        new VariableDeclarator(
            new VariableDeclaratorId(fullHintName),
            // Create new instantiation of type socket hint type
            socketHintBuilder(socketHintBuilderType, stringLiteralExpr, paramType)
        )
    );
  }
  if (variableDeclarations.isEmpty()) {
    return null;
  }

  return new FieldDeclaration(modifiers, socketHintType, variableDeclarations);
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:44,代码来源:SocketHintDeclaration.java

示例4: getSocketReturnParam

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
public static Type getSocketReturnParam(String socketNameType) {
  ClassOrInterfaceType socketType = new ClassOrInterfaceType(null, socketNameType);
  socketType.setTypeArgs(Arrays.asList(new WildcardType()));
  return new ReferenceType(socketType, 1);
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:6,代码来源:SocketHintDeclarationCollection.java

示例5: generateCopyExpression

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
private Expression generateCopyExpression(DefinedParamType type, String inputParmId, int
    inputIndex, String outputParamId, int outputIndex) {
  // GOAL: ((InputSocket<Mat>) inputs[0]).getValue().get().assignTo(((OutputSocket<Mat>)
  // outputs[0]).getValue().get());
  final ClassOrInterfaceType outputType = new ClassOrInterfaceType("OutputSocket");
  final ClassOrInterfaceType inputType = new ClassOrInterfaceType("InputSocket");
  outputType.setTypeArgs(Collections.singletonList(type.getType()));
  inputType.setTypeArgs(Collections.singletonList(type.getType()));

  final MethodCallExpr copyExpression = new MethodCallExpr(
      new MethodCallExpr(
          getOrSetValueExpression(
              new EnclosedExpr(
                  new CastExpr(
                      inputType,
                      arrayAccessExpr(inputParmId, inputIndex)
                  )
              ),
              null
          ),
          "get"
      ),
      "assignTo",
      Collections.singletonList(
          new MethodCallExpr(
              getOrSetValueExpression(
                  new EnclosedExpr(
                      new CastExpr(
                          outputType,
                          arrayAccessExpr(outputParamId, outputIndex)
                      )
                  ),
                  null
              ),
              "get"
          )
      )
  );
  copyExpression.setComment(new BlockComment(
      " Sets the value of the input Mat to the output because this operation does not have a " +
          "destination Mat. "
  ));
  return copyExpression;
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:45,代码来源:SocketHintDeclarationCollection.java

示例6: doMerge

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入方法依赖的package包/类
@Override
public ClassOrInterfaceType doMerge(ClassOrInterfaceType first, ClassOrInterfaceType second) {

    ClassOrInterfaceType cift = new ClassOrInterfaceType();

    cift.setName(first.getName());
    cift.setScope(first.getScope());
    cift.setTypeArgs(first.getTypeArgs());

    cift.setAnnotations(mergeCollections(first.getAnnotations(), second.getAnnotations()));

    return cift;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:14,代码来源:ClassOrInterfaceTypeMerger.java


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