Class MCValueObject

java.lang.Object
de.monticore.values.MCValueObject
All Implemented Interfaces:
MCValue

public class MCValueObject extends Object implements MCValue
A value that is a Java Object.

Note: we deliberately do not interpret Objects based on Symbols alone; We assume that all (Object-)Types are already available as Java classes, as the use-cases for runtime-definition of types are rather rare.

  • Field Details

    • value

      protected Object value
  • Constructor Details

    • MCValueObject

      public MCValueObject(Object value)
  • Method Details

    • isObject

      public boolean isObject()
      Specified by:
      isObject in interface MCValue
    • asObject

      public MCValueObject asObject()
      Description copied from interface: MCValue
      Specified by:
      asObject in interface MCValue
      Returns:
      The value as an MCValueObject, iff it is one.
    • asNativeObject

      public <T> T asNativeObject(Class<T> clazz)
    • unsafeCast

      public <T> T unsafeCast()
    • asNativeObject

      public Object asNativeObject()
      Description copied from interface: MCValue
      Used to pass the value to native Java classes and similar, e.g., collections.

      Note: not all values can have a native representation, as such, their native version is the MIValue itself.

      Specified by:
      asNativeObject in interface MCValue
      Returns:
      The value as a Java native Object.
    • asString

      public String asString()
      Specified by:
      asString in interface MCValue
    • isBoolean

      public boolean isBoolean()
      Specified by:
      isBoolean in interface MCValue
    • asBoolean

      public boolean asBoolean()
      Specified by:
      asBoolean in interface MCValue
    • isByte

      public boolean isByte()
      Specified by:
      isByte in interface MCValue
    • asByte

      public byte asByte()
      Specified by:
      asByte in interface MCValue
    • isChar

      public boolean isChar()
      Specified by:
      isChar in interface MCValue
    • asChar

      public char asChar()
      Specified by:
      asChar in interface MCValue
    • isShort

      public boolean isShort()
      Specified by:
      isShort in interface MCValue
    • asShort

      public short asShort()
      Specified by:
      asShort in interface MCValue
    • isInt

      public boolean isInt()
      Specified by:
      isInt in interface MCValue
    • asInt

      public int asInt()
      Specified by:
      asInt in interface MCValue
    • isLong

      public boolean isLong()
      Specified by:
      isLong in interface MCValue
    • asLong

      public long asLong()
      Specified by:
      asLong in interface MCValue
    • isFloat

      public boolean isFloat()
      Specified by:
      isFloat in interface MCValue
    • asFloat

      public float asFloat()
      Specified by:
      asFloat in interface MCValue
    • isDouble

      public boolean isDouble()
      Specified by:
      isDouble in interface MCValue
    • asDouble

      public double asDouble()
      Specified by:
      asDouble in interface MCValue
    • isString

      public boolean isString()
      Description copied from interface: MCValue
      helper for String specifically
      Specified by:
      isString in interface MCValue
    • isArray

      public boolean isArray()
    • arrayToObjectList

      public List<Object> arrayToObjectList()
      Converts the array value to a list of Object. S.a. isArray()
      Returns:
      the list of objects.
    • checkEqualityOperator

      public boolean checkEqualityOperator(MCValue other)
      Description copied from interface: MCValue
      basically implements ==
      Specified by:
      checkEqualityOperator in interface MCValue
      Parameters:
      other - the value to check against this
      Returns:
      whether they are considered equal
    • printType

      public String printType()
      Description copied from interface: MCValue
      Print the type of the MIValue in human-readable form
      Specified by:
      printType in interface MCValue
    • printValue

      public String printValue()
      Description copied from interface: MCValue
      Print the value in human-readable form
      Specified by:
      printValue in interface MCValue
    • createIllegalConversionException

      protected IllegalStateException createIllegalConversionException(String type)