Package com.github.javaparser.ast.type
Class ArrayType
java.lang.Object
com.github.javaparser.ast.Node
com.github.javaparser.ast.type.Type
com.github.javaparser.ast.type.ReferenceType
com.github.javaparser.ast.type.ArrayType
- All Implemented Interfaces:
NodeWithAnnotations<ArrayType>,NodeWithRange<Node>,NodeWithTokenRange<Node>,Observable,Visitable,HasParentNode<Node>,Resolvable<ResolvedType>,Cloneable
To indicate that a type is an array, it gets wrapped in an ArrayType for every array level it has.
So, int[][] becomes ArrayType(ArrayType(int)).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHelper class that stores information about a pair of brackets in a non-recursive way (unlike ArrayType.)static classThe origin of a pair of array brackets [].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
ConstructorsConstructorDescriptionArrayType(Type type, AnnotationExpr... annotations)ArrayType(Type componentType, ArrayType.Origin origin, NodeList<AnnotationExpr> annotations)ArrayType(TokenRange tokenRange, Type componentType, ArrayType.Origin origin, NodeList<AnnotationExpr> annotations)This constructor is used by the parser and is considered private. -
Method Summary
Modifier and TypeMethodDescription<R, A> Raccept(GenericVisitor<R,A> v, A arg)Accept method for visitor support.<A> voidaccept(VoidVisitor<A> v, A arg)Accept method for visitor support.asString()clone()intreturns the array level that is 0 for non array type.Finds the element type, meaning: the type without ArrayTypes around it.voidifArrayType(Consumer<ArrayType> action)booleanbooleanresolve()setAnnotations(NodeList<AnnotationExpr> annotations)setComponentType(Type componentType)setOrigin(ArrayType.Origin origin)static Pair<Type,List<ArrayType.ArrayBracketPair>>unwrapArrayTypes(Type type)Takes a type that may be an ArrayType.static TypewrapInArrayTypes(Type type, List<ArrayType.ArrayBracketPair>... arrayBracketPairLists)Takes lists of arrayBracketPairs, assumes the lists are ordered outer to inner and the pairs are ordered left to right.Methods inherited from class com.github.javaparser.ast.type.ReferenceType
asReferenceType, ifReferenceType, isReferenceType, toReferenceTypeMethods inherited from class com.github.javaparser.ast.type.Type
asClassOrInterfaceType, asIntersectionType, asPrimitiveType, asTypeParameter, asUnionType, asUnknownType, asVarType, asVoidType, asWildcardType, getAnnotation, getAnnotations, ifClassOrInterfaceType, ifIntersectionType, ifPrimitiveType, ifTypeParameter, ifUnionType, ifUnknownType, ifVarType, ifVoidType, ifWildcardType, isClassOrInterfaceType, isIntersectionType, isPrimitiveType, isTypeParameter, isUnionType, isUnknownType, isVarType, isVoidType, isWildcardType, remove, toClassOrInterfaceType, toIntersectionType, toPrimitiveType, toTypeParameter, toUnionType, toUnknownType, toVarType, toVoidType, toWildcardTypeMethods 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, 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, getAnnotations, isAnnotationPresent, isAnnotationPresent, setAnnotation, tryAddImportToParentCompilationUnitMethods inherited from interface com.github.javaparser.ast.nodeTypes.NodeWithRange
containsWithin, containsWithinRange, getBegin, getEnd, hasRange
-
Constructor Details
-
ArrayType
public ArrayType(Type componentType, ArrayType.Origin origin, NodeList<AnnotationExpr> annotations) -
ArrayType
-
ArrayType
public ArrayType(TokenRange tokenRange, Type componentType, ArrayType.Origin origin, NodeList<AnnotationExpr> annotations)This constructor is used by the parser and is considered private.
-
-
Method Details
-
resolve
- Specified by:
resolvein interfaceResolvable<ResolvedType>- Specified by:
resolvein classType
-
accept
Description copied from interface:VisitableAccept method for visitor support.- Specified by:
acceptin interfaceVisitable- Type Parameters:
R- the type of the return value of the visitorA- the type the user argument passed to the visitor- Parameters:
v- the visitor implementationarg- the argument passed to the visitor (of type A)- Returns:
- the result of the visit (of type R)
-
accept
Description copied from interface:VisitableAccept method for visitor support. -
getComponentType
-
setComponentType
-
wrapInArrayTypes
@SafeVarargs public static Type wrapInArrayTypes(Type type, List<ArrayType.ArrayBracketPair>... arrayBracketPairLists)Takes lists of arrayBracketPairs, assumes the lists are ordered outer to inner and the pairs are ordered left to right. The type gets wrapped in ArrayTypes so that the outermost ArrayType corresponds to the leftmost ArrayBracketPair in the first list. -
unwrapArrayTypes
Takes a type that may be an ArrayType. Unwraps ArrayTypes until the element type is found.- Returns:
- a pair of the element type, and the unwrapped ArrayTypes, if any.
-
setAnnotations
- Specified by:
setAnnotationsin interfaceNodeWithAnnotations<ArrayType>- Overrides:
setAnnotationsin classType
-
getOrigin
-
setOrigin
-
asString
-
toDescriptor
- Specified by:
toDescriptorin classReferenceType
-
clone
- Overrides:
clonein classReferenceType
-
getMetaModel
- Overrides:
getMetaModelin classReferenceType- Returns:
- get JavaParser specific node introspection information.
-
replace
-
isArrayType
public boolean isArrayType()- Overrides:
isArrayTypein classType
-
asArrayType
- Overrides:
asArrayTypein classType
-
ifArrayType
- Overrides:
ifArrayTypein classType
-
toArrayType
- Overrides:
toArrayTypein classType
-
getElementType
Finds the element type, meaning: the type without ArrayTypes around it.In "
int[] a[];", the element type is int.- Overrides:
getElementTypein classType
-
getArrayLevel
public int getArrayLevel()returns the array level that is 0 for non array type.- Overrides:
getArrayLevelin classType
-