- java.lang.Object
-
- swim.structure.Item
-
- swim.structure.Value
-
-
Method Summary
Modifier and Type Method Description static Valueabsent()voidalias()Itemand(Item that)Valueand(Value that)ItembitwiseAnd(Item that)ValuebitwiseAnd(Value that)ValuebitwiseNot()ItembitwiseOr(Item that)ValuebitwiseOr(Value that)ItembitwiseXor(Item that)ValuebitwiseXor(Value that)Valuebody()booleanbooleanValue()Converts thisValueinto a primitivebooleanvalue, if possible.booleanbooleanValue(boolean orElse)Converts thisValueinto a primitivebooleanvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivebooleanvalue.Valuebranch()static Builder<Item,Value>builder()bytebyteValue()Converts thisValueinto a primitivebytevalue, if possible.bytebyteValue(byte orElse)Converts thisValueinto a primitivebytevalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivebytevalue.charcharValue()Converts thisValueinto a primitivecharvalue, if possible.charcharValue(char orElse)Converts thisValueinto a primitivecharvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivecharvalue.Valuecommit()Itemconditional(Item thenTerm, Item elseTerm)Valueconditional(Value thenTerm, Value elseTerm)booleancontains(Item item)Returnstrueif thisValueis aRecordthat has a member equal toitem; otherwise returnsfalseif thisValueis not aRecord, or if thisValueis aRecord, but has no member equal toitem.booleancontainsKey(String key)booleancontainsKey(Value key)booleancontainsValue(Value value)Itemdivide(Item that)Valuedivide(Value that)doubledoubleValue()Converts thisValueinto a primitivedoublevalue, if possible.doubledoubleValue(double orElse)Converts thisValueinto a primitivedoublevalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivedoublevalue.static Valueempty()Itemeq(Item that)Valueeq(Value that)static Valueextant()Valueflattened()floatfloatValue()Converts thisValueinto a primitivefloatvalue, if possible.floatfloatValue(float orElse)Converts thisValueinto a primitivefloatvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivefloatvalue.static ValuefromObject(Object object)Itemge(Item that)Valuege(Value that)Valueget(String key)Valueget(Value key)ValuegetAttr(String key)ValuegetAttr(Text key)FieldgetField(String key)FieldgetField(Value key)ItemgetItem(int index)ValuegetSlot(String key)ValuegetSlot(Value key)Itemgt(Item that)Valuegt(Value that)Itemhead()Valueheader(String tag)Returns the value of the first member of thisValue, if thisValueis aRecord, and its first member is anAttrwhosekeystring is equal totag; otherwise returnsAbsentif thisValueis not aRecord, or if thisValueis aRecordwhose first member is not anAttr, or if thisValueis aRecordwhose first member is anAttrwhosekeydoes not equal thetag.Recordheaders(String tag)Returns theunflattenedheaderof thisValue, if thisValueis aRecord, and its first member is anAttrwhosekeystring is equal totag; otherwise returnsnull.BigIntegerintegerValue()Converts thisValueinto aBigIntegervalue, if possible.BigIntegerintegerValue(BigInteger orElse)Converts thisValueinto aBigIntegervalue, if possible; otherwise returnsorElseif thisValuecan't be converted into aBigIntegervalue.intintValue()Converts thisValueinto a primitiveintvalue, if possible.intintValue(int orElse)Converts thisValueinto a primitiveintvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitiveintvalue.Valueinverse()booleanisAliased()booleanisDefined()booleanisDistinct()booleanisMutable()Valuekey()booleankeyEquals(Object key)Valuelambda(Value template)Itemle(Item that)Valuele(Value that)intlength()Returns the number of members contained in thisValue, if thisValueis aRecord; otherwise returns0if thisValueis not aRecord.longlongValue()Converts thisValueinto a primitivelongvalue, if possible.longlongValue(long orElse)Converts thisValueinto a primitivelongvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivelongvalue.Itemlt(Item that)Valuelt(Value that)Itemminus(Item that)Valueminus(Value that)Itemmodulo(Item that)Valuemodulo(Value that)Itemne(Item that)Valuene(Value that)Valuenegative()Valuenot()NumbernumberValue()Converts thisValueinto aNumberobject, if possible.NumbernumberValue(Number orElse)Converts thisValueinto aNumberobject, if possible; otherwise returnsorElseif thisValuecan't be converted into aNumberobject.Itemor(Item that)Valueor(Value that)Itemplus(Item that)Valueplus(Value that)Valuepositive()Valueremoved(String key)Valueremoved(Value key)shortshortValue()Converts thisValueinto a primitiveshortvalue, if possible.shortshortValue(short orElse)Converts thisValueinto a primitiveshortvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitiveshortvalue.StringstringValue()Converts thisValueinto aStringvalue, if possible.StringstringValue(String orElse)Converts thisValueinto aStringvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into astringvalue.Stringtag()Returns thekeystring of the first member of thisValue, if thisValueis aRecord, and its first member is anAttr; otherwise returnsnullif thisValueis not aRecord, or if thisValueis aRecordwhose first member is not anAttr.Recordtail()Returns a view of all but the first member of thisValue, if thisValueis a non-emptyRecord; otherwise returns an emptyRecordif thisValueis not aRecord, of if thisValueis itself an emptyRecord.Valuetarget()Itemtimes(Item that)Valuetimes(Value that)ValuetoValue()Always returnsthisbecause everyValueis its own value component.Recordunflattened()-
Methods inherited from class swim.structure.Item
appended, appended, appended, appended, appended, appended, appended, appended, cast, cast, coerce, coerce, compareTo, concat, debug, display, equals, evaluate, evaluate, filter, filter, globalScope, hashCode, invoke, isConstant, iterator, max, min, precedence, prepended, prepended, prepended, prepended, prepended, prepended, prepended, prepended, substitute, substitute, toString, typeOrder, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updated, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedAttr, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot, updatedSlot
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
empty
public static Value empty()
-
extant
public static Value extant()
-
absent
public static Value absent()
-
isDistinct
public boolean isDistinct()
- Specified by:
isDistinctin classItem
-
toValue
public final Value toValue()
Always returnsthisbecause everyValueis its own value component.
-
tag
public String tag()
Returns thekeystring of the first member of thisValue, if thisValueis aRecord, and its first member is anAttr; otherwise returnsnullif thisValueis not aRecord, or if thisValueis aRecordwhose first member is not anAttr.Used to concisely get the name of the discriminating attribute of a structure. The
tagcan be used to discern the nominal type of a polymorphic structure, similar to an XML element tag.
-
target
public Value target()
Returns theflattenedmembers of thisValueafter all attributes have been removed, if thisValueis aRecord; otherwise returnsthisif thisValueis not aRecord.Used to concisely get the scalar value of an attributed structure. An attributed structure is a
Recordwith one or more attributes that modify one or more other members.
-
flattened
public Value flattened()
Returns the sole member of thisValue, if thisValueis aRecordwith exactly one member, and its member is aValue; returnsExtantif thisValueis an emptyRecord; otherwise returnsthisif thisValueis aRecordwith more than one member, or if thisValueis not aRecord.Used to convert a unary
Recordinto its memberValue. Facilitates writing code that treats a unaryRecordequivalently to a bareValue.
-
unflattened
public Record unflattened()
Returnsthisif thisValueis aRecord; returns aRecordcontaining just thisValue, if thisValueisdistinct; otherwise returns an emptyRecordif thisValueisExtantorAbsent. Facilitates writing code that treats a bareValueequivalently to a unaryRecord.- Specified by:
unflattenedin classItem
-
header
public Value header(String tag)
Returns the value of the first member of thisValue, if thisValueis aRecord, and its first member is anAttrwhosekeystring is equal totag; otherwise returnsAbsentif thisValueis not aRecord, or if thisValueis aRecordwhose first member is not anAttr, or if thisValueis aRecordwhose first member is anAttrwhosekeydoes not equal thetag.Used to conditionally get the value of the head
Attrof a structure, if and only if the key string of the headAttris equal to thetag. Can be used to check if a structure might conform to a nominal type namedtag, while simultaneously getting the value of thetagattribute.
-
headers
public Record headers(String tag)
Returns theunflattenedheaderof thisValue, if thisValueis aRecord, and its first member is anAttrwhosekeystring is equal totag; otherwise returnsnull.The
headersof thetagattribute of a structure are like the attributes of an XML element tag; through unlike an XML element,tagattribute headers are not limited to string keys and values.
-
head
public Item head()
-
tail
public Record tail()
Returns a view of all but the first member of thisValue, if thisValueis a non-emptyRecord; otherwise returns an emptyRecordif thisValueis not aRecord, of if thisValueis itself an emptyRecord.
-
body
public Value body()
-
length
public int length()
Returns the number of members contained in thisValue, if thisValueis aRecord; otherwise returns0if thisValueis not aRecord.
-
contains
public boolean contains(Item item)
Returnstrueif thisValueis aRecordthat has a member equal toitem; otherwise returnsfalseif thisValueis not aRecord, or if thisValueis aRecord, but has no member equal toitem.
-
containsKey
public boolean containsKey(Value key)
Returnstrueif thisValueis aRecordthat has aFieldmember with a key that is equal to the givenkey; otherwise returnsfalseif thisValueis not aRecord, or if thisValueis aRecord, but has noFieldmember with a key equal to the givenkey.- Specified by:
containsKeyin classItem
-
containsKey
public boolean containsKey(String key)
Returnstrueif thisValueis aRecordthat has aFieldwith aTextkey whose string value is equal to the givenkey; otherwise returnsfalseif thisValueis not aRecord, or if thisValueis aRecord, but has noFieldmember with aTextkey whose string value equals the givenkey. Equivalent tocontainsKey(Value), but avoids boxing thekeystring into aTextvalue.- Specified by:
containsKeyin classItem
-
containsValue
public boolean containsValue(Value value)
Returnstrueif thisValueis aRecordthat has aFieldmember with a value that is equal to the givenvalue; otherwise returnsfalseif thisValueis not aRecord, or if thisValueis aRecord, but has noFieldmember with a value equal to the givenvalue.- Specified by:
containsValuein classItem
-
get
public Value get(String key)
Returns the value of the lastFieldmember of thisValuewith aTextkey whose string value is equal to the givenkey; returnsAbsentif thisValueis not aRecord, or if thisValueis aRecord, but has noFieldmember with aTextkey whose string value equals the givenkey. Equivalent toget(Value), but avoids boxing thekeystring into aTextvalue.
-
getAttr
public Value getAttr(String key)
Returns the value of the lastAttrmember of thisValuewith aTextkey whose string value is equal to the givenkey; returnsAbsentif thisValueis not aRecord, or if thisValueis aRecord, but has noAttrmember with aTextkey whose string value equals the givenkey. Equivalent togetAttr(Text), but avoids boxing thekeystring into aTextvalue.
-
getSlot
public Value getSlot(String key)
Returns the value of the lastSlotmember of thisValuewith aTextkey whose string value is equal to the givenkey; returnsAbsentif thisValueis not aRecord, or if thisValueis aRecord, but has noSlotmember with aTextkey whose string value equals the givenkey. Equivalent togetSlot(Value), but avoids boxing thekeystring into aTextvalue.
-
getField
public Field getField(String key)
Returns the lastFieldmember of thisValuewith aTextkey whose string value is equal to the givenkey; returnsnullif thisValueis not aRecord, or if thisValueis aRecord, but has noFieldmember with aTextkey whose string value equals the givenkey. Equivalent togetField(Value), but avoids boxing thekeystring into aTextvalue.
-
getItem
public Item getItem(int index)
-
conditional
public Item conditional(Item thenTerm, Item elseTerm)
- Specified by:
conditionalin classItem
-
bitwiseXor
public Item bitwiseXor(Item that)
- Specified by:
bitwiseXorin classItem
-
bitwiseAnd
public Item bitwiseAnd(Item that)
- Specified by:
bitwiseAndin classItem
-
bitwiseNot
public Value bitwiseNot()
- Specified by:
bitwiseNotin classItem
-
stringValue
public String stringValue()
Converts thisValueinto aStringvalue, if possible.- Specified by:
stringValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into aStringvalue.
-
stringValue
public String stringValue(String orElse)
Converts thisValueinto aStringvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into astringvalue.- Specified by:
stringValuein classItem
-
byteValue
public byte byteValue()
Converts thisValueinto a primitivebytevalue, if possible.- Specified by:
byteValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into a primitivebytevalue.
-
byteValue
public byte byteValue(byte orElse)
Converts thisValueinto a primitivebytevalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivebytevalue.
-
shortValue
public short shortValue()
Converts thisValueinto a primitiveshortvalue, if possible.- Specified by:
shortValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into a primitiveshortvalue.
-
shortValue
public short shortValue(short orElse)
Converts thisValueinto a primitiveshortvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitiveshortvalue.- Specified by:
shortValuein classItem
-
intValue
public int intValue()
Converts thisValueinto a primitiveintvalue, if possible.- Specified by:
intValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into a primitiveintvalue.
-
intValue
public int intValue(int orElse)
Converts thisValueinto a primitiveintvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitiveintvalue.
-
longValue
public long longValue()
Converts thisValueinto a primitivelongvalue, if possible.- Specified by:
longValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into a primitivelongvalue.
-
longValue
public long longValue(long orElse)
Converts thisValueinto a primitivelongvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivelongvalue.
-
floatValue
public float floatValue()
Converts thisValueinto a primitivefloatvalue, if possible.- Specified by:
floatValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into a primitivefloatvalue.
-
floatValue
public float floatValue(float orElse)
Converts thisValueinto a primitivefloatvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivefloatvalue.- Specified by:
floatValuein classItem
-
doubleValue
public double doubleValue()
Converts thisValueinto a primitivedoublevalue, if possible.- Specified by:
doubleValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into a primitivedoublevalue.
-
doubleValue
public double doubleValue(double orElse)
Converts thisValueinto a primitivedoublevalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivedoublevalue.- Specified by:
doubleValuein classItem
-
integerValue
public BigInteger integerValue()
Converts thisValueinto aBigIntegervalue, if possible.- Specified by:
integerValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into aBigIntegervalue.
-
integerValue
public BigInteger integerValue(BigInteger orElse)
Converts thisValueinto aBigIntegervalue, if possible; otherwise returnsorElseif thisValuecan't be converted into aBigIntegervalue.- Specified by:
integerValuein classItem
-
numberValue
public Number numberValue()
Converts thisValueinto aNumberobject, if possible.- Specified by:
numberValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into aNumberobject.
-
numberValue
public Number numberValue(Number orElse)
Converts thisValueinto aNumberobject, if possible; otherwise returnsorElseif thisValuecan't be converted into aNumberobject.- Specified by:
numberValuein classItem
-
charValue
public char charValue()
Converts thisValueinto a primitivecharvalue, if possible.- Specified by:
charValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into a primitivecharvalue.
-
charValue
public char charValue(char orElse)
Converts thisValueinto a primitivecharvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivecharvalue.
-
booleanValue
public boolean booleanValue()
Converts thisValueinto a primitivebooleanvalue, if possible.- Specified by:
booleanValuein classItem- Throws:
UnsupportedOperationException- if thisValuecan't be converted into a primitivebooleanvalue.
-
booleanValue
public boolean booleanValue(boolean orElse)
Converts thisValueinto a primitivebooleanvalue, if possible; otherwise returnsorElseif thisValuecan't be converted into a primitivebooleanvalue.- Specified by:
booleanValuein classItem
-
-