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,RecordDeclaration
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, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY -
Constructor Summary
ConstructorsConstructorDescriptionTypeDeclaration(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
Modifier and TypeMethodDescriptionaddMember(BodyDeclaration<?> decl)Adds the given declaration to the specified type.clone()Returns the fully qualified name of this type, derived only from information available in this compilation unit.Return the modifiers of this type declaration.getName()voidifTypeDeclaration(Consumer<TypeDeclaration> action)booleanbooleanbooleanbooleanbooleanabstract ResolvedReferenceTypeDeclarationresolve()setMembers(NodeList<BodyDeclaration<?>> members)setModifiers(NodeList<Modifier> modifiers)setName(SimpleName name)Methods inherited from class com.github.javaparser.ast.body.BodyDeclaration
asAnnotationDeclaration, asAnnotationMemberDeclaration, asCallableDeclaration, asClassOrInterfaceDeclaration, asCompactConstructorDeclaration, asConstructorDeclaration, asEnumConstantDeclaration, asEnumDeclaration, asFieldDeclaration, asInitializerDeclaration, asMethodDeclaration, asRecordDeclaration, getAnnotations, ifAnnotationDeclaration, ifAnnotationMemberDeclaration, ifCallableDeclaration, ifClassOrInterfaceDeclaration, ifCompactConstructorDeclaration, ifConstructorDeclaration, ifEnumConstantDeclaration, ifEnumDeclaration, ifFieldDeclaration, ifInitializerDeclaration, ifMethodDeclaration, ifRecordDeclaration, isAnnotationDeclaration, isAnnotationMemberDeclaration, isCallableDeclaration, isClassOrInterfaceDeclaration, isCompactConstructorDeclaration, isConstructorDeclaration, isEnumConstantDeclaration, isEnumDeclaration, isFieldDeclaration, isInitializerDeclaration, isMethodDeclaration, isRecordDeclaration, setAnnotations, toAnnotationDeclaration, toAnnotationMemberDeclaration, toCallableDeclaration, toClassOrInterfaceDeclaration, toCompactConstructorDeclaration, toConstructorDeclaration, toEnumConstantDeclaration, toEnumDeclaration, toFieldDeclaration, toInitializerDeclaration, toMethodDeclaration, toRecordDeclarationMethods inherited from class com.github.javaparser.ast.Node
addOrphanComment, containsData, createDefaultPrinter, createDefaultPrinter, customInitialization, equals, findAll, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getDataKeys, getDefaultPrinterConfiguration, getLineEndingStyle, getLineEndingStyleOrDefault, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getPrinter, getPrinter, getRange, getSymbolResolver, getTokenRange, hashCode, hasScope, isAncestorOf, isPhantom, 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, walkMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.github.javaparser.HasParentNode
findAncestor, findAncestor, hasParentNode, isDescendantOfMethods 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, tryAddImportToParentCompilationUnitMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithJavadoc
getComment, getJavadoc, getJavadocComment, hasJavaDocComment, removeJavaDocComment, setComment, setJavadocComment, setJavadocComment, setJavadocComment, setJavadocCommentMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithMembers
addConstructor, addField, addField, addField, addFieldWithInitializer, addFieldWithInitializer, addFieldWithInitializer, addInitializer, addMethod, addPrivateField, addPrivateField, addPrivateField, addProtectedField, addProtectedField, addProtectedField, addPublicField, addPublicField, addPublicField, addStaticInitializer, getConstructorByParameterTypes, getConstructorByParameterTypes, getConstructors, getDefaultConstructor, getFieldByName, getFields, getMember, getMethods, getMethodsByName, getMethodsByParameterTypes, getMethodsByParameterTypes, getMethodsBySignature, isEmpty, setMember, tryAddImportToParentCompilationUnitMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithModifiers
addModifier, getAccessSpecifier, hasModifier, removeModifier, setModifier, setModifiersMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPrivateModifier
isPrivate, setPrivateMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithProtectedModifier
isProtected, setProtectedMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithPublicModifier
isPublic, setPublicMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRangeMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithSimpleName
getNameAsExpression, getNameAsString, setNameMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStaticModifier
isStatic, setStaticMethods inherited from interface com.github.javaparser.ast.nodeTypes.modifiers.NodeWithStrictfpModifier
isStrictfp, setStrictfp
-
Constructor Details
-
TypeDeclaration
public TypeDeclaration() -
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 Details
-
addMember
Adds the given declaration to the specified type.- Specified by:
addMemberin interfaceNodeWithMembers<T extends TypeDeclaration<?>>- Parameters:
decl- member declaration
-
getMembers
- Specified by:
getMembersin interfaceNodeWithMembers<T extends TypeDeclaration<?>>- Returns:
- all members inside the braces of this node, like fields, methods, nested types, etc.
-
getModifiers
Return the modifiers of this type declaration.- Specified by:
getModifiersin interfaceNodeWithModifiers<T extends TypeDeclaration<?>>- Returns:
- modifiers
- See Also:
Modifier
-
setMembers
- Specified by:
setMembersin interfaceNodeWithMembers<T extends TypeDeclaration<?>>
-
setModifiers
- Specified by:
setModifiersin interfaceNodeWithModifiers<T extends TypeDeclaration<?>>
-
setName
- Specified by:
setNamein interfaceNodeWithSimpleName<T extends TypeDeclaration<?>>
-
getName
- Specified by:
getNamein interfaceNodeWithSimpleName<T extends TypeDeclaration<?>>
-
remove
- 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.
-
getFullyQualifiedName
Returns the fully qualified name of this type, derived only from information available in this compilation unit. (So no symbol solving happens.) If the declared type is a local class declaration, it will return Optional.empty(). If the declared type is a local record declaration, it will return Optional.empty(). If the declared type is not contained in a compilation unit, it will return Optional.empty(). -
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
- Overrides:
clonein classBodyDeclaration<T extends TypeDeclaration<?>>
-
getMetaModel
- Overrides:
getMetaModelin classBodyDeclaration<T extends TypeDeclaration<?>>- Returns:
- get JavaParser specific node introspection information.
-
replace
- Overrides:
replacein classBodyDeclaration<T extends TypeDeclaration<?>>
-
isTypeDeclaration
public boolean isTypeDeclaration()- Overrides:
isTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
asTypeDeclaration
- Overrides:
asTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
ifTypeDeclaration
- Overrides:
ifTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
toTypeDeclaration
- Overrides:
toTypeDeclarationin classBodyDeclaration<T extends TypeDeclaration<?>>
-
resolve
-