Package com.blackrook.archetext
Class ArcheTextValue
- java.lang.Object
-
- com.blackrook.archetext.ArcheTextValue
-
public final class ArcheTextValue extends Object
The values stored in anArcheTextObject
.- Author:
- Matthew Tropiano
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ArcheTextValue.Type
ArcheText value internal types.
-
Field Summary
Fields Modifier and Type Field Description static ArcheTextValue
NULL
Null value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ArcheTextValue
absolute()
Returns the absolute value of this value, returning a new one.ArcheTextValue
bitwiseNot()
Returns the bitwise "not" value of this value, returning a new one.ArcheTextValue
combineWith(Combinator combinator, ArcheTextValue source)
Combines this value with another and returns the result.ArcheTextValue
copy()
static <T> ArcheTextValue
create(T object)
Creates a new value.<T> T
createForType(String memberName, Class<T> type)
Converts this value to another Java object type.boolean
equals(ArcheTextValue other)
Equality test.boolean
equals(Object obj)
ArcheTextValue.Type
getType()
Object
getValue()
int
hashCode()
boolean
isNull()
Returns if this object is null-valued.ArcheTextValue
negate()
Negates the value of this value, returning a new one.ArcheTextValue
not()
Returns the logical "not" value of this value, returning a new one.ArcheTextValue
promoteTo(ArcheTextValue.Type promotionType)
Returns a new ArcheTextValue that is a promoted type from this one.String
toString()
-
-
-
Field Detail
-
NULL
public static final ArcheTextValue NULL
Null value.
-
-
Method Detail
-
create
public static <T> ArcheTextValue create(T object)
Creates a new value. Converts primitives and boxed primitives, strings, arrays, andSet
s, andMap
s, and objects.- Type Parameters:
T
- the object's type.- Parameters:
object
- the input object.- Returns:
- an
ArcheTextValue
to use inArcheTextObject
.
-
createForType
public <T> T createForType(String memberName, Class<T> type)
Converts this value to another Java object type.- Type Parameters:
T
- the return type.- Parameters:
memberName
- the name of this value, if a member of another object.type
- the type to convert to.- Returns:
- the converted type.
-
equals
public boolean equals(ArcheTextValue other)
Equality test.- Parameters:
other
- the other value.- Returns:
- true if equal, false if not.
-
copy
public ArcheTextValue copy()
- Returns:
- a deep copy of this value.
-
getType
public ArcheTextValue.Type getType()
- Returns:
- the value type.
-
getValue
public Object getValue()
- Returns:
- the value itself.
-
isNull
public boolean isNull()
Returns if this object is null-valued.- Returns:
- true if so, false if not.
-
combineWith
public ArcheTextValue combineWith(Combinator combinator, ArcheTextValue source)
Combines this value with another and returns the result.- Parameters:
combinator
- the combinator to use.source
- the source value to combine this with. Can be null forNULL
.- Returns:
- the new value.
-
promoteTo
public ArcheTextValue promoteTo(ArcheTextValue.Type promotionType)
Returns a new ArcheTextValue that is a promoted type from this one. No types can be promoted toArcheTextValue.Type.OBJECT
. If the same type is passed in, this object is returned.- Parameters:
promotionType
- the type to promote to.- Returns:
- the new, promoted value.
- Throws:
ArcheTextOperationException
- if the type is less than this one or not promotable.
-
negate
public ArcheTextValue negate()
Negates the value of this value, returning a new one. Only works for integers, floats, and strings (strings are set to lower case).- Returns:
- a new value.
- Throws:
ArcheTextOperationException
- if the current type is not a correct type.
-
not
public ArcheTextValue not()
Returns the logical "not" value of this value, returning a new one. Only works for booleans.- Returns:
- a new value.
- Throws:
ArcheTextOperationException
- if the current type is not a correct type.
-
bitwiseNot
public ArcheTextValue bitwiseNot()
Returns the bitwise "not" value of this value, returning a new one. Only works for booleans, integers, and floats.- Returns:
- a new value.
- Throws:
ArcheTextOperationException
- if the current type is not a correct type.
-
absolute
public ArcheTextValue absolute()
Returns the absolute value of this value, returning a new one. Only works for integers, floats, and strings (strings are set to upper case).- Returns:
- a new value.
- Throws:
ArcheTextOperationException
- if the current type is not a correct type.
-
-