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


Java Parameter类代码示例

本文整理汇总了Java中com.github.javaparser.ast.body.Parameter的典型用法代码示例。如果您正苦于以下问题:Java Parameter类的具体用法?Java Parameter怎么用?Java Parameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MethodNode

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
MethodNode( MethodDeclaration metDec)
{
    super();
    this.metDec = metDec;
    type = metDec.getType();
    if(metDec.isPrivate())
        modifier = "- ";
    else if(metDec.isPublic())
        modifier = "+ ";
    else if(metDec.isProtected())
        modifier = "# ";
    else
        modifier = "~ ";
    nodeName =  modifier + metDec.getName() + "(";
    if (metDec.getParameters() != null)
    {
        parameters = new ArrayList<Parameter>(metDec.getParameters());
        for (Parameter p : parameters)
            nodeName = nodeName + " " + p + ", ";
        if (nodeName.lastIndexOf(',') > 0 )
            nodeName = nodeName.substring(0, nodeName.lastIndexOf(','));
    }
    nodeName = nodeName + ") : " + type.toString();
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:25,代码来源:MethodNode.java

示例2: hasMain

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
/**
 * A method to check whether the file has a main method in it or not
 * @param file a parameter to take the file to check
 * @return true if the file has a main method; false, if it hasn't
 */
public boolean hasMain( File file) {
    int index = getRow( file);
    if (index != -1) {
        MutableTreeNode node = ((MutableTreeNode) rootNode.getChildAt(index));
        if (node instanceof ClassNode) {
            for (int i = 0; i < ((ClassNode) node).getChildCount(); i++) {
                TreeNode treeNode = (((ClassNode) node).getChildAt(i));
                if (treeNode instanceof MethodNode) {
                    MethodDeclaration metDec = ((MethodNode) treeNode).metDec;
                    if (metDec.getNameAsString().equals("main") &&
                        metDec.isPublic() && metDec.isStatic()) {
                        ArrayList<Parameter> parameters = new ArrayList<Parameter>(metDec.getParameters());
                        if (parameters.size() == 1 && parameters.get(0).toString().startsWith("String[]"))
                            return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:bufferhe4d,项目名称:call-IDE,代码行数:27,代码来源:Parser.java

示例3: visit

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
@Override
public void visit(MethodDeclaration method, Object arg) {
  if (isInModuleStack.isEmpty() || !isInModuleStack.peek()) {
    return;
  }

  if (!hasProvideAnnotation(method)) {
    return;
  }

  String type = method.getType().toString();
  if (hasIntoSetAnnotation(method)) {
    type = "Set<" + type + ">";
  }

  for (Parameter parameter : method.getParameters()) {
    builder.addDependency(type, parameter.getType().toString());
  }
}
 
开发者ID:jraska,项目名称:dagger-visual-graph,代码行数:20,代码来源:ModuleAnnotationVisitor.java

示例4: visit

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
public void visit(MethodDeclaration n, Object arg) {

			MethodDVO methodDVO = new MethodDVO();
			methodDVO.setMethodName(n.getName());
			methodDVO.setVisivility(GargoyleJavaParser.toStringVisibility(n.getModifiers()));
			methodDVO.setDescription(n.getComment() != null ? n.getComment().toString() : "");
			ArrayList<MethodParameterDVO> methodParameterDVOList = new ArrayList<>();
			methodDVO.setMethodParameterDVOList(methodParameterDVOList);
			List<Parameter> parameters = n.getParameters();
			for (Parameter p : parameters) {
				//				String string2 = p.toString();
				VariableDeclaratorId id2 = p.getId();
				String varName = id2.getName();
				Type type = p.getType();
				String typeName = type.toString();
				Comment comment = p.getComment();
				methodParameterDVOList.add(new MethodParameterDVO(varName, typeName, "", comment == null ? "" : comment.toString()));
			}

			onMethodDVOVisite.accept(methodDVO);

			super.visit(n, arg);
		}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:24,代码来源:BaseInfoComposite.java

示例5: getParameterNames

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
private void getParameterNames(MethodDeclaration methodDeclaration, boolean isInterface) {
  final EnumSet<Modifier> modifiers = methodDeclaration.getModifiers();
  if (isInterface || modifiers.contains(Modifier.PUBLIC)) {
    String methodName = methodDeclaration.getName().getIdentifier();
    List<Parameter> parameters = methodDeclaration.getParameters();
    names.className = this.className;
    List<List<ParameterName>> parameterNames =
        names.names.computeIfAbsent(methodName, k -> new ArrayList<>(4));

    final List<ParameterName> temp = new ArrayList<>();
    for (final Parameter parameter : parameters) {
      ParameterName parameterName = new ParameterName();
      String type = parameter.getType().toString();
      String name = parameter.getName().getIdentifier();
      if (name.contains("[]")) {
        type = type + "[]";
        name = name.replace("[]", "");
      }
      parameterName.type = type;
      parameterName.name = name;
      temp.add(parameterName);
    }
    parameterNames.add(temp);
  }
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:26,代码来源:ParameterNameVisitor.java

示例6: mapParam

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
/**
 * @return a RunParameter instance representing the JavaParser {@link com.github.javaparser.ast.body.Parameter} p.
 */
private static RunParameter mapParam(final Parameter p) {
  switch (parameterToTypeNameAsString(p)) {
  case "boolean":
  case "byte":
  case "short":
  case "int":
  case "long":
  case "char":
  case "float":
  case "double":
    return RunParameterPrimitive.of(parameterToTypeNameAsString(p), parameterToVariableNameAsString(p));
  default:
    return RunParameterClass.of(parameterToPackageNameAsString(p), parameterToTypeNameAsString(p),
        parameterToVariableNameAsString(p));
  }
}
 
开发者ID:raffishquartan,项目名称:vpt,代码行数:20,代码来源:JavaparserSourceFile.java

示例7: isSignatureMatched

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
private boolean isSignatureMatched(MethodDeclaration targetMethod, MethodDeclaration sourceMethod) {
    final List<Parameter> targetParams = targetMethod.getParameters();
    final List<Parameter> sourceParams = sourceMethod.getParameters();
    if (targetParams.size() != sourceParams.size()) {
        return false;
    }

    final List<Type> targetParameterTypes = targetParams.stream()
            .map(Parameter::getType)
            .collect(toList());

    final List<Type> sourceParameterTypes = sourceParams.stream()
            .map(Parameter::getType)
            .collect(toList());

    return targetParameterTypes.equals(sourceParameterTypes);
}
 
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:18,代码来源:SpringWebValidatorMojo.java

示例8: diffNode

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
private void diffNode(final Node a, final Node aParent,
                      final Node b, final Node bParent,
                      final Consumer<Quintet<Node, Node, Node, Node, DiffStatus>> diffCallback) {
    if (b == null) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISSING));
    } else if (a instanceof NameExpr && !Objects.equals(((NameExpr) a).getName(), ((NameExpr) b).getName())) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof FieldAccessExpr && !Objects.equals(((FieldAccessExpr) a).getFieldExpr(), ((FieldAccessExpr) b).getFieldExpr())) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof LiteralExpr && !Objects.equals(a, b)) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof AnnotationExpr && !Objects.equals(((AnnotationExpr) a).getName().getName(), ((AnnotationExpr) b).getName().getName())) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof Parameter && !Objects.equals(((Parameter) a).getType(), ((Parameter) b).getType())) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof MethodDeclaration) {
        final Iterator<Parameter> iSourceParameters = ((MethodDeclaration) b).getParameters().iterator();
        for (Parameter parameter : ((MethodDeclaration) a).getParameters()) {
            diffNode(parameter, a, iSourceParameters.hasNext() ? iSourceParameters.next() : null, b, diffCallback);
        }
        introspect(a, b, diffCallback);
    } else {
        introspect(a, b, diffCallback);
    }
}
 
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:26,代码来源:SpringWebValidatorMojo.java

