Class MapBackedEntityCollection<U extends java.util.Collection<T>,​T extends RawMapAware>

  • Type Parameters:
    U - Type of Collection (ie: List/Set)
    T - Type of Entity in the Collection

    public class MapBackedEntityCollection<U extends java.util.Collection<T>,​T extends RawMapAware>
    extends MapBackedCollection<java.util.Collection<T>,​T>
    For Collections of Entities
    • Constructor Detail

      • MapBackedEntityCollection

        public MapBackedEntityCollection​(java.util.Map sourceMap,
                                         java.lang.String property,
                                         java.util.Collection valueIfMissing,
                                         EntityInstantiator entityInstantiator)
        Construct a MapBackedEntityCollection with a certain property name and default value
        Parameters:
        sourceMap - Map to store the Collection value in
        property - Key name of the property
        valueIfMissing - value to set if missing
        entityInstantiator - function to use to instantiate a new entry in the collection
      • MapBackedEntityCollection

        public MapBackedEntityCollection​(java.util.Map sourceMap,
                                         java.lang.String property,
                                         EntityInstantiator entityInstantiator)
        Construct a MapBackedEntityCollection with a certain property name. The default value will be a new ArrayList
        Parameters:
        sourceMap - Map to store the Collection value in
        property - Key name of the property
        entityInstantiator - function to use to instantiate a new entry in the collection
    • Method Detail

      • toMap

        protected java.lang.Object toMap​(T o)
                                  throws com.legyver.core.exception.CoreException
        Return the internal map where the MapBackedEntityCollection is stored
        Specified by:
        toMap in class MapBackedCollection<java.util.Collection<T extends RawMapAware>,​T extends RawMapAware>
        Parameters:
        o - the object whose map will be returned
        Returns:
        the raw map for the passed in Object
        Throws:
        com.legyver.core.exception.CoreException - if there is a problem marshalling to/from JSON