Class SerIteratorFactory

  • Direct Known Subclasses:
    GuavaSerIteratorFactory

    public class SerIteratorFactory
    extends Object
    A factory used to create wrappers around collection-like objects.
    • Field Detail

      • EMPTY_VALUE_TYPES

        public static final List<Class<?>> EMPTY_VALUE_TYPES
        An empty list of classes.
    • Constructor Detail

      • SerIteratorFactory

        public SerIteratorFactory()
    • Method Detail

      • create

        public SerIterator create​(Object value,
                                  MetaProperty<?> prop,
                                  Class<?> beanClass,
                                  boolean allowPrimitiveArrays)
        Creates an iterator wrapper for a meta-property value.
        Parameters:
        value - the possible collection-like object, not null
        prop - the meta-property defining the value, not null
        beanClass - the class of the bean, not the meta-property, for better generics, not null
        allowPrimitiveArrays - whether to allow primitive arrays
        Returns:
        the iterator, null if not a collection-like type
      • create

        public SerIterator create​(Object value,
                                  MetaProperty<?> prop,
                                  Class<?> beanClass)
        Creates an iterator wrapper for a meta-property value.
        Parameters:
        value - the possible collection-like object, not null
        prop - the meta-property defining the value, not null
        beanClass - the class of the bean, not the meta-property, for better generics, not null
        Returns:
        the iterator, null if not a collection-like type
      • createChild

        public SerIterator createChild​(Object value,
                                       SerIterator parent)
        Creates an iterator wrapper for a value retrieved from a parent iterator.

        Allows the parent iterator to define the child iterator using generic type information. This handles cases such as a List as the value in a Map.

        Parameters:
        value - the possible collection-like object, not null
        parent - the parent iterator, not null
        Returns:
        the iterator, null if not a collection-like type
      • defaultToObjectClass

        protected Class<?> defaultToObjectClass​(Class<?> type)
        Defaults input class to Object class.
        Parameters:
        type - the type, may be null
        Returns:
        the type, not null
      • createIterable

        public SerIterable createIterable​(String metaTypeDescription,
                                          JodaBeanSer settings,
                                          Map<String,​Class<?>> knownTypes)
        Creates an iterator wrapper for a meta-type description.
        Parameters:
        metaTypeDescription - the description of the collection type, not null
        settings - the settings object, not null
        knownTypes - the known types map, null if not using known type shortening
        Returns:
        the iterable, null if not a collection-like type
      • createIterable

        public SerIterable createIterable​(SerIterable iterable)
        Creates an iterator wrapper for a child where there are second level generic parameters.
        Parameters:
        iterable - the parent iterable, not null
        Returns:
        the iterable, null if not a collection-like type
      • createIterable

        public SerIterable createIterable​(MetaProperty<?> prop,
                                          Class<?> beanClass,
                                          boolean allowPrimitiveArrays)
        Creates an iterator wrapper for a meta-property value.
        Parameters:
        prop - the meta-property defining the value, not null
        beanClass - the class of the bean, not the meta-property, for better generics, not null
        allowPrimitiveArrays - whether to allow primitive arrays
        Returns:
        the iterable, null if not a collection-like type
      • createIterable

        public SerIterable createIterable​(MetaProperty<?> prop,
                                          Class<?> beanClass)
        Creates an iterator wrapper for a meta-property value.
        Parameters:
        prop - the meta-property defining the value, not null
        beanClass - the class of the bean, not the meta-property, for better generics, not null
        Returns:
        the iterable, null if not a collection-like type
      • list

        public static final SerIterable list​(Class<?> valueType,
                                             List<Class<?>> valueTypeTypes)
        Gets an iterable wrapper for List.
        Parameters:
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterable, not null
      • set

        public static final SerIterable set​(Class<?> valueType,
                                            List<Class<?>> valueTypeTypes)
        Gets an iterable wrapper for Set.
        Parameters:
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterable, not null
      • sortedSet

        public static final SerIterable sortedSet​(Class<?> valueType,
                                                  List<Class<?>> valueTypeTypes)
        Gets an iterable wrapper for SortedSet.
        Parameters:
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterable, not null
      • navigableSet

        public static final SerIterable navigableSet​(Class<?> valueType,
                                                     List<Class<?>> valueTypeTypes)
        Gets an iterable wrapper for NavigableSet.
        Parameters:
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterable, not null
      • collection

        public static final SerIterator collection​(Collection<?> coll,
                                                   Class<?> declaredType,
                                                   Class<?> valueType,
                                                   List<Class<?>> valueTypeTypes)
        Gets an iterator wrapper for Collection.
        Parameters:
        coll - the collection, not null
        declaredType - the declared type, not null
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterator, not null
      • map

        public static final SerIterable map​(Class<?> keyType,
                                            Class<?> valueType,
                                            List<Class<?>> valueTypeTypes)
        Gets an iterable wrapper for Map.
        Parameters:
        keyType - the value type, not null
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterable, not null
      • sortedMap

        public static final SerIterable sortedMap​(Class<?> keyType,
                                                  Class<?> valueType,
                                                  List<Class<?>> valueTypeTypes)
        Gets an iterable wrapper for SortedMap.
        Parameters:
        keyType - the value type, not null
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterable, not null
      • navigableMap

        public static final SerIterable navigableMap​(Class<?> keyType,
                                                     Class<?> valueType,
                                                     List<Class<?>> valueTypeTypes)
        Gets an iterable wrapper for NavigableMap.
        Parameters:
        keyType - the value type, not null
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterable, not null
      • map

        public static final SerIterator map​(Map<?,​?> map,
                                            Class<?> declaredType,
                                            Class<?> keyType,
                                            Class<?> valueType,
                                            List<Class<?>> valueTypeTypes)
        Gets an iterator wrapper for Map.
        Parameters:
        map - the collection, not null
        declaredType - the declared type, not null
        keyType - the value type, not null
        valueType - the value type, not null
        valueTypeTypes - the generic parameters of the value type
        Returns:
        the iterator, not null
      • array

        public static final SerIterable array​(Class<?> valueType)
        Gets an iterable wrapper for an object array.
        Parameters:
        valueType - the value type, not null
        Returns:
        the iterable, not null
      • array

        public static final SerIterator array​(Object[] array,
                                              Class<?> declaredType,
                                              Class<?> valueType)
        Gets an iterator wrapper for an object array.
        Parameters:
        array - the array, not null
        declaredType - the declared type, not null
        valueType - the value type, not null
        Returns:
        the iterator, not null