Class Literal

java.lang.Object
org.openrewrite.java.trait.Literal
All Implemented Interfaces:
org.openrewrite.trait.Trait<Expression>

public class Literal extends Object implements org.openrewrite.trait.Trait<Expression>
A literal in Java is either a J.Literal or a J.NewArray that has a non-null initializer that, itself, contains literals or new arrays that recursively contain these constraints. In other languages this trait is inclusive of constructs like list or map literals.
  • Constructor Details

    • Literal

      public Literal()
  • Method Details

    • isNull

      public boolean isNull()
    • isNotNull

      public boolean isNotNull()
    • isArray

      public boolean isArray()
      Returns:
      true if the value represented by this literal is an array.
    • getString

      public @Nullable String getString()
      Returns:
      the value of this expression as String if possible, or null if it is an array literal or otherwise unavailable.
    • getStrings

      public List<String> getStrings()
      Returns:
      the value of this expression as a list of strings. Works for both single string literals and array literals.
    • getValue

      public <T> @Nullable T getValue(Class<T> type)
    • getValue

      public <T> @Nullable T getValue(com.fasterxml.jackson.core.type.TypeReference<T> type)
    • getValue

      public <T> @Nullable T getValue(com.fasterxml.jackson.databind.JavaType type)