Class Record

    • Constructor Detail

      • Record

        public Record()
    • Method Detail

      • isDefinite

        public boolean isDefinite()
        Description copied from class: Value
        Returns true if this Value is not one of: an empty Record, False, Extant, or Absent.
        Overrides:
        isDefinite in class Value
      • isEmpty

        public abstract boolean isEmpty()
        Returns true if this Record has no members.
        Specified by:
        isEmpty in interface Collection<Item>
        Specified by:
        isEmpty in interface List<Item>
      • isArray

        public boolean isArray()
        Returns true if this Record has only Value members–no Field members.
      • isObject

        public boolean isObject()
        Returns true if this Record has only Field members–no Value members.
      • size

        public abstract int size()
        Returns the number of members contained in this Record.
        Specified by:
        size in interface Collection<Item>
        Specified by:
        size in interface List<Item>
      • length

        public final int length()
        Returns the number of members contained in this Record; equivalent to size().
        Overrides:
        length in class Value
      • fieldCount

        public int fieldCount()
        Returns the number of Field members contained in this Record.
      • valueCount

        public int valueCount()
        Returns the number of Value members contained in this Record.
      • isConstant

        public boolean isConstant()
        Description copied from class: Item
        Returns true if this Item always evaluates to the same Item.
        Specified by:
        isConstant in class Item
      • tag

        public String tag()
        Returns the key string of the first member of this Record, if the first member is an Attr; otherwise returns null if the 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.

        Overrides:
        tag in class Value
      • target

        public Value target()
        Returns the flattened members of this Record after all attributes have been removed.

        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.

        Overrides:
        target in class Value
      • flattened

        public Value flattened()
        Returns the sole member of this Record, if this Record has exactly one member, and its member is a Value; returns Extant if this Record is empty; otherwise returns this if this Record has more than one member.

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

        Overrides:
        flattened in class Value
      • header

        public Value header​(String tag)
        Returns the value of the first member of this Record, if the first member is an Attr whose key string is equal to tag; otherwise returns Absent if the first member of this Record is not an Attr, or if the first member of this Record 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.

        Overrides:
        header in class Value
      • headers

        public Record headers​(String tag)
        Returns the unflattened header of this Record. 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.
        Overrides:
        headers in class Value
      • head

        public Item head()
        Returns the first member of this Record, if this Record is non-empty; otherwise returns Absent.
        Overrides:
        head in class Value
      • tail

        public Record tail()
        Returns a view of all but the first member of this Record, if this Record is non-empty; otherwise returns an empty Record, if this Record is itself empty.
        Overrides:
        tail in class Value
      • body

        public Value body()
        Returns the flattened tail of this Record. 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.
        Overrides:
        body in class Value
      • contains

        public boolean contains​(Object item)
        Returns true if this Record has a member equal to Item.fromObject(item); otherwise returns false if this Record has no member equal to Item.fromObject(item).
        Specified by:
        contains in interface Collection<Item>
        Specified by:
        contains in interface List<Item>
      • contains

        public boolean contains​(Item item)
        Returns true if this Record has a member equal to item; otherwise returns false if this Record has no member equal to item.
        Overrides:
        contains in class Value
      • containsAll

        public boolean containsAll​(Collection<?> items)
        Returns true if this Record has a member equal to every item in items; returns false if any item in items is not contained in this Record.
        Specified by:
        containsAll in interface Collection<Item>
        Specified by:
        containsAll in interface List<Item>
      • containsKey

        public boolean containsKey​(Value key)
        Returns true if this Record has a Field member with a key that is equal to the given key; otherwise returns false if this Record has no Field member with a key equal to the given key.
        Overrides:
        containsKey in class Value
      • containsKey

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

        public boolean containsValue​(Value value)
        Returns true if this Record has a Field member with a value that is equal to the given value; otherwise returns false if this Record has no Field member with a value equal to the given value.
        Overrides:
        containsValue in class Value
      • get

        public Value get​(Value key)
        Returns the value of the last Field member of this Record whose key is equal to the given key; returns Absent if this Record has no Field member with a key equal to the given key.
        Overrides:
        get in class Value
      • get

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

        public Value getAttr​(Text key)
        Returns the value of the last Attr member of this Record whose key is equal to the given key; returns Absent if this Record has no Attr member with a key equal to the given key.
        Overrides:
        getAttr in class Value
      • getAttr

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

        public Value getSlot​(Value key)
        Returns the value of the last Slot member of this Record whose key is equal to the given key; returns Absent if this Record has no Slot member with a key equal to the given key.
        Overrides:
        getSlot in class Value
      • getSlot

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

        public Field getField​(Value key)
        Returns the last Field member of this Record whose key is equal to the given key; returns null if this Record has no Field member with a key equal to the given key.
        Overrides:
        getField in class Value
      • getField

        public Field getField​(String key)
        Returns the last Field member of this Record whose key is equal to the given key; returns null if this Record has no Field member with a key equal to the given key. Equivalent to getField(Value), but avoids boxing the key string into a Text value.
        Overrides:
        getField in class Value
      • get

        public abstract Item get​(int index)
        Returns the member of this Record at the given index, if the index is greater than or equal to zero, and less than the length of this Record.
        Specified by:
        get in interface List<Item>
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds.
      • getItem

        public abstract Item getItem​(int index)
        Returns the member of this Record at the given index, if the index is greater than or equal to zero, and less than the length of this Record; otherwise returns Absent if the index is out of bounds.
        Overrides:
        getItem in class Value
      • put

        public Value put​(Value key,
                         int newValue)
      • put

        public Value put​(Value key,
                         long newValue)
      • put

        public Value put​(Value key,
                         float newValue)
      • put

        public Value put​(Value key,
                         double newValue)
      • put

        public Value put​(Value key,
                         boolean newValue)
      • put

        public Value put​(String key,
                         int newValue)
      • put

        public Value put​(String key,
                         long newValue)
      • put

        public Value put​(String key,
                         float newValue)
      • put

        public Value put​(String key,
                         double newValue)
      • put

        public Value put​(String key,
                         boolean newValue)
      • putAttr

        public Value putAttr​(Text key,
                             int newValue)
      • putAttr

        public Value putAttr​(Text key,
                             long newValue)
      • putAttr

        public Value putAttr​(Text key,
                             float newValue)
      • putAttr

        public Value putAttr​(Text key,
                             double newValue)
      • putAttr

        public Value putAttr​(Text key,
                             boolean newValue)
      • putAttr

        public Value putAttr​(String key,
                             int newValue)
      • putAttr

        public Value putAttr​(String key,
                             long newValue)
      • putAttr

        public Value putAttr​(String key,
                             float newValue)
      • putAttr

        public Value putAttr​(String key,
                             double newValue)
      • putAttr

        public Value putAttr​(String key,
                             boolean newValue)
      • putSlot

        public Value putSlot​(Value key,
                             int newValue)
      • putSlot

        public Value putSlot​(Value key,
                             long newValue)
      • putSlot

        public Value putSlot​(Value key,
                             float newValue)
      • putSlot

        public Value putSlot​(Value key,
                             double newValue)
      • putSlot

        public Value putSlot​(Value key,
                             boolean newValue)
      • putSlot

        public Value putSlot​(String key,
                             int newValue)
      • putSlot

        public Value putSlot​(String key,
                             long newValue)
      • putSlot

        public Value putSlot​(String key,
                             float newValue)
      • putSlot

        public Value putSlot​(String key,
                             double newValue)
      • putSlot

        public Value putSlot​(String key,
                             boolean newValue)
      • putAll

        public void putAll​(Map<? extends Value,​? extends Value> fields)
      • setItem

        public abstract Item setItem​(int index,
                                     Item item)
        Replaces the member of this Record at the given index with a new item, returning the previous Item at the given index, if the index is greater than or equal to zero, and less than the length of this Record.
        Throws:
        UnsupportedOperationException - if this is an immutable Record.
        IndexOutOfBoundsException - if the index is out of bounds.
      • setItem

        public Item setItem​(int index,
                            String value)
        Replaces the member of this Record at the given index with a Text value, returning the previous Item at the given index, if the index is greater than or equal to zero, and less than the length of this Record.
        Throws:
        UnsupportedOperationException - if this is an immutable Record.
        IndexOutOfBoundsException - if the index is out of bounds.
      • setItem

        public Item setItem​(int index,
                            int value)
        Replaces the member of this Record at the given index with a Num value, returning the previous Item at the given index, if the index is greater than or equal to zero, and less than the length of this Record.
        Throws:
        UnsupportedOperationException - if this is an immutable Record.
        IndexOutOfBoundsException - if the index is out of bounds.
      • setItem

        public Item setItem​(int index,
                            long value)
        Replaces the member of this Record at the given index with a Num value, returning the previous Item at the given index, if the index is greater than or equal to zero, and less than the length of this Record.
        Throws:
        UnsupportedOperationException - if this is an immutable Record.
        IndexOutOfBoundsException - if the index is out of bounds.
      • setItem

        public Item setItem​(int index,
                            float value)
        Replaces the member of this Record at the given index with a Num value, returning the previous Item at the given index, if the index is greater than or equal to zero, and less than the length of this Record.
        Throws:
        UnsupportedOperationException - if this is an immutable Record.
        IndexOutOfBoundsException - if the index is out of bounds.
      • setItem

        public Item setItem​(int index,
                            double value)
        Replaces the member of this Record at the given index with a Num value, returning the previous Item at the given index, if the index is greater than or equal to zero, and less than the length of this Record.
        Throws:
        UnsupportedOperationException - if this is an immutable Record.
        IndexOutOfBoundsException - if the index is out of bounds.
      • setItem

        public Item setItem​(int index,
                            boolean value)
        Replaces the member of this Record at the given index with a Bool value, returning the previous Item at the given index, if the index is greater than or equal to zero, and less than the length of this Record.
        Throws:
        UnsupportedOperationException - if this is an immutable Record.
        IndexOutOfBoundsException - if the index is out of bounds.
      • add

        public abstract boolean add​(Item item)
        Description copied from interface: Builder
        Adds a single input value to this builder, returning true if the state of the builder changed.
        Specified by:
        add in interface Builder<Item,​Record>
        Specified by:
        add in interface Collection<Item>
        Specified by:
        add in interface List<Item>
      • add

        public boolean add​(String item)
      • add

        public boolean add​(int item)
      • add

        public boolean add​(long item)
      • add

        public boolean add​(float item)
      • add

        public boolean add​(double item)
      • add

        public boolean add​(boolean item)
      • add

        public abstract void add​(int index,
                                 Item item)
        Specified by:
        add in interface List<Item>
      • add

        public void add​(int index,
                        String item)
      • add

        public void add​(int index,
                        int item)
      • add

        public void add​(int index,
                        long item)
      • add

        public void add​(int index,
                        float item)
      • add

        public void add​(int index,
                        double item)
      • add

        public void add​(int index,
                        boolean item)
      • add

        public boolean add​(Value key,
                           Value value)
        Description copied from interface: PairBuilder
        Adds an input pair to this builder, returning true if the state of the builder changed.
        Specified by:
        add in interface PairBuilder<Value,​Value,​Record>
      • attr

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

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

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

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

        public Record attr​(Text key,
                           boolean value)
      • slot

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

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

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

        public Record slot​(Value key,
                           boolean value)
      • item

        public Record item​(int item)
      • item

        public Record item​(long item)
      • item

        public Record item​(float item)
      • item

        public Record item​(double item)
      • item

        public Record item​(boolean item)
      • remove

        public abstract Item remove​(int index)
        Specified by:
        remove in interface List<Item>
      • removeKey

        public boolean removeKey​(Value key)
      • removeKey

        public boolean removeKey​(String key)
      • stringValue

        public String stringValue()
        Description copied from class: Value
        Converts this Value into a String value, if possible.
        Overrides:
        stringValue in class Value
      • stringValue

        public String stringValue​(String orElse)
        Description copied from class: Value
        Converts this Value into a String value, if possible; otherwise returns orElse if this Value can't be converted into a string value.
        Overrides:
        stringValue in class Value
      • isAliased

        public boolean isAliased()
        Overrides:
        isAliased in class Value
      • isMutable

        public boolean isMutable()
        Overrides:
        isMutable in class Value
      • asMutable

        public Record asMutable()
      • alias

        public void alias()
        Overrides:
        alias in class Value
      • commit

        public Record commit()
        Description copied from class: Item
        Flags this Item as immutable, recursively if it is a Record, then returns this Item.
        Overrides:
        commit in class Value
      • subList

        public Record subList​(int fromIndex,
                              int toIndex)
        Specified by:
        subList in interface List<Item>
      • fieldSet

        public Set<Field> fieldSet()
      • typeOrder

        public int typeOrder()
        Description copied from class: Item
        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.
        Specified by:
        typeOrder in class Item
      • compareTo

        public int compareTo​(Record that)
      • debug

        public <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
        Specified by:
        debug in class Item
        Returns:
        the continuation of the output.
      • empty

        public static Record empty()
      • create

        public static Record create()
      • create

        public static Record create​(int initialSize)
      • of

        public static Record of()