Top Methods
com.github.javaparser.ast.nodeTypes

public Interface NodeWithParameters<N extends Node>

Known Direct Implementers
com.github.javaparser.ast.body.CallableDeclaration, com.github.javaparser.ast.body.ConstructorDeclaration, com.github.javaparser.ast.body.MethodDeclaration, com.github.javaparser.ast.expr.LambdaExpr
Imports
com.github.javaparser.ast.Node, .NodeList, com.github.javaparser.ast.body.Parameter, com.github.javaparser.ast.type.Type, java.util.Arrays, .Optional, java.util.stream.Stream

Method Summary

Modifier and TypeMethod and Description
public default Parameter
public default Parameter
addAndGetParameter(Class<?> paramClass, String name)

public default Parameter

Returns:

the Parameter created
addAndGetParameter
(String
the name of the class, ex : org.test.Foo or Foo if you added manually the import
className
,
String
the name of the parameter
name
)

Remember to import the class in the compilation unit yourself

public default Parameter
public default N
addParameter(Type type, String name)

public default N
addParameter(Class<?> paramClass, String name)

public default N
addParameter(String
the name of the class, ex : org.test.Foo or Foo if you added manually the import
className
,
String
the name of the parameter
name
)

Remember to import the class in the compilation unit yourself

public default N
public default Parameter
getParameter(int i)

public default Optional<Parameter>

Returns:

null if not found, the param found otherwise
getParameterByName
(String
the name of the param
name
)

Try to find a Parameter by its name

public default Optional<Parameter>

Returns:

null if not found, the param found otherwise
getParameterByType
(String
the type of the param
type
)

Try to find a Parameter by its type

public default Optional<Parameter>

Returns:

null if not found, the param found otherwise
getParameterByType
(Class<?>
the type of the param take care about generics, it wont work
type
)

Try to find a Parameter by its type

public NodeList<Parameter>
public default boolean

Returns:

true if all parameters match one by one, in the given order.
hasParametersOfType
(String...
the types of parameters like "Map<Integer,String>", "int" to match void foo(Map<Integer,String> myMap, int number).
paramTypes
)

Check if the parameters have certain types.

public default boolean

Returns:

true if all parameters match one by one, in the given order.
hasParametersOfType
(Class<?>...
the types of parameters like Map.class, int.class to match void foo(Map<Integer,String> myMap, int number).
paramTypes
)

Check if the parameters have certain types.

public default N
setParameter(int i, Parameter parameter)

public N
public void

Method Detail

addAndGetParameterback to summary
public default Parameter addAndGetParameter(Type type, String name)
addAndGetParameterback to summary
public default Parameter addAndGetParameter(Class<?> paramClass, String name)
addAndGetParameterback to summary
public default Parameter addAndGetParameter(String className, String name)

Remember to import the class in the compilation unit yourself

Parameters
className:String

the name of the class, ex : org.test.Foo or Foo if you added manually the import

name:String

the name of the parameter

Returns:Parameter

the Parameter created

addAndGetParameterback to summary
public default Parameter addAndGetParameter(Parameter parameter)
addParameterback to summary
public default N addParameter(Type type, String name)
addParameterback to summary
public default N addParameter(Class<?> paramClass, String name)
addParameterback to summary
public default N addParameter(String className, String name)

Remember to import the class in the compilation unit yourself

Parameters
className:String

the name of the class, ex : org.test.Foo or Foo if you added manually the import

name:String

the name of the parameter

addParameterback to summary
public default N addParameter(Parameter parameter)
Annotations
@SuppressWarnings:unchecked
getParameterback to summary
public default Parameter getParameter(int i)
getParameterByNameback to summary
public default Optional<Parameter> getParameterByName(String name)

Try to find a Parameter by its name

Parameters
name:String

the name of the param

Returns:Optional<Parameter>

null if not found, the param found otherwise

getParameterByTypeback to summary
public default Optional<Parameter> getParameterByType(String type)

Try to find a Parameter by its type

Parameters
type:String

the type of the param

Returns:Optional<Parameter>

null if not found, the param found otherwise

getParameterByTypeback to summary
public default Optional<Parameter> getParameterByType(Class<?> type)

Try to find a Parameter by its type

Parameters
type:Class<?>

the type of the param take care about generics, it wont work

Returns:Optional<Parameter>

null if not found, the param found otherwise

getParametersback to summary
public NodeList<Parameter> getParameters()
hasParametersOfTypeback to summary
public default boolean hasParametersOfType(String... paramTypes)

Check if the parameters have certain types. The given parameter types must literally match the declared types of this node's parameters, so passing the string "List" to this method will be considered a match if this node has exactly one parameter whose type is declared as List, but not if the parameter type is declared as java.util.List or java.awt.List. Conversely, passing the string "java.util.List" to this method will be considered a match if this node has exactly one parameter whose type is declared as java.util.List, but not if the parameter type is declared as List. Similarly, note that generics are matched as well: If this node has one parameter declared as List<String>, then it will be considered as a match only if the given string is "List<String>", but not if the given string is only "List".

Parameters
paramTypes:String[]

the types of parameters like "Map<Integer,String>", "int" to match void foo(Map<Integer,String> myMap, int number).

Returns:boolean

true if all parameters match one by one, in the given order.

hasParametersOfTypeback to summary
public default boolean hasParametersOfType(Class<?>... paramTypes)

Check if the parameters have certain types. Note that this is a match in SimpleName, so java.awt.List and java.util.List are identical to this algorithm. In addition, note that it is the erasure of each type which is considered, so passing List.class to this method will be considered a match if this node has exactly one parameter whose type is named List, regardless of whether the parameter type is declared without generics as List, or with generics as List<String>, or List<Integer>, etc.

Parameters
paramTypes:Class<?>[]

the types of parameters like Map.class, int.class to match void foo(Map<Integer,String> myMap, int number).

Returns:boolean

true if all parameters match one by one, in the given order.

setParameterback to summary
public default N setParameter(int i, Parameter parameter)
Annotations
@SuppressWarnings:unchecked
setParametersback to summary
public N setParameters(NodeList<Parameter> parameters)
tryAddImportToParentCompilationUnitback to summary
public void tryAddImportToParentCompilationUnit(Class<?> clazz)