Class Form<T>

    • Constructor Detail

      • Form

        public Form()
    • Method Detail

      • forByte

        public static Form<Byte> forByte()
        Utility method to receive a singleton ByteForm.
      • forShort

        public static Form<Short> forShort()
        Utility method to receive a singleton ShortForm.
      • forLong

        public static Form<Long> forLong()
        Utility method to receive a singleton LongForm.
      • forFloat

        public static Form<Float> forFloat()
        Utility method to receive a singleton FloatForm.
      • forDouble

        public static Form<Double> forDouble()
        Utility method to receive a singleton DoubleForm.
      • forNumber

        public static Form<Number> forNumber()
        Utility method to receive a singleton NumberForm.
      • forString

        public static Form<String> forString()
        Utility method to receive a singleton StringForm.
      • forItem

        public static Form<Item> forItem()
        Utility method to receive a singleton ItemForm.
      • forValue

        public static Form<Value> forValue()
        Utility method to receive a singleton ValueForm.
      • forArray

        public static <T> Form<T> forArray​(Class<?> type,
                                           Form<?> form)
        Utility method to construct an ArrayForm.
      • forCollection

        public static <CC,​T> Form<CC> forCollection​(Class<?> type,
                                                          Form<T> form)
        Utility method to construct a CollectionForm.
      • forList

        public static <T> Form<List<T>> forList​(Form<T> form)
        Utility method to construct a CollectionForm where the underlying collection is of type List<T>.
      • forSet

        public static <T> Form<Set<T>> forSet​(Form<T> form)
        Utility method to construct a CollectionForm where the underlying collection is of type List<T>.
      • forMap

        public static <K,​V> Form<Map<K,​V>> forMap​(Form<K> keyForm,
                                                              Form<V> valForm)
        Utility method to construct a MapForm.
      • isBuiltin

        public static boolean isBuiltin​(Class<?> type)
        Returns whether type has a built-in base (i.e. is defined in swim.structure.form and is not a CollectionForm) Form.
      • forBuiltin

        public static <T> Form<T> forBuiltin​(Class<?> type)
        Returns the type built-in Form for type if it exists, and null if it does not.
      • forClass

        public static <T> Form<T> forClass​(Class<?> type,
                                           PolyForm scope)
        Returns a Form for type against scope preferring built-in Forms to ClassForm constructions whenever possible.
      • forClass

        public static <T> Form<T> forClass​(Class<?> type)
        Returns a Form for type preferring built-in Forms to ClassForm constructions whenever possible.
      • tag

        public String tag()
        Returns the key of the tag attribute that distinguishes structures of this Form; returns null if this Form has no distinguishing tag attribute. Used to accelerate distrcrimination of polymorphic structural types with nominal type hints.
      • tag

        public Form<T> tag​(String tag)
        Returns a version of this Form that requires a head Attr with the given tag name.
      • unit

        public T unit()
        Returns a default–possibly null–value of type T. Used as the fallback return value when coercing an invalid structural value.
      • unit

        public Form<T> unit​(T unit)
        Returns a version of this Form with the given unit value.
      • type

        public abstract Class<?> type()
        Returns the reified Class of type T.
      • mold

        public Item mold​(T object,
                         Item item)
        Converts a nominally typed Java object into its structurally typed equivalent based on the provided prototype item. The passed-in item is assumed to be non-null. The returned Item must never be null.
      • mold

        public abstract Item mold​(T object)
        Converts a nominally typed Java object into its structurally typed equivalent. The returned Item must never be null.
      • cast

        public T cast​(Item item,
                      T object)
        Converts a structurally typed item into a nominally typed Java object based on the provided prototype object. The passed-in item is assumed to be non-null. The passed-in prototype object may be null.
      • cast

        public abstract T cast​(Item item)
        Converts a structurally typed item into a nominally typed Java object. The passed-in item is assumed to be non-null.