Top Description Methods
com.github.javaparser.ast.nodeTypes

public Interface NodeWithTypeArguments<N extends Node>

Known Direct Implementers
com.github.javaparser.ast.stmt.ExplicitConstructorInvocationStmt, com.github.javaparser.ast.type.ClassOrInterfaceType, com.github.javaparser.ast.expr.MethodCallExpr, com.github.javaparser.ast.expr.FieldAccessExpr, com.github.javaparser.ast.expr.MethodReferenceExpr, com.github.javaparser.ast.expr.ObjectCreationExpr
Imports
com.github.javaparser.ast.Node, .NodeList, com.github.javaparser.ast.type.Type, com.github.javaparser.metamodel.DerivedProperty, java.util.Optional

A node that can have type arguments.

    new X();        --> typeArguments == Optional is empty
    new X<>();      --> typeArguments = [], diamondOperator = true
    new X<C,D>();   --> typeArguments = [C,D], diamondOperator = false
Only ObjectCreationExpr uses the diamond operator. On other nodes it is treated the same as the first case.

Method Summary

Modifier and TypeMethod and Description
public Optional<NodeList<Type>>

Returns:

the types that can be found in the type arguments: <String, Integer>.
getTypeArguments
()

public default boolean

Returns:

whether the type arguments look like <>.
isUsingDiamondOperator
()

public default N
removeTypeArguments()

Removes all type arguments, including the surrounding <>.

public default N
setDiamondOperator()

Sets the type arguments to <>.

public N
setTypeArguments(NodeList<Type>
The list of types of the generics, can be null
typeArguments
)

Allows you to set the generic arguments

public default N
setTypeArguments(Type... typeArguments)

Method Detail

getTypeArgumentsback to summary
public Optional<NodeList<Type>> getTypeArguments()
Returns:Optional<NodeList<Type>>

the types that can be found in the type arguments: <String, Integer>.

isUsingDiamondOperatorback to summary
public default boolean isUsingDiamondOperator()
Returns:boolean

whether the type arguments look like <>.

Annotations
@DerivedProperty
removeTypeArgumentsback to summary
public default N removeTypeArguments()

Removes all type arguments, including the surrounding <>.

Annotations
@SuppressWarnings:unchecked
setDiamondOperatorback to summary
public default N setDiamondOperator()

Sets the type arguments to <>.

Annotations
@SuppressWarnings:unchecked
setTypeArgumentsback to summary
public N setTypeArguments(NodeList<Type> typeArguments)

Allows you to set the generic arguments

Parameters
typeArguments:NodeList<Type>

The list of types of the generics, can be null

setTypeArgumentsback to summary
public default N setTypeArguments(Type... typeArguments)
Annotations
@SuppressWarnings:unchecked