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 ofAmetysObject
s.
- 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
ConstructorDescriptionCollatingUniqueAmetysObjectIterable
(List<AmetysObjectIterable<A>> iterables, Comparator<A> comparator) Creates aCollatingUniqueAmetysObjectIterable
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the associated resources.
AnAmetysObjectIterable
must NOT be closed if any of the containedAmetysObject
is still in use.long
getSize()
Returns the number of elements only if there is only oneAmetysObjectIterable
in the list.iterator()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 oneAmetysObjectIterable
in the list. If there is more than 1AmetysObjectIterable
, this always returns -1.- Specified by:
getSize
in interfaceAmetysObjectIterable<A extends AmetysObject>
- Returns:
- The size of the unique iterable or -1 if there is more than 1 iterable.
-
iterator
- Specified by:
iterator
in interfaceAmetysObjectIterable<A extends AmetysObject>
- Specified by:
iterator
in interfaceIterable<A extends AmetysObject>
-
close
Description copied from interface:AmetysObjectIterable
Close the associated resources.
AnAmetysObjectIterable
must NOT be closed if any of the containedAmetysObject
is still in use.- Specified by:
close
in interfaceAmetysObjectIterable<A extends AmetysObject>
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-