Package org.openrewrite.java.trait
Class Literal
java.lang.Object
org.openrewrite.java.trait.Literal
- All Implemented Interfaces:
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.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openrewrite.trait.Trait
getCursor, getTree
-
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
- Returns:
- the value of this expression as String if possible, or null if it is an array literal or otherwise unavailable.
-
getStrings
- Returns:
- the value of this expression as a list of strings. Works for both single string literals and array literals.
-
getValue
-
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)
-