public interface NodeWithParameters<N extends Node>
Modifier and Type | Method and Description |
---|---|
default Parameter |
addAndGetParameter(Class<?> paramClass,
String name) |
default Parameter |
addAndGetParameter(Parameter parameter) |
default Parameter |
addAndGetParameter(String className,
String name)
Remember to import the class in the compilation unit yourself
|
default Parameter |
addAndGetParameter(Type type,
String name) |
default N |
addParameter(Class<?> paramClass,
String name) |
default N |
addParameter(Parameter parameter) |
default N |
addParameter(String className,
String name)
Remember to import the class in the compilation unit yourself
|
default N |
addParameter(Type type,
String name) |
default Parameter |
getParameter(int i) |
default Optional<Parameter> |
getParameterByName(String name)
Try to find a
Parameter by its name |
default Optional<Parameter> |
getParameterByType(Class<?> type)
Try to find a
Parameter by its type |
default Optional<Parameter> |
getParameterByType(String type)
Try to find a
Parameter by its type |
NodeList<Parameter> |
getParameters() |
default boolean |
hasParametersOfType(Class<?>... paramTypes)
Check if the parameters have certain types.
|
default boolean |
hasParametersOfType(String... paramTypes)
Check if the parameters have certain types.
|
default N |
setParameter(int i,
Parameter parameter) |
N |
setParameters(NodeList<Parameter> parameters) |
void |
tryAddImportToParentCompilationUnit(Class<?> clazz) |
default Parameter getParameter(int i)
void tryAddImportToParentCompilationUnit(Class<?> clazz)
default N addParameter(String className, String name)
className
- the name of the class, ex : org.test.Foo or Foo if you added manually the importname
- the name of the parameterdefault Parameter addAndGetParameter(String className, String name)
className
- the name of the class, ex : org.test.Foo or Foo if you added manually the importname
- the name of the parameterParameter
createddefault Optional<Parameter> getParameterByName(String name)
Parameter
by its namename
- the name of the paramdefault Optional<Parameter> getParameterByType(String type)
Parameter
by its typetype
- the type of the paramdefault Optional<Parameter> getParameterByType(Class<?> type)
Parameter
by its typetype
- the type of the param take care about generics, it wont workdefault boolean hasParametersOfType(String... paramTypes)
"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"
.paramTypes
- the types of parameters like "Map<Integer,String>", "int"
to match
void foo(Map<Integer,String> myMap, int number)
.true
if all parameters match one by one, in the given order.default boolean hasParametersOfType(Class<?>... paramTypes)
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.paramTypes
- the types of parameters like Map.class, int.class
to match
void foo(Map<Integer,String> myMap, int number)
.true
if all parameters match one by one, in the given order.Copyright © 2007–2024. All rights reserved.