Package org.ametys.plugins.repository
Class NodeIteratorIterable<A extends AmetysObject>
- java.lang.Object
-
- org.ametys.plugins.repository.NodeIteratorIterable<A>
-
- Type Parameters:
A
- the actual type ofAmetysObject
s.
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<A>
,AmetysObjectIterable<A>
public class NodeIteratorIterable<A extends AmetysObject> extends Object implements AmetysObjectIterable<A>
Implementation ofAmetysObjectIterable
based on a underlying JCRNodeIterator
.
Please note that this implementation only works with NodeIterators containing nodes actually bound to AmetysObjects.
If a node exists in the iterator and does not correspond to anAmetysObject
, anAmetysRepositoryException
will be thrown.
UnlessAmetysObjectIterator.skip(long)
is called on the underlying Iterator, results are buffered so that one may safely calliterator()
more than once, even if the underlyingNodeIterator
will be consumed only once.
IfAmetysObjectIterator.skip(long)
is called, any subsequent call toiterator()
will throw anIllegalStateException
.
-
-
Constructor Summary
Constructors Constructor Description NodeIteratorIterable(AmetysObjectResolver resolver, NodeIterator iterator, String parentPath, Session session)
Creates aNodeIteratorIterable
.
-
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 in this iterable.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
-
NodeIteratorIterable
public NodeIteratorIterable(AmetysObjectResolver resolver, NodeIterator iterator, String parentPath, Session session)
Creates aNodeIteratorIterable
.- Parameters:
resolver
- the applicationAmetysObjectResolver
.iterator
- the underlyingNodeIterator
.parentPath
- the parent path in the Ametys hierarchy of allAmetysObject
being returned.session
- the JCR Session corresponding to the specified NodeIterator
-
-
Method Detail
-
getSize
public long getSize()
Description copied from interface:AmetysObjectIterable
Returns the number of elements in this iterable. If this information is unavailable, returns -1.- Specified by:
getSize
in interfaceAmetysObjectIterable<A extends AmetysObject>
- Returns:
- a long
-
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
-
-