COLLECTION - is the generic Collection-type.public interface CollectionFactory<COLLECTION extends Collection>
Collections. It allows to abstract from Collection
implementations. Collection instance can be used for different purposes such as a set or a list or with different aspects
such as a thread-safe collection. If you write a generic component different users of that component may expect
different aspects of your component and therefore the underlying Collection. inject an instance of this interface to
override the default, your code will increase usability. CollectionFactory rather than a Collection instance to the constructor?Class to Class<?>) you would break compatibility of the users of your code.
Additionally you may want to express that the Collection should be empty and/or NOT shared with others.
Anyways the interface can obviously NOT guarantee this.| Modifier and Type | Method and Description |
|---|---|
<E> Collection<E> |
create()
This method creates a new
Collection instance. |
<E> Collection<E> |
create(int capacity)
This method creates a new
Collection instance with the given initial capacity. |
COLLECTION |
createGeneric()
This method creates a new instance of the generic
Collection type <COLLECTION>. |
COLLECTION |
createGeneric(int capacity)
This method creates a new instance of the generic
Collection type <COLLECTION> with the given
initial capacity. |
Class<? extends COLLECTION> |
getCollectionImplementation()
This method gets the implementation of the
collection-interface used by this
factory. |
Class<COLLECTION> |
getCollectionInterface()
This method gets the interface of the
Collection managed by this factory. |
Class<COLLECTION> getCollectionInterface()
Collection managed by this factory.Collection interface.Class<? extends COLLECTION> getCollectionImplementation()
collection-interface used by this
factory.Collection implementation.COLLECTION createGeneric()
Collection type <COLLECTION>.COLLECTION createGeneric(int capacity)
Collection type <COLLECTION> with the given
initial capacity.capacity - is the initial capacity of the collection.<E> Collection<E> create()
Collection instance. Collection can NOT be bound to the generic type <COLLECTION> because of limitations in Java's
generic type system. You need to work on the actual sub-interface (e.g. ListFactory) to get the proper
result type.E - the type of elements contained in the collection.createGeneric()<E> Collection<E> create(int capacity)
Collection instance with the given initial capacity. Collection can NOT be bound to the generic type <COLLECTION> because of limitations in Java's
generic type system. You need to work on the actual sub-interface (e.g. ListFactory) to get the proper
result type.E - the type of elements contained in the collection.capacity - is the initial capacity of the collection.createGeneric(int)Copyright © 2001–2016 mmm-Team. All rights reserved.