Interface NodeWithTypeArguments<N extends Node>

All Known Implementing Classes:
ClassOrInterfaceType, ExplicitConstructorInvocationStmt, FieldAccessExpr, MethodCallExpr, MethodReferenceExpr, ObjectCreationExpr

public interface NodeWithTypeArguments<N extends Node>
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 Details

    • getTypeArguments

      Optional<NodeList<Type>> getTypeArguments()
      Returns:
      the types that can be found in the type arguments: <String, Integer>.
    • setTypeArguments

      N setTypeArguments(NodeList<Type> typeArguments)
      Allows you to set the generic arguments
      Parameters:
      typeArguments - The list of types of the generics, can be null
    • isUsingDiamondOperator

      default boolean isUsingDiamondOperator()
      Returns:
      whether the type arguments look like <>.
    • setDiamondOperator

      default N setDiamondOperator()
      Sets the type arguments to <>.
    • removeTypeArguments

      default N removeTypeArguments()
      Removes all type arguments, including the surrounding <>.
    • setTypeArguments

      default N setTypeArguments(Type... typeArguments)