Class Tuple

java.lang.Object
ch.ivyteam.ivy.scripting.objects.Tuple
All Implemented Interfaces:
IIvyDataObject, Serializable, Cloneable

public class Tuple extends Object implements IIvyDataObject
A class for a typed tuple. Tuples are an ordered sequence of 0..n Types. A tuple knows about its member types, member fields can have optional names.
See Also:
API:
This is a public API.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Tuple
    Creates an empty tuple with empty tuple type "<>".
    boolean
     
    get(int pos)
    Gets the value of the member at the position.
    get(String name)
    Gets the tuple value of the member with the given name.
    int
     
    boolean
    Check if this is the empty tuple value.
    Creates a read-only version of the given tuple.
    void
    set(int pos, Object value)
    Sets the value of the member at the given position.
    void
    set(String name, Object value)
    Sets the value of the member with the given name.
    int
    The size of this tuple (i.e. number of members/fields).
    Returns a string representation of this tuple.
    Creates a writable version of the given tuple.
  • Method Details

    • createEmpty

      public static Tuple createEmpty()
      Creates an empty tuple with empty tuple type "<>".
      Returns:
      tuple value
      API:
      This public API is available in Java.
    • readOnlyTuple

      public Tuple readOnlyTuple()
      Creates a read-only version of the given tuple.
      Returns:
      If this type is read-only, it is returned, otherwise a read-only copy of this tuple is returned.
      API:
      This public API is available in Java.
    • writableTuple

      public Tuple writableTuple()
      Creates a writable version of the given tuple.
      Returns:
      If this type is writable, it is returned, otherwise a writable copy of this tuple is returned.
      API:
      This public API is available in Java.
    • get

      public Object get(int pos) throws IndexOutOfBoundsException
      Gets the value of the member at the position.
      Parameters:
      pos - a 0-based position
      Returns:
      value of the member at the given position (may be null)
      Throws:
      IndexOutOfBoundsException - if position is invalid
      API:
      This public API is available in Java.
    • get

      public Object get(String name) throws NoSuchFieldException
      Gets the tuple value of the member with the given name.
      Parameters:
      name - the name of the member to get value of
      Returns:
      value of given member (may be null)
      Throws:
      NoSuchFieldException - if no member with given name exists
      API:
      This public API is available in Java.
    • set

      Sets the value of the member at the given position. If value type does not match type of member with given name, then an IllegalArgumentException will be thrown.
      Parameters:
      pos - the position of the member to set value of
      value - the value to set
      Throws:
      IllegalArgumentException - if type of value does not match type of member
      IndexOutOfBoundsException - if position is invalid
      IllegalStateException - if field/tuple is read only
      API:
      This public API is available in Java.
    • set

      Sets the value of the member with the given name. If value type does not match type of member with given name, then an IllegalArgumentException will be thrown.
      Parameters:
      name - the name of the member to set
      value - the value to set
      Throws:
      IllegalArgumentException - if type of value does not match type of member
      NoSuchFieldException - if no member with given name exists
      IllegalStateException - if field/tuple is read only
      API:
      This public API is available in Java.
    • size

      public int size()
      The size of this tuple (i.e. number of members/fields).
      Returns:
      tuple size
      API:
      This public API is available in Java.
    • isEmpty

      public boolean isEmpty()
      Check if this is the empty tuple value. This is the same as a check for size() == 0.
      Returns:
      true, if this tuple is the empty tuple
      API:
      This public API is available in Java.
    • equals

      public boolean equals(Object obj)
      See Also:
      API:
      This public API is available in Java.
    • hashCode

      public int hashCode()
      See Also:
      API:
      This public API is available in Java.
    • toString

      public String toString()
      Returns a string representation of this tuple.
      See Also:
      API:
      This public API is available in Java.