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 aAmetysObjectIterable
based on a list of othersAmetysObjectIterable
, 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
Constructors Constructor Description CollatingUniqueAmetysObjectIterable(List<AmetysObjectIterable<A>> iterables, Comparator<A> comparator)
Creates aCollatingUniqueAmetysObjectIterable
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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.AmetysObjectIterator<A>
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 Detail
-
CollatingUniqueAmetysObjectIterable
public CollatingUniqueAmetysObjectIterable(List<AmetysObjectIterable<A>> iterables, Comparator<A> comparator)
Creates aCollatingUniqueAmetysObjectIterable
.- Parameters:
iterables
- a list ofAmetysObjectIterable
.comparator
- a comparator.
-
-
Method Detail
-
getSize
public long 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
public AmetysObjectIterator<A> iterator()
- Specified by:
iterator
in interfaceAmetysObjectIterable<A extends AmetysObject>
- Specified by:
iterator
in interfaceIterable<A extends AmetysObject>
-
close
public void 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
-
-