Package org.joda.beans.ser
Class SerIteratorFactory
- java.lang.Object
-
- org.joda.beans.ser.SerIteratorFactory
-
- Direct Known Subclasses:
GuavaSerIteratorFactory
public class SerIteratorFactory extends Object
A factory used to create wrappers around collection-like objects.
-
-
Field Summary
Fields Modifier and Type Field Description static List<Class<?>>EMPTY_VALUE_TYPESAn empty list of classes.static SerIteratorFactoryINSTANCESingleton instance.
-
Constructor Summary
Constructors Constructor Description SerIteratorFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SerIterablearray(Class<?> valueType)Gets an iterable wrapper for an object array.static SerIteratorarray(Object[] array, Class<?> declaredType, Class<?> valueType)Gets an iterator wrapper for an object array.static SerIteratorcollection(Collection<?> coll, Class<?> declaredType, Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterator wrapper forCollection.SerIteratorcreate(Object value, MetaProperty<?> prop, Class<?> beanClass)Creates an iterator wrapper for a meta-property value.SerIteratorcreate(Object value, MetaProperty<?> prop, Class<?> beanClass, boolean allowPrimitiveArrays)Creates an iterator wrapper for a meta-property value.SerIteratorcreateChild(Object value, SerIterator parent)Creates an iterator wrapper for a value retrieved from a parent iterator.SerIterablecreateIterable(String metaTypeDescription, JodaBeanSer settings, Map<String,Class<?>> knownTypes)Creates an iterator wrapper for a meta-type description.SerIterablecreateIterable(MetaProperty<?> prop, Class<?> beanClass)Creates an iterator wrapper for a meta-property value.SerIterablecreateIterable(MetaProperty<?> prop, Class<?> beanClass, boolean allowPrimitiveArrays)Creates an iterator wrapper for a meta-property value.SerIterablecreateIterable(SerIterable iterable)Creates an iterator wrapper for a child where there are second level generic parameters.protected Class<?>defaultToObjectClass(Class<?> type)Defaults input class to Object class.static SerIterablelist(Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterable wrapper forList.static SerIterablemap(Class<?> keyType, Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterable wrapper forMap.static SerIteratormap(Map<?,?> map, Class<?> declaredType, Class<?> keyType, Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterator wrapper forMap.static SerIterablenavigableMap(Class<?> keyType, Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterable wrapper forNavigableMap.static SerIterablenavigableSet(Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterable wrapper forNavigableSet.static SerIterableset(Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterable wrapper forSet.static SerIterablesortedMap(Class<?> keyType, Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterable wrapper forSortedMap.static SerIterablesortedSet(Class<?> valueType, List<Class<?>> valueTypeTypes)Gets an iterable wrapper forSortedSet.
-
-
-
Field Detail
-
INSTANCE
public static final SerIteratorFactory INSTANCE
Singleton instance.
-
-
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 nullprop- the meta-property defining the value, not nullbeanClass- the class of the bean, not the meta-property, for better generics, not nullallowPrimitiveArrays- 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 nullprop- the meta-property defining the value, not nullbeanClass- 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
Listas the value in aMap.- Parameters:
value- the possible collection-like object, not nullparent- 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 nullsettings- the settings object, not nullknownTypes- 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 nullbeanClass- the class of the bean, not the meta-property, for better generics, not nullallowPrimitiveArrays- 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 nullbeanClass- 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 forList.- Parameters:
valueType- the value type, not nullvalueTypeTypes- 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 forSet.- Parameters:
valueType- the value type, not nullvalueTypeTypes- 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 forSortedSet.- Parameters:
valueType- the value type, not nullvalueTypeTypes- 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 forNavigableSet.- Parameters:
valueType- the value type, not nullvalueTypeTypes- 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 forCollection.- Parameters:
coll- the collection, not nulldeclaredType- the declared type, not nullvalueType- the value type, not nullvalueTypeTypes- 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 forMap.- Parameters:
keyType- the value type, not nullvalueType- the value type, not nullvalueTypeTypes- 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 forSortedMap.- Parameters:
keyType- the value type, not nullvalueType- the value type, not nullvalueTypeTypes- 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 forNavigableMap.- Parameters:
keyType- the value type, not nullvalueType- the value type, not nullvalueTypeTypes- 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 forMap.- Parameters:
map- the collection, not nulldeclaredType- the declared type, not nullkeyType- the value type, not nullvalueType- the value type, not nullvalueTypeTypes- 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 nulldeclaredType- the declared type, not nullvalueType- the value type, not null- Returns:
- the iterator, not null
-
-