Package com.github.javaparser.ast.body
Class TypeDeclaration<T extends TypeDeclaration<?>>
- java.lang.Object
-
- com.github.javaparser.ast.Node
-
- com.github.javaparser.ast.body.BodyDeclaration<T>
-
- com.github.javaparser.ast.body.TypeDeclaration<T>
-
- All Implemented Interfaces:
NodeWithAccessModifiers<T>,NodeWithPrivateModifier<T>,NodeWithProtectedModifier<T>,NodeWithPublicModifier<T>,NodeWithStaticModifier<T>,NodeWithStrictfpModifier<T>,NodeWithAnnotations<T>,NodeWithJavadoc<T>,NodeWithMembers<T>,NodeWithModifiers<T>,NodeWithRange<Node>,NodeWithSimpleName<T>,NodeWithTokenRange<Node>,Observable,Visitable,HasParentNode<Node>,Cloneable
- Direct Known Subclasses:
AnnotationDeclaration,ClassOrInterfaceDeclaration,EnumDeclaration
public abstract class TypeDeclaration<T extends TypeDeclaration<?>> extends BodyDeclaration<T> implements NodeWithSimpleName<T>, NodeWithJavadoc<T>, NodeWithMembers<T>, NodeWithAccessModifiers<T>, NodeWithStaticModifier<T>, NodeWithStrictfpModifier<T>
A base class for all types of type declarations.- Author:
- Julio Vilmar Gesser
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.github.javaparser.ast.Node
Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversal
-
-
Field Summary
-
Fields inherited from class com.github.javaparser.ast.Node
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration, SYMBOL_RESOLVER_KEY
-
-
Constructor Summary
Constructors Constructor Description TypeDeclaration()TypeDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)TypeDeclaration(NodeList<Modifier> modifiers, String name)TypeDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)This constructor is used by the parser and is considered private.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TaddMember(BodyDeclaration<?> decl)Adds the given declaration to the specified type.TypeDeclarationasTypeDeclaration()TypeDeclaration<?>clone()List<CallableDeclaration<?>>getCallablesWithSignature(CallableDeclaration.Signature signature)NodeList<BodyDeclaration<?>>getMembers()TypeDeclarationMetaModelgetMetaModel()NodeList<Modifier>getModifiers()Return the modifiers of this type declaration.SimpleNamegetName()voidifTypeDeclaration(Consumer<TypeDeclaration> action)booleanisNestedType()booleanisTopLevelType()booleanisTypeDeclaration()booleanremove(Node node)booleanreplace(Node node, Node replacementNode)abstract ResolvedReferenceTypeDeclarationresolve()TsetMembers(NodeList<BodyDeclaration<?>> members)TsetModifiers(NodeList<Modifier> modifiers)TsetName(SimpleName name)Optional<TypeDeclaration>toTypeDeclaration()-
Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
asAnnotationDeclaration, asAnnotationMemberDeclaration, asCallableDeclaration, asClassOrInterfaceDeclaration, asConstructorDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asMethodDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifCallableDeclaration, ifClassOrInterfaceDeclaration, ifConstructorDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifMethodDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isCallableDeclaration, isClassOrInterfaceDeclaration, isConstructorDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isMethodDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toCallableDeclaration, toClassOrInterfaceDeclaration, toConstructorDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toMethodDeclaration
-
Methods inherited from class com.github.javaparser.ast.Node
addOrphanComment, containsData, customInitialization, equals, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getSymbolResolver, getTokenRange, hasComment, hashCode, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walk
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.javaparser.HasParentNode
findAncestor, findAncestor, findParent, getAncestorOfType
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithAnnotations
addAndGetAnnotation, addAndGetAnnotation, addAnnotation, addAnnotation, addAnnotation, addMarkerAnnotation, addMarkerAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, addSingleMemberAnnotation, getAnnotation, getAnnotationByClass, getAnnotationByName, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnit
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocComment
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithMembers
addField, addField, addField, addFieldWithInitializer, addFieldWithInitializer, addFieldWithInitializer, addInitializer, addMethod, addPrivateField, addPrivateField, addPrivateField, addProtectedField, addProtectedField, addProtectedField, addPublicField, addPublicField, addPublicField, addStaticInitializer, getFieldByName, getFields, getMember, getMethods, getMethodsByName, getMethodsByParameterTypes, getMethodsByParameterTypes, getMethodsBySignature, setMember, tryAddImportToParentCompilationUnit
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, getAccessSpecifier, hasModifier, removeModifier, setModifier, setModifiers
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier
isPrivate, setPrivate
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier
isProtected, setProtected
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier
isPublic, setPublic
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, getBegin, getEnd, isPositionedAfter, isPositionedBefore
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getNameAsExpression, getNameAsString, setName
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier
isStatic, setStatic
-
Methods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStrictfpModifier
isStrictfp, setStrictfp
-
-
-
-
Constructor Detail
-
TypeDeclaration
public TypeDeclaration()
-
TypeDeclaration
public TypeDeclaration(NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)
-
TypeDeclaration
public TypeDeclaration(TokenRange tokenRange, NodeList<Modifier> modifiers, NodeList<AnnotationExpr> annotations, SimpleName name, NodeList<BodyDeclaration<?>> members)
This constructor is used by the parser and is considered private.
-
-
Method Detail
-
addMember
public T addMember(BodyDeclaration<?> decl)
Adds the given declaration to the specified type.- Specified by:
addMemberin interfaceNodeWithMembers<T extends TypeDeclaration<?>>- Parameters:
decl- member declaration
-
getMembers
public NodeList<BodyDeclaration<?>> getMembers()
- Specified by:
getMembersin interfaceNodeWithMembers<T extends TypeDeclaration<?>>- Returns:
- all members inside the braces of this node, like fields, methods, nested types, etc.
-
getModifiers
public NodeList<Modifier> getModifiers()
Return the modifiers of this type declaration.- Specified by:
getModifiersin interfaceNodeWithModifiers<T extends TypeDeclaration<?>>- Returns:
- modifiers
- See Also:
Modifier
-
setMembers
public T setMembers(NodeList<BodyDeclaration<?>> members)
- Specified by:
setMembersin interfaceNodeWithMembers<T extends TypeDeclaration<?>>
-
setModifiers
public T setModifiers(NodeList<Modifier> modifiers)
- Specified by:
setModifiersin interfaceNodeWithModifiers<T extends TypeDeclaration<?>>
-
setName
public T setName(SimpleName name)
- Specified by:
setNamein interfaceNodeWithSimpleName<T extends TypeDeclaration<?>>
-
getName
public SimpleName getName()
- Specified by:
getNamein interfaceNodeWithSimpleName<T extends TypeDeclaration<?>>
-
remove
public boolean remove(Node node)
- Overrides:
removein classBodyDeclaration<T extends TypeDeclaration<?>>
-
isTopLevelType
public boolean isTopLevelType()
- Returns:
- is this type's parent a CompilationUnit?
-
getCallablesWithSignature
public List<CallableDeclaration<?>> getCallablesWithSignature(CallableDeclaration.Signature signature)
- Returns:
- methods or constructors whose signatures match the passed signature.
-
isNestedType
public boolean isNestedType()
- Returns:
- is this type's parent a TypeDeclaration? NOTE: many people are confused over terminology. Refer to https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html .
-
clone
public TypeDeclaration<?> clone()
- Overrides:
clonein classBodyDeclaration<T extends TypeDeclaration<?>>
-
getMetaModel
public TypeDeclarationMetaModel getMetaModel()
- Overrides:
getMetaModelin classBodyDeclaration<T extends TypeDeclaration<?>>- Returns:
- get JavaParser specific node introspection information.
-
replace
public boolean replace(Node node, Node replacementNode)
- Overrides:
replacein classBodyDeclaration<T extends TypeDeclaration<?>>
-
isTypeDeclaration
public boolean isTypeDeclaration()
- Overrides:
isTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
asTypeDeclaration
public TypeDeclaration asTypeDeclaration()
- Overrides:
asTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
ifTypeDeclaration
public void ifTypeDeclaration(Consumer<TypeDeclaration> action)
- Overrides:
ifTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
toTypeDeclaration
public Optional<TypeDeclaration> toTypeDeclaration()
- Overrides:
toTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
resolve
public abstract ResolvedReferenceTypeDeclaration resolve()
-
-