Package ch.ivyteam.ivy.scripting.objects
Class Tuple
java.lang.Object
ch.ivyteam.ivy.scripting.objects.Tuple
- All Implemented Interfaces:
IIvyDataObject
,Serializable
,Cloneable
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 TypeMethodDescriptionstatic Tuple
Creates an empty tuple with empty tuple type "<>".boolean
get
(int pos) Gets the value of the member at the position.Gets the tuple value of the member with the given name.int
hashCode()
boolean
isEmpty()
Check if this is the empty tuple value.Creates a read-only version of the given tuple.void
Sets the value of the member at the given position.void
Sets the value of the member with the given name.int
size()
The size of this tuple (i.e.toString()
Returns a string representation of this tuple.Creates a writable version of the given tuple.
-
Method Details
-
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
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
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
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
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
- See Also:
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
hashCode
public int hashCode()- See Also:
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
toString
Returns a string representation of this tuple.- See Also:
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-