Class ArcheTextValue

java.lang.Object
com.blackrook.archetext.ArcheTextValue

public final class ArcheTextValue extends Object
The values stored in an ArcheTextObject.
Author:
Matthew Tropiano
  • Field Details

  • Method Details

    • create

      public static <T> ArcheTextValue create(T object)
      Creates a new value. Converts primitives and boxed primitives, strings, arrays, and Sets, and Maps, and objects.
      Type Parameters:
      T - the object's type.
      Parameters:
      object - the input object.
      Returns:
      an ArcheTextValue to use in ArcheTextObject.
    • createForType

      public <T> T createForType(String memberName, Class<T> type)
      Converts this value to another Java object type.
      Type Parameters:
      T - the return type.
      Parameters:
      memberName - the name of this value, if a member of another object.
      type - the type to convert to.
      Returns:
      the converted type.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(ArcheTextValue other)
      Equality test.
      Parameters:
      other - the other value.
      Returns:
      true if equal, false if not.
    • copy

      public ArcheTextValue copy()
      Returns:
      a deep copy of this value.
    • getType

      public ArcheTextValue.Type getType()
      Returns:
      the value type.
    • getValue

      public Object getValue()
      Returns:
      the value itself.
    • isNull

      public boolean isNull()
      Returns if this object is null-valued.
      Returns:
      true if so, false if not.
    • combineWith

      public ArcheTextValue combineWith(Combinator combinator, ArcheTextValue source)
      Combines this value with another and returns the result.
      Parameters:
      combinator - the combinator to use.
      source - the source value to combine this with. Can be null for NULL.
      Returns:
      the new value.
    • promoteTo

      public ArcheTextValue promoteTo(ArcheTextValue.Type promotionType)
      Returns a new ArcheTextValue that is a promoted type from this one. No types can be promoted to ArcheTextValue.Type.OBJECT. If the same type is passed in, this object is returned.
      Parameters:
      promotionType - the type to promote to.
      Returns:
      the new, promoted value.
      Throws:
      ArcheTextOperationException - if the type is less than this one or not promotable.
    • negate

      public ArcheTextValue negate()
      Negates the value of this value, returning a new one. Only works for integers, floats, and strings (strings are set to lower case).
      Returns:
      a new value.
      Throws:
      ArcheTextOperationException - if the current type is not a correct type.
    • not

      public ArcheTextValue not()
      Returns the logical "not" value of this value, returning a new one. Only works for booleans.
      Returns:
      a new value.
      Throws:
      ArcheTextOperationException - if the current type is not a correct type.
    • bitwiseNot

      public ArcheTextValue bitwiseNot()
      Returns the bitwise "not" value of this value, returning a new one. Only works for booleans, integers, and floats.
      Returns:
      a new value.
      Throws:
      ArcheTextOperationException - if the current type is not a correct type.
    • absolute

      public ArcheTextValue absolute()
      Returns the absolute value of this value, returning a new one. Only works for integers, floats, and strings (strings are set to upper case).
      Returns:
      a new value.
      Throws:
      ArcheTextOperationException - if the current type is not a correct type.
    • toString

      public String toString()
      Overrides:
      toString in class Object