java.lang.Object
swim.structure.Form<T>
- Direct Known Subclasses:
ArrayForm
,BigIntegerForm
,BooleanForm
,ByteBufferForm
,ByteForm
,CharacterForm
,ClassForm
,CollectionForm
,DoubleForm
,FieldForm
,FloatForm
,IntegerForm
,ItemForm
,LongForm
,MapForm
,NumberForm
,PolyForm
,R2Form
,R3Form
,ShortForm
,StringForm
,TagForm
,TensorForm
,UnitForm
,UriForm
,UriPathForm
,UriPatternForm
,ValueForm
,Z2Form
,Z3Form
Transformation between a structurally typed
Item
and a nominally
typed Java object.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract T
Converts a structurally typeditem
into a nominally typed Java object.Converts a structurally typeditem
into a nominally typed Java object based on the provided prototypeobject
.static <T> Form<T>
Utility method to construct anArrayForm
.static final Form<BigInteger>
Utility method to receive a singletonBigIntegerForm
.Utility method to receive a singletonBooleanForm
.static <T> Form<T>
forBuiltin
(Class<?> type) Returns thetype
built-inForm
fortype
if it exists, andnull
if it does not.forByte()
Utility method to receive a singletonByteForm
.static Form<ByteBuffer>
Utility method to receive a singletonByteBufferForm
.Utility method to receive a singletonCharacterForm
.static <T> Form<T>
static <T> Form<T>
Returns aForm
fortype
againstscope
preferring built-inForms
toClassForm
constructions whenever possible.static <CC,
T> Form<CC> forCollection
(Class<?> type, Form<T> form) Utility method to construct aCollectionForm
.Utility method to receive a singletonDoubleForm
.forFloat()
Utility method to receive a singletonFloatForm
.Utility method to receive a singletonIntegerForm
.forItem()
Utility method to receive a singletonItemForm
.Utility method to construct aCollectionForm
where the underlying collection is of typeList<T>
.forLong()
Utility method to receive a singletonLongForm
.static <CC,
K, V> Form<CC> Utility method to construct aMapForm
.Utility method to receive a singletonNumberForm
.Utility method to construct aCollectionForm
where the underlying collection is of typeList<T>
.forShort()
Utility method to receive a singletonShortForm
.Utility method to receive a singletonStringForm
.forValue()
Utility method to receive a singletonValueForm
.static boolean
Returns whethertype
has a built-in base (i.e.abstract Item
Converts a nominally typed Javaobject
into its structurally typed equivalent.Converts a nominally typed Javaobject
into its structurally typed equivalent based on the provided prototypeitem
.tag()
Returns the key of the tag attribute that distinguishes structures of thisForm
; returnsnull
if thisForm
has no distinguishing tag attribute.abstract Class<?>
type()
Returns the reifiedClass
of typeT
.unit()
Returns a default–possiblynull
–value of typeT
.Returns a version of thisForm
with the givenunit
value.
-
Constructor Details
-
Form
public Form()
-
-
Method Details
-
tag
Returns the key of the tag attribute that distinguishes structures of thisForm
; returnsnull
if thisForm
has no distinguishing tag attribute. Used to accelerate distrcrimination of polymorphic structural types with nominal type hints. -
tag
-
unit
Returns a default–possiblynull
–value of typeT
. Used as the fallback return value whencoercing
an invalid structural value. -
unit
Returns a version of thisForm
with the givenunit
value. -
type
Returns the reifiedClass
of typeT
. -
mold
Converts a nominally typed Javaobject
into its structurally typed equivalent based on the provided prototypeitem
. The passed-initem
is assumed to be non-null
. The returnedItem
must never benull
. -
mold
Converts a nominally typed Javaobject
into its structurally typed equivalent. The returnedItem
must never benull
. -
cast
Converts a structurally typeditem
into a nominally typed Java object based on the provided prototypeobject
. The passed-initem
is assumed to be non-null
. The passed-in prototypeobject
may benull
. -
cast
Converts a structurally typeditem
into a nominally typed Java object. The passed-initem
is assumed to be non-null
. -
forByte
Utility method to receive a singletonByteForm
. -
forShort
Utility method to receive a singletonShortForm
. -
forInteger
Utility method to receive a singletonIntegerForm
. -
forLong
Utility method to receive a singletonLongForm
. -
forFloat
Utility method to receive a singletonFloatForm
. -
forDouble
Utility method to receive a singletonDoubleForm
. -
forCharacter
Utility method to receive a singletonCharacterForm
. -
forBoolean
Utility method to receive a singletonBooleanForm
. -
forBigInteger
Utility method to receive a singletonBigIntegerForm
. -
forNumber
Utility method to receive a singletonNumberForm
. -
forString
Utility method to receive a singletonStringForm
. -
forByteBuffer
Utility method to receive a singletonByteBufferForm
. -
forItem
Utility method to receive a singletonItemForm
. -
forValue
Utility method to receive a singletonValueForm
. -
forArray
Utility method to construct anArrayForm
. -
forCollection
Utility method to construct aCollectionForm
. -
forList
Utility method to construct aCollectionForm
where the underlying collection is of typeList<T>
. -
forSet
Utility method to construct aCollectionForm
where the underlying collection is of typeList<T>
. -
forMap
- Throws:
ClassCastException
- iftype
does not extendMap
-
forMap
Utility method to construct aMapForm
. -
isBuiltin
Returns whethertype
has a built-in base (i.e. is defined inswim.structure.form
and is not aCollectionForm
)Form
. -
forBuiltin
Returns thetype
built-inForm
fortype
if it exists, andnull
if it does not. -
forClass
Returns aForm
fortype
againstscope
preferring built-inForms
toClassForm
constructions whenever possible. -
forClass
-