Class SetBeanProvider

  • All Implemented Interfaces:
    BeanProvider

    public class SetBeanProvider
    extends CollectionBeanProvider

    A specialized CollectionBeanProvider implementation that creates a java.util.Set bean.

    The createCollection() method is implemented to create a concrete implementation of the java.util.Set interface. Depending on the ordered flag that can be passed to the constructor either a java.util.HashSet (if ordered is false) or a java.util.LinkedHashSet (if ordered is true) is created. In the latter case the set will remember the order of its elements.

    Implementation note: Objects of this class are immutable and thus can be shared between multiple threads.

    Version:
    $Id: SetBeanProvider.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • SetBeanProvider

        public SetBeanProvider​(Collection<Dependency> deps,
                               boolean ordered)
        Creates a new instance of SetBeanProvider and initializes it with the dependencies of its elements and the ordered flag.
        Parameters:
        deps - the dependencies representing the elements of the set
        ordered - a flag whether the set created should keep the order of its elements
        Throws:
        IllegalArgumentException - if the collection with the dependencies is null
    • Method Detail

      • isOrdered

        public boolean isOrdered()
        Returns the ordered flag. This flag determines the type of the collection created by this bean provider.
        Returns:
        the ordered flag
      • createCollection

        protected Collection<Object> createCollection​(int size)
        Creates the collection managed by this bean provider. This implementation will return an implementation of the java.util.Set interface (the concrete type depends on the ordered property.
        Specified by:
        createCollection in class CollectionBeanProvider
        Parameters:
        size - the size of the collection
        Returns:
        a new instance of the collection managed by this bean provider