Class JavaLiteral<T>

Type Parameters:
T - type of JavaConstant.getValue().
All Implemented Interfaces:
io.github.mmm.code.api.expression.CodeConstant, io.github.mmm.code.api.expression.CodeExpression, io.github.mmm.code.api.expression.CodeLiteral, io.github.mmm.code.api.item.CodeItem, JavaExpression
Direct Known Subclasses:
JavaLiteralBoolean, JavaLiteralByte, JavaLiteralChar, JavaLiteralClass, JavaLiteralDouble, JavaLiteralEnum, JavaLiteralFloat, JavaLiteralInt, JavaLiteralLong, JavaLiteralNull, JavaLiteralShort, JavaLiteralString

public abstract class JavaLiteral<T> extends JavaConstant<T> implements io.github.mmm.code.api.expression.CodeLiteral
Implementation of CodeLiteral for Java.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Constructor Details

    • JavaLiteral

      protected JavaLiteral(T value)
      The constructor.
      Parameters:
      value - the value.
  • Method Details

    • evaluate

      public JavaLiteral<T> evaluate()
      Specified by:
      evaluate in interface io.github.mmm.code.api.expression.CodeConstant
      Specified by:
      evaluate in interface io.github.mmm.code.api.expression.CodeExpression
      Specified by:
      evaluate in interface JavaExpression
      Overrides:
      evaluate in class JavaConstant<T>
    • isPrimitive

      public boolean isPrimitive()
      Overrides:
      isPrimitive in class JavaConstant<T>
      Returns:
      true if the type is primitive.
    • withValue

      public abstract JavaLiteral<T> withValue(T newValue)
      Specified by:
      withValue in class JavaConstant<T>
      Parameters:
      newValue - the new value. May not be null.
      Returns:
      the corresponding JavaConstant of the same type with the given value.
    • of

      public static JavaLiteral<?> of(Object value)
      Parameters:
      value - the literal value.
      Returns:
      the JavaLiteral for the given value. May be null if the type of the given value is not supported.