Package org.ametys.plugins.repository
Class CollatingUniqueAmetysObjectIterable<A extends AmetysObject>
java.lang.Object
org.ametys.plugins.repository.CollatingUniqueAmetysObjectIterable<A>
- Type Parameters:
A- the actual type ofAmetysObjects.
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<A>,AmetysObjectIterable<A>
public class CollatingUniqueAmetysObjectIterable<A extends AmetysObject>
extends Object
implements AmetysObjectIterable<A>
Implementation of a
AmetysObjectIterable based on a list of others AmetysObjectIterable,
which returns the objects in a given order, removing duplicates.
Each iterable must be sorted.
The "collating" part is copied and adapted from Apache Commons Lang's CollatingIterator class.-
Constructor Summary
ConstructorsConstructorDescriptionCollatingUniqueAmetysObjectIterable(List<AmetysObjectIterable<A>> iterables, Comparator<A> comparator) Creates aCollatingUniqueAmetysObjectIterable. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the associated resources.
AnAmetysObjectIterablemust NOT be closed if any of the containedAmetysObjectis still in use.longgetSize()Returns the number of elements only if there is only oneAmetysObjectIterablein the list.iterator()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ametys.plugins.repository.AmetysObjectIterable
spliterator, stream
-
Constructor Details
-
CollatingUniqueAmetysObjectIterable
public CollatingUniqueAmetysObjectIterable(List<AmetysObjectIterable<A>> iterables, Comparator<A> comparator) Creates aCollatingUniqueAmetysObjectIterable.- Parameters:
iterables- a list ofAmetysObjectIterable.comparator- a comparator.
-
-
Method Details
-
getSize
Returns the number of elements only if there is only oneAmetysObjectIterablein the list. If there is more than 1AmetysObjectIterable, this always returns -1.- Specified by:
getSizein interfaceAmetysObjectIterable<A extends AmetysObject>- Returns:
- The size of the unique iterable or -1 if there is more than 1 iterable.
-
iterator
- Specified by:
iteratorin interfaceAmetysObjectIterable<A extends AmetysObject>- Specified by:
iteratorin interfaceIterable<A extends AmetysObject>
-
close
Description copied from interface:AmetysObjectIterableClose the associated resources.
AnAmetysObjectIterablemust NOT be closed if any of the containedAmetysObjectis still in use.- Specified by:
closein interfaceAmetysObjectIterable<A extends AmetysObject>- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-