- java.lang.Object
-
- swim.structure.Item
-
- swim.structure.Value
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Value
absent()
void
alias()
Item
and(Item that)
Value
and(Value that)
Item
bitwiseAnd(Item that)
Value
bitwiseAnd(Value that)
Value
bitwiseNot()
Item
bitwiseOr(Item that)
Value
bitwiseOr(Value that)
Item
bitwiseXor(Item that)
Value
bitwiseXor(Value that)
Value
body()
boolean
booleanValue()
Converts thisValue
into a primitiveboolean
value, if possible.boolean
booleanValue(boolean orElse)
Converts thisValue
into a primitiveboolean
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitiveboolean
value.Value
branch()
static Builder<Item,Value>
builder()
byte
byteValue()
Converts thisValue
into a primitivebyte
value, if possible.byte
byteValue(byte orElse)
Converts thisValue
into a primitivebyte
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivebyte
value.char
charValue()
Converts thisValue
into a primitivechar
value, if possible.char
charValue(char orElse)
Converts thisValue
into a primitivechar
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivechar
value.Value
commit()
Item
conditional(Item thenTerm, Item elseTerm)
Value
conditional(Value thenTerm, Value elseTerm)
boolean
contains(Item item)
Returnstrue
if thisValue
is aRecord
that has a member equal toitem
; otherwise returnsfalse
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has no member equal toitem
.boolean
containsKey(String key)
boolean
containsKey(Value key)
boolean
containsValue(Value value)
Item
divide(Item that)
Value
divide(Value that)
double
doubleValue()
Converts thisValue
into a primitivedouble
value, if possible.double
doubleValue(double orElse)
Converts thisValue
into a primitivedouble
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivedouble
value.static Value
empty()
Item
eq(Item that)
Value
eq(Value that)
static Value
extant()
Value
flattened()
float
floatValue()
Converts thisValue
into a primitivefloat
value, if possible.float
floatValue(float orElse)
Converts thisValue
into a primitivefloat
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivefloat
value.static Value
fromObject(Object object)
Item
ge(Item that)
Value
ge(Value that)
Value
get(String key)
Value
get(Value key)
Value
getAttr(String key)
Value
getAttr(Text key)
Field
getField(String key)
Field
getField(Value key)
Item
getItem(int index)
Value
getSlot(String key)
Value
getSlot(Value key)
Item
gt(Item that)
Value
gt(Value that)
Item
head()
Value
header(String tag)
Returns the value of the first member of thisValue
, if thisValue
is aRecord
, and its first member is anAttr
whosekey
string is equal totag
; otherwise returnsAbsent
if thisValue
is not aRecord
, or if thisValue
is aRecord
whose first member is not anAttr
, or if thisValue
is aRecord
whose first member is anAttr
whosekey
does not equal thetag
.Record
headers(String tag)
Returns theunflattened
header
of thisValue
, if thisValue
is aRecord
, and its first member is anAttr
whosekey
string is equal totag
; otherwise returnsnull
.BigInteger
integerValue()
Converts thisValue
into aBigInteger
value, if possible.BigInteger
integerValue(BigInteger orElse)
Converts thisValue
into aBigInteger
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into aBigInteger
value.int
intValue()
Converts thisValue
into a primitiveint
value, if possible.int
intValue(int orElse)
Converts thisValue
into a primitiveint
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitiveint
value.Value
inverse()
boolean
isAliased()
boolean
isDefined()
boolean
isDefinite()
Returnstrue
if thisValue
is not one of: an emptyRecord
,False
,Extant
, orAbsent
.boolean
isDistinct()
boolean
isMutable()
Value
key()
boolean
keyEquals(Object key)
Value
lambda(Value template)
Item
le(Item that)
Value
le(Value that)
int
length()
Returns the number of members contained in thisValue
, if thisValue
is aRecord
; otherwise returns0
if thisValue
is not aRecord
.long
longValue()
Converts thisValue
into a primitivelong
value, if possible.long
longValue(long orElse)
Converts thisValue
into a primitivelong
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivelong
value.Item
lt(Item that)
Value
lt(Value that)
Item
minus(Item that)
Value
minus(Value that)
Item
modulo(Item that)
Value
modulo(Value that)
Item
ne(Item that)
Value
ne(Value that)
Value
negative()
Value
not()
Number
numberValue()
Converts thisValue
into aNumber
object, if possible.Number
numberValue(Number orElse)
Converts thisValue
into aNumber
object, if possible; otherwise returnsorElse
if thisValue
can't be converted into aNumber
object.Item
or(Item that)
Value
or(Value that)
Item
plus(Item that)
Value
plus(Value that)
Value
positive()
Value
removed(String key)
Value
removed(Value key)
short
shortValue()
Converts thisValue
into a primitiveshort
value, if possible.short
shortValue(short orElse)
Converts thisValue
into a primitiveshort
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitiveshort
value.String
stringValue()
Converts thisValue
into aString
value, if possible.String
stringValue(String orElse)
Converts thisValue
into aString
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into astring
value.String
tag()
Returns thekey
string of the first member of thisValue
, if thisValue
is aRecord
, and its first member is anAttr
; otherwise returnsnull
if thisValue
is not aRecord
, or if thisValue
is aRecord
whose first member is not anAttr
.Record
tail()
Returns a view of all but the first member of thisValue
, if thisValue
is a non-emptyRecord
; otherwise returns an emptyRecord
if thisValue
is not aRecord
, of if thisValue
is itself an emptyRecord
.Value
target()
Item
times(Item that)
Value
times(Value that)
Value
toValue()
Always returnsthis
because everyValue
is its own value component.Record
unflattened()
-
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
-
isDistinct
public boolean isDistinct()
- Specified by:
isDistinct
in classItem
-
isDefinite
public boolean isDefinite()
Returnstrue
if thisValue
is not one of: an emptyRecord
,False
,Extant
, orAbsent
.- Specified by:
isDefinite
in classItem
-
toValue
public final Value toValue()
Always returnsthis
because everyValue
is its own value component.
-
tag
public String tag()
Returns thekey
string of the first member of thisValue
, if thisValue
is aRecord
, and its first member is anAttr
; otherwise returnsnull
if thisValue
is not aRecord
, or if thisValue
is aRecord
whose first member is not anAttr
.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.
-
target
public Value target()
Returns theflattened
members of thisValue
after all attributes have been removed, if thisValue
is aRecord
; otherwise returnsthis
if thisValue
is not aRecord
.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.
-
flattened
public Value flattened()
Returns the sole member of thisValue
, if thisValue
is aRecord
with exactly one member, and its member is aValue
; returnsExtant
if thisValue
is an emptyRecord
; otherwise returnsthis
if thisValue
is aRecord
with more than one member, or if thisValue
is not aRecord
.Used to convert a unary
Record
into its memberValue
. Facilitates writing code that treats a unaryRecord
equivalently to a bareValue
.
-
unflattened
public Record unflattened()
Returnsthis
if thisValue
is aRecord
; returns aRecord
containing just thisValue
, if thisValue
isdistinct
; otherwise returns an emptyRecord
if thisValue
isExtant
orAbsent
. Facilitates writing code that treats a bareValue
equivalently to a unaryRecord
.- Specified by:
unflattened
in classItem
-
header
public Value header(String tag)
Returns the value of the first member of thisValue
, if thisValue
is aRecord
, and its first member is anAttr
whosekey
string is equal totag
; otherwise returnsAbsent
if thisValue
is not aRecord
, or if thisValue
is aRecord
whose first member is not anAttr
, or if thisValue
is aRecord
whose first member is anAttr
whosekey
does not equal thetag
.Used to conditionally get the value of the head
Attr
of a structure, if and only if the key string of the headAttr
is equal to thetag
. Can be used to check if a structure might conform to a nominal type namedtag
, while simultaneously getting the value of thetag
attribute.
-
headers
public Record headers(String tag)
Returns theunflattened
header
of thisValue
, if thisValue
is aRecord
, and its first member is anAttr
whosekey
string is equal totag
; otherwise returnsnull
.The
headers
of thetag
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.
-
head
public Item head()
-
tail
public Record tail()
Returns a view of all but the first member of thisValue
, if thisValue
is a non-emptyRecord
; otherwise returns an emptyRecord
if thisValue
is not aRecord
, of if thisValue
is itself an emptyRecord
.
-
body
public Value body()
-
length
public int length()
Returns the number of members contained in thisValue
, if thisValue
is aRecord
; otherwise returns0
if thisValue
is not aRecord
.
-
contains
public boolean contains(Item item)
Returnstrue
if thisValue
is aRecord
that has a member equal toitem
; otherwise returnsfalse
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has no member equal toitem
.
-
containsKey
public boolean containsKey(Value key)
Returnstrue
if thisValue
is aRecord
that has aField
member with a key that is equal to the givenkey
; otherwise returnsfalse
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has noField
member with a key equal to the givenkey
.- Specified by:
containsKey
in classItem
-
containsKey
public boolean containsKey(String key)
Returnstrue
if thisValue
is aRecord
that has aField
with aText
key whose string value is equal to the givenkey
; otherwise returnsfalse
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has noField
member with aText
key whose string value equals the givenkey
. Equivalent tocontainsKey(Value)
, but avoids boxing thekey
string into aText
value.- Specified by:
containsKey
in classItem
-
containsValue
public boolean containsValue(Value value)
Returnstrue
if thisValue
is aRecord
that has aField
member with a value that is equal to the givenvalue
; otherwise returnsfalse
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has noField
member with a value equal to the givenvalue
.- Specified by:
containsValue
in classItem
-
get
public Value get(String key)
Returns the value of the lastField
member of thisValue
with aText
key whose string value is equal to the givenkey
; returnsAbsent
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has noField
member with aText
key whose string value equals the givenkey
. Equivalent toget(Value)
, but avoids boxing thekey
string into aText
value.
-
getAttr
public Value getAttr(String key)
Returns the value of the lastAttr
member of thisValue
with aText
key whose string value is equal to the givenkey
; returnsAbsent
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has noAttr
member with aText
key whose string value equals the givenkey
. Equivalent togetAttr(Text)
, but avoids boxing thekey
string into aText
value.
-
getSlot
public Value getSlot(String key)
Returns the value of the lastSlot
member of thisValue
with aText
key whose string value is equal to the givenkey
; returnsAbsent
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has noSlot
member with aText
key whose string value equals the givenkey
. Equivalent togetSlot(Value)
, but avoids boxing thekey
string into aText
value.
-
getField
public Field getField(String key)
Returns the lastField
member of thisValue
with aText
key whose string value is equal to the givenkey
; returnsnull
if thisValue
is not aRecord
, or if thisValue
is aRecord
, but has noField
member with aText
key whose string value equals the givenkey
. Equivalent togetField(Value)
, but avoids boxing thekey
string into aText
value.
-
getItem
public Item getItem(int index)
-
conditional
public Item conditional(Item thenTerm, Item elseTerm)
- Specified by:
conditional
in classItem
-
bitwiseXor
public Item bitwiseXor(Item that)
- Specified by:
bitwiseXor
in classItem
-
bitwiseAnd
public Item bitwiseAnd(Item that)
- Specified by:
bitwiseAnd
in classItem
-
bitwiseNot
public Value bitwiseNot()
- Specified by:
bitwiseNot
in classItem
-
stringValue
public String stringValue()
Converts thisValue
into aString
value, if possible.- Specified by:
stringValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into aString
value.
-
stringValue
public String stringValue(String orElse)
Converts thisValue
into aString
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into astring
value.- Specified by:
stringValue
in classItem
-
byteValue
public byte byteValue()
Converts thisValue
into a primitivebyte
value, if possible.- Specified by:
byteValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into a primitivebyte
value.
-
byteValue
public byte byteValue(byte orElse)
Converts thisValue
into a primitivebyte
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivebyte
value.
-
shortValue
public short shortValue()
Converts thisValue
into a primitiveshort
value, if possible.- Specified by:
shortValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into a primitiveshort
value.
-
shortValue
public short shortValue(short orElse)
Converts thisValue
into a primitiveshort
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitiveshort
value.- Specified by:
shortValue
in classItem
-
intValue
public int intValue()
Converts thisValue
into a primitiveint
value, if possible.- Specified by:
intValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into a primitiveint
value.
-
intValue
public int intValue(int orElse)
Converts thisValue
into a primitiveint
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitiveint
value.
-
longValue
public long longValue()
Converts thisValue
into a primitivelong
value, if possible.- Specified by:
longValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into a primitivelong
value.
-
longValue
public long longValue(long orElse)
Converts thisValue
into a primitivelong
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivelong
value.
-
floatValue
public float floatValue()
Converts thisValue
into a primitivefloat
value, if possible.- Specified by:
floatValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into a primitivefloat
value.
-
floatValue
public float floatValue(float orElse)
Converts thisValue
into a primitivefloat
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivefloat
value.- Specified by:
floatValue
in classItem
-
doubleValue
public double doubleValue()
Converts thisValue
into a primitivedouble
value, if possible.- Specified by:
doubleValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into a primitivedouble
value.
-
doubleValue
public double doubleValue(double orElse)
Converts thisValue
into a primitivedouble
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivedouble
value.- Specified by:
doubleValue
in classItem
-
integerValue
public BigInteger integerValue()
Converts thisValue
into aBigInteger
value, if possible.- Specified by:
integerValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into aBigInteger
value.
-
integerValue
public BigInteger integerValue(BigInteger orElse)
Converts thisValue
into aBigInteger
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into aBigInteger
value.- Specified by:
integerValue
in classItem
-
numberValue
public Number numberValue()
Converts thisValue
into aNumber
object, if possible.- Specified by:
numberValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into aNumber
object.
-
numberValue
public Number numberValue(Number orElse)
Converts thisValue
into aNumber
object, if possible; otherwise returnsorElse
if thisValue
can't be converted into aNumber
object.- Specified by:
numberValue
in classItem
-
charValue
public char charValue()
Converts thisValue
into a primitivechar
value, if possible.- Specified by:
charValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into a primitivechar
value.
-
charValue
public char charValue(char orElse)
Converts thisValue
into a primitivechar
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitivechar
value.
-
booleanValue
public boolean booleanValue()
Converts thisValue
into a primitiveboolean
value, if possible.- Specified by:
booleanValue
in classItem
- Throws:
UnsupportedOperationException
- if thisValue
can't be converted into a primitiveboolean
value.
-
booleanValue
public boolean booleanValue(boolean orElse)
Converts thisValue
into a primitiveboolean
value, if possible; otherwise returnsorElse
if thisValue
can't be converted into a primitiveboolean
value.- Specified by:
booleanValue
in classItem
-
empty
public static Value empty()
-
extant
public static Value extant()
-
absent
public static Value absent()
-
-