Class Item

    • Method Detail

      • isDefined

        public abstract boolean isDefined()
        Returns true if this Item is not Absent.
      • isDistinct

        public abstract boolean isDistinct()
        Returns true if this Item is neither Extant nor Absent.
      • isDefinite

        public abstract boolean isDefinite()
        Returns true if this Item is not one of: an empty Record, False, Extant, or Absent.
      • isConstant

        public abstract boolean isConstant()
        Returns true if this Item always evaluates to the same Item.
      • key

        public abstract Value key()
        Returns the key component of this Item, if this Item is a Field; otherwise returns Absent if this Item is a Value.
      • toValue

        public abstract Value toValue()
        Returns the value component of this Item, if this Item is a Field; otherwise returns this if this Item is a Value.
      • tag

        public abstract String tag()
        Returns the key string of the first member of this Item, if this Item is a Record, and its first member is an Attr; otherwise returns null if this Item is not a Record, or if this Item is a Record whose first member is not an Attr.

        Used to concisely get the name of the discriminating attribute of a structure. The tag can be used to discern the nominal type of a polymorphic structure, similar to an XML element tag.

      • target

        public abstract Value target()
        Returns the flattened members of this Item after all attributes have been removed, if this Item is a Record; otherwise returns this if this Item is a non-Record Value, or returns the value component if this Item is a Field.

        Used to concisely get the scalar value of an attributed structure. An attributed structure is a Record with one or more attributes that modify one or more other members.

      • flattened

        public abstract Value flattened()
        Returns the sole member of this Item, if this Item is a Record with exactly one member, and its member is a Value; returns Extant if this Item is an empty Record; returns Absent if this Item is a Field; otherwise returns this if this Item is a Record with more than one member, or if this Item is a non-Record Value.

        Used to convert a unary Record into its member Value. Facilitates writing code that treats a unary Record equivalently to a bare Value.

      • unflattened

        public abstract Record unflattened()
        Returns this if this Item is a Record; returns a Record containing just this Item, if this Item is distinct; otherwise returns an empty Record if this Item is Extant or Absent. Facilitates writing code that treats a bare Value equivalently to a unary Record.
      • header

        public abstract Value header​(String tag)
        Returns the value of the first member of this Item, if this Item is a Record, and its first member is an Attr whose key string is equal to tag; otherwise returns Absent if this Item is not a Record, or if this Item is a Record whose first member is not an Attr, or if this Item is a Record whose first member is an Attr whose key does not equal the tag.

        Used to conditionally get the value of the head Attr of a structure, if and only if the key string of the head Attr is equal to the tag. Can be used to check if a structure might conform to a nominal type named tag, while simultaneously getting the value of the tag attribute.

      • headers

        public abstract Record headers​(String tag)
        Returns the unflattened header of this Item, if this Item is a Record, and its first member is an Attr whose key string is equal to tag; otherwise returns null.

        The headers of the tag attribute of a structure are like the attributes of an XML element tag; through unlike an XML element, tag attribute headers are not limited to string keys and values.

      • head

        public abstract Item head()
        Returns the first member of this Item, if this Item is a non-empty Record; otherwise returns Absent.
      • tail

        public abstract Record tail()
        Returns a view of all but the first member of this Item, if this Item is a non-empty Record; otherwise returns an empty Record if this Item is not a Record, or if this Item is itself an empty Record.
      • body

        public abstract Value body()
        Returns the flattened tail of this Item. Used to recursively deconstruct a structure, terminating with its last Value, rather than a unary Record containing its last value, if the structure ends with a Value member.
      • length

        public abstract int length()
        Returns the number of members contained in this Item, if this Item is a Record; otherwise returns 0 if this Item is not a Record.
      • contains

        public abstract boolean contains​(Item item)
        Returns true if this Item is a Record that has a member equal to item; otherwise returns false if this Item is not a Record, or if this Item is a Record, but has no member equal to item.
      • containsKey

        public abstract boolean containsKey​(Value key)
        Returns true if this Item is a Record that has a Field member with a key that is equal to the given key; otherwise returns false if this Item is not a Record, or if this Item is a Record, but has no Field member with a key equal to the given key.
      • containsKey

        public abstract boolean containsKey​(String key)
        Returns true if this Item is a Record that has a Field with a Text key whose string value is equal to the given key; otherwise returns false if this Item is not a Record, or if this Item is a Record, but has no Field member with a Text key whose string value equals the given key. Equivalent to containsKey(Value), but avoids boxing the key string into a Text value.
      • containsValue

        public abstract boolean containsValue​(Value value)
        Returns true if this Item is a Record that has a Field member with a value that is equal to the given value; otherwise returns false if this Item is not a Record, or if this Item is a Record, but has no Field member with a value equal to the given value.
      • get

        public abstract Value get​(Value key)
        Returns the value of the last Field member of this Item whose key is equal to the given key; returns Absent if this Item is not a Record, or if this Item is a Record, but has no Field member with a key equal to the given key.
      • get

        public abstract Value get​(String key)
        Returns the value of the last Field member of this Item with a Text key whose string value is equal to the given key; returns Absent if this Item is not a Record, or if this Item is a Record, but has no Field member with a Text key whose string value equals the given key. Equivalent to get(Value), but avoids boxing the key string into a Text value.
      • getAttr

        public abstract Value getAttr​(Text key)
        Returns the value of the last Attr member of this Item whose key is equal to the given key; returns Absent if this Item is not a Record, or if this Item is a Record, but has no Attr member with a key equal to the given key.
      • getAttr

        public abstract Value getAttr​(String key)
        Returns the value of the last Attr member of this Item with a Text key whose string value is equal to the given key; returns Absent if this Item is not a Record, or if this Item is a Record, but has no Attr member with a Text key whose string value equals the given key. Equivalent to getAttr(Text), but avoids boxing the key string into a Text value.
      • getSlot

        public abstract Value getSlot​(Value key)
        Returns the value of the last Slot member of this Item whose key is equal to the given key; returns Absent if this Item is not a Record, or if this Item is a Record, but has no Slot member with a key equal to the given key.
      • getSlot

        public abstract Value getSlot​(String key)
        Returns the value of the last Slot member of this Item with a Text key whose string value is equal to the given key; returns Absent if this Item is not a Record, or if this Item is a Record, but has no Slot member with a Text key whose string value equals the given key. Equivalent to getSlot(Value), but avoids boxing the key string into a Text value.
      • getField

        public abstract Field getField​(Value key)
        Returns the last Field member of this Item whose key is equal to the given key; returns null if this Item is not a Record, or if this Item is a Record, but has no Field member with a key equal to the given key.
      • getField

        public abstract Field getField​(String key)
        Returns the last Field member of this Item with a Text key whose string value is equal to the given key; returns null if this Item is not a Record, or if this Item is a Record, but has no Field member with a Text key whose string value equals the given key. Equivalent to getField(Value), but avoids boxing the key string into a Text value.
      • getItem

        public abstract Item getItem​(int index)
        Returns the member of this Item at the given index, if this Item is a Record, and the index is greater than or equal to zero, and less than the length of the Record; otherwise returns Absent if this Item is not a Record, or if this Item is a Record, but the index is out of bounds.
      • updated

        public Record updated​(Value key,
                              int value)
      • updated

        public Record updated​(Value key,
                              long value)
      • updated

        public Record updated​(Value key,
                              float value)
      • updated

        public Record updated​(Value key,
                              double value)
      • updated

        public Record updated​(Value key,
                              boolean value)
      • updated

        public Record updated​(String key,
                              int value)
      • updated

        public Record updated​(String key,
                              long value)
      • updated

        public Record updated​(String key,
                              float value)
      • updated

        public Record updated​(String key,
                              double value)
      • updated

        public Record updated​(String key,
                              boolean value)
      • updatedAttr

        public Record updatedAttr​(Text key,
                                  int value)
      • updatedAttr

        public Record updatedAttr​(Text key,
                                  long value)
      • updatedAttr

        public Record updatedAttr​(Text key,
                                  float value)
      • updatedAttr

        public Record updatedAttr​(Text key,
                                  double value)
      • updatedAttr

        public Record updatedAttr​(Text key,
                                  boolean value)
      • updatedAttr

        public Record updatedAttr​(String key,
                                  int value)
      • updatedAttr

        public Record updatedAttr​(String key,
                                  long value)
      • updatedAttr

        public Record updatedAttr​(String key,
                                  float value)
      • updatedAttr

        public Record updatedAttr​(String key,
                                  double value)
      • updatedAttr

        public Record updatedAttr​(String key,
                                  boolean value)
      • updatedSlot

        public Record updatedSlot​(Value key,
                                  int value)
      • updatedSlot

        public Record updatedSlot​(Value key,
                                  long value)
      • updatedSlot

        public Record updatedSlot​(Value key,
                                  float value)
      • updatedSlot

        public Record updatedSlot​(Value key,
                                  double value)
      • updatedSlot

        public Record updatedSlot​(Value key,
                                  boolean value)
      • updatedSlot

        public Record updatedSlot​(String key,
                                  int value)
      • updatedSlot

        public Record updatedSlot​(String key,
                                  long value)
      • updatedSlot

        public Record updatedSlot​(String key,
                                  float value)
      • updatedSlot

        public Record updatedSlot​(String key,
                                  double value)
      • updatedSlot

        public Record updatedSlot​(String key,
                                  boolean value)
      • appended

        public Record appended​(Item item)
      • appended

        public Record appended​(int item)
      • appended

        public Record appended​(long item)
      • appended

        public Record appended​(float item)
      • appended

        public Record appended​(double item)
      • appended

        public Record appended​(boolean item)
      • prepended

        public Record prepended​(Item item)
      • prepended

        public Record prepended​(int item)
      • prepended

        public Record prepended​(long item)
      • prepended

        public Record prepended​(float item)
      • prepended

        public Record prepended​(double item)
      • prepended

        public Record prepended​(boolean item)
      • removed

        public abstract Item removed​(Value key)
      • removed

        public abstract Item removed​(String key)
      • conditional

        public abstract Item conditional​(Item thenTerm,
                                         Item elseTerm)
      • or

        public abstract Item or​(Item that)
      • and

        public abstract Item and​(Item that)
      • bitwiseOr

        public abstract Item bitwiseOr​(Item that)
      • bitwiseXor

        public abstract Item bitwiseXor​(Item that)
      • bitwiseAnd

        public abstract Item bitwiseAnd​(Item that)
      • plus

        public abstract Item plus​(Item that)
      • minus

        public abstract Item minus​(Item that)
      • times

        public abstract Item times​(Item that)
      • divide

        public abstract Item divide​(Item that)
      • modulo

        public abstract Item modulo​(Item that)
      • not

        public abstract Item not()
      • bitwiseNot

        public abstract Item bitwiseNot()
      • negative

        public abstract Item negative()
      • positive

        public abstract Item positive()
      • inverse

        public abstract Item inverse()
      • invoke

        public Item invoke​(Value args)
      • lambda

        public abstract Value lambda​(Value template)
      • evaluate

        public Item evaluate​(Item scope)
      • substitute

        public Item substitute​(Item scope)
      • stringValue

        public abstract String stringValue()
        Converts this Item into a String value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a String value.
      • stringValue

        public abstract String stringValue​(String orElse)
        Converts this Item into a String value, if possible; otherwise returns orElse if this Item can't be converted into a string value.
      • byteValue

        public abstract byte byteValue()
        Converts this Item into a primitive byte value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a primitive byte value.
      • byteValue

        public abstract byte byteValue​(byte orElse)
        Converts this Item into a primitive byte value, if possible; otherwise returns orElse if this Item can't be converted into a primitive byte value.
      • shortValue

        public abstract short shortValue()
        Converts this Item into a primitive short value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a primitive short value.
      • shortValue

        public abstract short shortValue​(short orElse)
        Converts this Item into a primitive short value, if possible; otherwise returns orElse if this Item can't be converted into a primitive short value.
      • intValue

        public abstract int intValue()
        Converts this Item into a primitive int value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a primitive int value.
      • intValue

        public abstract int intValue​(int orElse)
        Converts this Item into a primitive int value, if possible; otherwise returns orElse if this Item can't be converted into a primitive int value.
      • longValue

        public abstract long longValue()
        Converts this Item into a primitive long value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a primitive long value.
      • longValue

        public abstract long longValue​(long orElse)
        Converts this Item into a primitive long value, if possible; otherwise returns orElse if this Item can't be converted into a primitive long value.
      • floatValue

        public abstract float floatValue()
        Converts this Item into a primitive float value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a primitive float value.
      • floatValue

        public abstract float floatValue​(float orElse)
        Converts this Item into a primitive float value, if possible; otherwise returns orElse if this Item can't be converted into a primitive float value.
      • doubleValue

        public abstract double doubleValue()
        Converts this Item into a primitive double value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a primitive double value.
      • doubleValue

        public abstract double doubleValue​(double orElse)
        Converts this Item into a primitive double value, if possible; otherwise returns orElse if this Item can't be converted into a primitive double value.
      • integerValue

        public abstract BigInteger integerValue()
        Converts this Item into a BigInteger value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a BigInteger value.
      • integerValue

        public abstract BigInteger integerValue​(BigInteger orElse)
        Converts this Item into a BigInteger value, if possible; otherwise returns orElse if this Item can't be converted into a BigInteger value.
      • numberValue

        public abstract Number numberValue()
        Converts this Item into a Number object, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a Number object.
      • numberValue

        public abstract Number numberValue​(Number orElse)
        Converts this Item into a Number object, if possible; otherwise returns orElse if this Item can't be converted into a Number object.
      • charValue

        public abstract char charValue()
        Converts this Item into a primitive char value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a primitive char value.
      • charValue

        public abstract char charValue​(char orElse)
        Converts this Item into a primitive char value, if possible; otherwise returns orElse if this Item can't be converted into a primitive char value.
      • booleanValue

        public abstract boolean booleanValue()
        Converts this Item into a primitive boolean value, if possible.
        Throws:
        UnsupportedOperationException - if this Item can't be converted into a primitive boolean value.
      • booleanValue

        public abstract boolean booleanValue​(boolean orElse)
        Converts this Item into a primitive boolean value, if possible; otherwise returns orElse if this Item can't be converted into a primitive boolean value.
      • cast

        public <T> T cast​(Form<T> form)
      • cast

        public <T> T cast​(Form<T> form,
                          T orElse)
      • coerce

        public <T> T coerce​(Form<T> form)
      • coerce

        public <T> T coerce​(Form<T> form,
                            T orElse)
      • isAliased

        public abstract boolean isAliased()
      • isMutable

        public abstract boolean isMutable()
      • alias

        public abstract void alias()
      • branch

        public abstract Item branch()
      • commit

        public abstract Item commit()
        Flags this Item as immutable, recursively if it is a Record, then returns this Item.
      • precedence

        public int precedence()
      • typeOrder

        public abstract int typeOrder()
        Returns the heterogeneous sort order of this Item. Used to impose a total order on the set of all items. When comparing two items of different types, the items order according to their typeOrder.
      • keyEquals

        public abstract boolean keyEquals​(Object key)
      • equals

        public abstract boolean equals​(Object other)
        Overrides:
        equals in class Object
      • hashCode

        public abstract int hashCode()
        Overrides:
        hashCode in class Object
      • debug

        public abstract <T> Output<T> debug​(Output<T> output)
        Description copied from interface: Debug
        Writes a developer readable, debug-formatted string representation of this object to output.
        Specified by:
        debug in interface Debug
        Returns:
        the continuation of the output.
      • display

        public <T> Output<T> display​(Output<T> output)
        Description copied from interface: Display
        Writes a human readable, display-formatted string representation of this object to output.
        Specified by:
        display in interface Display
        Returns:
        the continuation of the output.
      • empty

        public static Item empty()
      • extant

        public static Item extant()
      • absent

        public static Item absent()
      • fromObject

        public static Item fromObject​(Object object)
      • globalScope

        public static Item globalScope()