示例9: isIntrospectionRelevantNode

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
private boolean isIntrospectionRelevantNode(Node node) {
    if (node instanceof Type && node.getParentNode() instanceof MethodDeclaration) {
        return false;
    }

    if (node instanceof Parameter && node.getParentNode() instanceof MethodDeclaration) {
        return false;
    }

    if (!(node instanceof AnnotationExpr) && node.getParentNode() instanceof BaseParameter) {
        return false;
    }

    if (node instanceof NameExpr && node.getParentNode() instanceof AnnotationExpr) {
        return false;
    }

    if (node.getParentNode() instanceof FieldAccessExpr) {
        return false;
    }

    return true;
}
 
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:24,代码来源:SpringWebValidatorMojo.java

示例10: visit

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
@Override
public Node visit(MethodDeclaration _n, Object _arg) {
	JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
	List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
	List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg);
	Type type_ = cloneNodes(_n.getType(), _arg);
	List<Parameter> parameters = visit(_n.getParameters(), _arg);
	List<NameExpr> throws_ = visit(_n.getThrows(), _arg);
	BlockStmt block = cloneNodes(_n.getBody(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

	MethodDeclaration r = new MethodDeclaration(
			_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
			 _n.getModifiers(), annotations, typeParameters, type_, _n.getName(), parameters, _n.getArrayCount(), throws_, block
	);
	r.setComment(comment);
	return r;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:19,代码来源:CloneVisitor.java

示例11: getSignature

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
@Override
public String getSignature() {
	List<Parameter> params = null;
	if ((params = method.getParameters()) == null) {
		return "";
	}
	StringBuilder sb = new StringBuilder("");
	boolean first = true;
	for (Parameter param : params) {
		if (first) {
			first = false;
			sb.append(param.toString());
		}
		else {
			sb.append(", ").append(param.toString());
		}
	}
	return sb.toString();
}
 
开发者ID:umlet,项目名称:umlet,代码行数:20,代码来源:JpMethod.java

示例12: visit

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
@Override
public Node visit(ConstructorDeclaration _n, Object _arg) {
	JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
	List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
	List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg);
	List<Parameter> parameters = visit(_n.getParameters(), _arg);
	List<NameExpr> throws_ = visit(_n.getThrows(), _arg);
	BlockStmt block = cloneNodes(_n.getBlock(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

	ConstructorDeclaration r = new ConstructorDeclaration(
			_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
			 _n.getModifiers(), annotations, typeParameters, _n.getName(), parameters, throws_, block
	);
	r.setComment(comment);
	return r;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:18,代码来源:CloneVisitor.java

示例13: getCreateInputSocketsMethod

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
/**
 * Creates the method that returns the input socket of this operation.
 *
 * @return The method declaration.
 */
private MethodDeclaration getCreateInputSocketsMethod() {
  return new MethodDeclaration(
      ModifierSet.PUBLIC,
      Arrays.asList(OVERRIDE_ANNOTATION, SUPPRESS_ANNOTATION),
      null,
      SocketHintDeclarationCollection.getSocketReturnParam("InputSocket"),
      "createInputSockets",
      Collections.singletonList(
          new Parameter(createReferenceType("EventBus", 0), new VariableDeclaratorId("eventBus"))
      ),
      0,
      null,
      socketHintDeclarationCollection.getInputSocketBody()
  );
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:21,代码来源:Operation.java

示例14: getCreateOutputSocketsMethod

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
/**
 * Creates the method that returns the output sockets of this operation.
 *
 * @return The method declaration.
 */
private MethodDeclaration getCreateOutputSocketsMethod() {
  return new MethodDeclaration(
      ModifierSet.PUBLIC,
      Arrays.asList(OVERRIDE_ANNOTATION, SUPPRESS_ANNOTATION),
      null,
      SocketHintDeclarationCollection.getSocketReturnParam("OutputSocket"),
      "createOutputSockets",
      Collections.singletonList(
          new Parameter(createReferenceType("EventBus", 0), new VariableDeclaratorId("eventBus"))
      ),
      0,
      null,
      socketHintDeclarationCollection.getOutputSocketBody()
  );
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:21,代码来源:Operation.java

示例15: getPerformMethod

import com.github.javaparser.ast.body.Parameter; //导入依赖的package包/类
private MethodDeclaration getPerformMethod() {
  String inputParamId = "inputs";
  String outputParamId = "outputs";
  return new MethodDeclaration(
      ModifierSet.PUBLIC,
      Arrays.asList(OVERRIDE_ANNOTATION),
      null,
      new VoidType(),
      "perform",
      Arrays.asList(
          new Parameter(SocketHintDeclarationCollection.getSocketReturnParam("InputSocket"),
              new VariableDeclaratorId(inputParamId)),
          new Parameter(SocketHintDeclarationCollection.getSocketReturnParam("OutputSocket"),
              new VariableDeclaratorId(outputParamId))
      ),
      0,
      null,
      new BlockStmt(
          getPerformExpressionList(inputParamId, outputParamId)
      )
  );
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:23,代码来源:Operation.java


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