Interface NodeWithConstructors<N extends Node>
-
- All Superinterfaces:
NodeWithMembers<N>
,NodeWithSimpleName<N>
- All Known Implementing Classes:
ClassOrInterfaceDeclaration
,EnumDeclaration
public interface NodeWithConstructors<N extends Node> extends NodeWithSimpleName<N>, NodeWithMembers<N>
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default ConstructorDeclaration
addConstructor(Modifier.Keyword... modifiers)
Adds a constructor to thisdefault Optional<ConstructorDeclaration>
getConstructorByParameterTypes(Class<?>... paramTypes)
Try to find aConstructorDeclaration
by its parameters typesdefault Optional<ConstructorDeclaration>
getConstructorByParameterTypes(String... paramTypes)
Try to find aConstructorDeclaration
by its parameters typesdefault List<ConstructorDeclaration>
getConstructors()
Find all constructors for this class.default Optional<ConstructorDeclaration>
getDefaultConstructor()
Try to find aConstructorDeclaration
with no parameters by its name-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithMembers
addField, addField, addField, addFieldWithInitializer, addFieldWithInitializer, addFieldWithInitializer, addInitializer, addMember, addMethod, addPrivateField, addPrivateField, addPrivateField, addProtectedField, addProtectedField, addProtectedField, addPublicField, addPublicField, addPublicField, addStaticInitializer, getFieldByName, getFields, getMember, getMembers, getMethods, getMethodsByName, getMethodsByParameterTypes, getMethodsByParameterTypes, getMethodsBySignature, setMember, setMembers, tryAddImportToParentCompilationUnit
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getName, getNameAsExpression, getNameAsString, setName, setName
-
-
-
-
Method Detail
-
getDefaultConstructor
default Optional<ConstructorDeclaration> getDefaultConstructor()
Try to find aConstructorDeclaration
with no parameters by its name- Returns:
- the constructors found (multiple in case of polymorphism)
-
addConstructor
default ConstructorDeclaration addConstructor(Modifier.Keyword... modifiers)
Adds a constructor to this- Parameters:
modifiers
- the modifiers likeModifier.Keyword.PUBLIC
- Returns:
- the created constructor
-
getConstructors
default List<ConstructorDeclaration> getConstructors()
Find all constructors for this class.- Returns:
- the constructors found. This list is immutable.
-
getConstructorByParameterTypes
default Optional<ConstructorDeclaration> getConstructorByParameterTypes(String... paramTypes)
Try to find aConstructorDeclaration
by its parameters types- Parameters:
paramTypes
- the types of parameters like "Map<Integer,String>","int" to match
void foo(Map<Integer,String> myMap,int number)- Returns:
- the constructor found (multiple in case of overloading)
-
getConstructorByParameterTypes
default Optional<ConstructorDeclaration> getConstructorByParameterTypes(Class<?>... paramTypes)
Try to find aConstructorDeclaration
by its parameters types- Parameters:
paramTypes
- the types of parameters like "Map<Integer,String>","int" to match
void foo(Map<Integer,String> myMap,int number)- Returns:
- the constructors found (multiple in case of overloading)
-
-