java.lang.Object
swim.structure.Form<T>
swim.structure.form.ClassForm<T>
- All Implemented Interfaces:
Cloneable
For some
Class
, a transformation between a structurally typed
Item
and an instance of that Class
.
A Class
instance in Java can be completely described by its
Class
name, its field names, and its field
values. This, combined with the fact that some fields are more
important than others, gives rise to the following rules for transforming
objects into structured Items
:
- The String identifier for the
Class
, usually simply theClass
name or some function of it, is calledtag
. - Every field being considered is either a
member
or aheader
, with the latter reserved for "important" fields. - Every such field transforms to a
Slot
whose key is the name of the field and whose value is theItem
representation of the field. - The structural representation of every object is some
Record
unless the item isnull
, which always transforms intoExtant
. - The first entry in this
Record
is anAttr
whose key istag
and whose value is either:- A
Record
ofheaders
that were transformed intoSlots
via rule 3., or Extant
if thisClass
has no fields.
- A
- Every subsequent entry in the
Record
from rule 4. is amember
that was transformed into aSlot
via rule 3.
These rules can be directly inverted to transform Items
to objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConverts a structurally typeditem
into a nominally typed Java object.Converts a structurally typeditem
into a nominally typed Java object based on the provided prototypeobject
.clone()
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.Class<?>
type()
Returns the reifiedClass
of typeT
.unit()
Returns a default–possiblynull
–value of typeT
.Returns a version of thisForm
with the givenunit
value.Methods inherited from class swim.structure.Form
forArray, forBigInteger, forBoolean, forBuiltin, forByte, forByteBuffer, forCharacter, forClass, forClass, forCollection, forDouble, forFloat, forInteger, forItem, forList, forLong, forMap, forMap, forNumber, forSet, forShort, forString, forValue, isBuiltin
-
Constructor Details
-
ClassForm
-
-
Method Details
-
tag
Description copied from class:Form
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
Description copied from class:Form
-
unit
Description copied from class:Form
Returns a default–possiblynull
–value of typeT
. Used as the fallback return value whencoercing
an invalid structural value. -
unit
Description copied from class:Form
Returns a version of thisForm
with the givenunit
value. -
addHeader
-
putHeader
-
putHeader
-
putHeader
-
addMember
-
putMember
-
putMember
-
putMember
-
type
Description copied from class:Form
Returns the reifiedClass
of typeT
. -
mold
Description copied from class:Form
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
Description copied from class:Form
Converts a nominally typed Javaobject
into its structurally typed equivalent. The returnedItem
must never benull
. -
cast
Description copied from class:Form
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
Description copied from class:Form
Converts a structurally typeditem
into a nominally typed Java object. The passed-initem
is assumed to be non-null
. -
clone
-