Package ch.ivyteam.ivy.scripting.objects
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:
- Serialized Form
- API:
- This is a public API.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Tuple
createEmpty()
Creates an empty tuple with empty tuple type "<>".boolean
equals(Object obj)
Object
get(int pos)
Gets the value of the member at the position.Object
get(String name)
Gets the tuple value of the member with the given name.int
hashCode()
boolean
isEmpty()
Check if this is the empty tuple value.Tuple
readOnlyTuple()
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
size()
The size of this tuple (i.e.String
toString()
Returns a string representation of this tuple.Tuple
writableTuple()
Creates a writable version of the given tuple.
-
-
-
Method Detail
-
createEmpty
public static Tuple createEmpty()
Creates an empty tuple with empty tuple type "<>".- Returns:
- tuple value
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
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 IvyScript and Java. It has the visibility EXPERT.
-
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 IvyScript and Java. It has the visibility EXPERT.
-
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 IvyScript and Java. It has the visibility EXPERT.
-
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 IvyScript and Java. It has the visibility EXPERT.
-
set
public void set(int pos, Object value) throws IllegalArgumentException, IndexOutOfBoundsException, IllegalStateException
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 ofvalue
- the value to set- Throws:
IllegalArgumentException
- if type of value does not match type of memberIndexOutOfBoundsException
- if position is invalidIllegalStateException
- if field/tuple is read only- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
set
public void set(String name, Object value) throws IllegalArgumentException, NoSuchFieldException, IllegalStateException
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 setvalue
- the value to set- Throws:
IllegalArgumentException
- if type of value does not match type of memberNoSuchFieldException
- if no member with given name existsIllegalStateException
- if field/tuple is read only- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
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 IvyScript and Java. It has the visibility EXPERT.
-
isEmpty
public boolean isEmpty()
Check if this is the empty tuple value. This is the same as a check forsize()
== 0.- Returns:
- true, if this tuple is the empty tuple
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
equals
public boolean equals(Object obj)
- See Also:
Object.equals(java.lang.Object)
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
hashCode
public int hashCode()
- See Also:
Object.hashCode()
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
toString
public String toString()
Returns a string representation of this tuple.- See Also:
Object.toString()
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
-