public class EagerForeignCollection<T,ID> extends BaseForeignCollection<T,ID> implements CloseableWrappedIterable<T>, Serializable
ForeignCollectionField annotation when an
object is refreshed or queried (i.e. not created).dao| Constructor and Description |
|---|
EagerForeignCollection(Dao<T,ID> dao,
Object parent,
Object parentId,
FieldType foreignFieldType,
String orderColumn,
boolean orderAscending)
WARNING: The user should not be calling this constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T data)
Add an element to the collection.
|
boolean |
addAll(Collection<? extends T> collection)
Add the collection of elements to this collection.
|
void |
close()
This will close the last iterator returned by the
Iterable.iterator() method. |
CloseableIterator<T> |
closeableIterator()
Returns an iterator over a set of elements of type T which can be closed.
|
CloseableIterator<T> |
closeableIterator(int flags)
Same as
ForeignCollection.iterator(int). |
void |
closeLastIterator()
This will close the last iterator returned by the
Collection.iterator() method. |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object obj)
This is just a call to the equals method of the internal results list.
|
CloseableWrappedIterable<T> |
getWrappedIterable()
This makes a one time use iterable class that can be closed afterwards.
|
CloseableWrappedIterable<T> |
getWrappedIterable(int flags)
Like
ForeignCollection.getWrappedIterable() but while specifying flags for the results. |
int |
hashCode()
This is just a call to the hashcode method of the internal results list.
|
boolean |
isEager()
Returns true if this an eager collection otherwise false.
|
boolean |
isEmpty() |
CloseableIterator<T> |
iterator() |
CloseableIterator<T> |
iterator(int flags)
Like
Collection.iterator() but while specifying flags for the results. |
CloseableIterator<T> |
iteratorThrow()
Like
Collection.iterator() but returns a closeable iterator instead and can throw a SQLException. |
CloseableIterator<T> |
iteratorThrow(int flags)
Like
ForeignCollection.iteratorThrow() but while specifying flags for the results. |
int |
refreshAll()
Call to refresh on all of the items currently in the collection with the database.
|
int |
refreshCollection()
This re-issues the query that initially built the collection replacing any underlying result collection with a
new one build from the database.
|
boolean |
remove(Object data)
Remove the item from the collection and the associated database table.
|
boolean |
removeAll(Collection<?> collection)
Remove the items in the collection argument from the foreign collection and the associated database table.
|
boolean |
retainAll(Collection<?> collection)
Uses the iterator to run through the dao and retain only the items that are in the passed in collection.
|
int |
size() |
Object[] |
toArray() |
<E> E[] |
toArray(E[] array) |
int |
updateAll()
Update all of the items currently in the collection with the database.
|
clear, getDao, getPreparedQuery, refresh, updatepublic EagerForeignCollection(Dao<T,ID> dao, Object parent, Object parentId, FieldType foreignFieldType, String orderColumn, boolean orderAscending) throws SQLException
Dao.assignEmptyForeignCollection(Object, String) or Dao.getEmptyForeignCollection(String) methods
instead.SQLExceptionpublic CloseableIterator<T> iterator()
public CloseableIterator<T> iterator(int flags)
ForeignCollectionCollection.iterator() but while specifying flags for the results. This is necessary with certain
database types. The resultFlags could be something like ResultSet.TYPE_SCROLL_INSENSITIVE or other values.iterator in interface ForeignCollection<T>public CloseableIterator<T> closeableIterator()
CloseableIterablecloseableIterator in interface CloseableIterable<T>public CloseableIterator<T> closeableIterator(int flags)
ForeignCollectionForeignCollection.iterator(int).closeableIterator in interface ForeignCollection<T>public CloseableIterator<T> iteratorThrow()
ForeignCollectionCollection.iterator() but returns a closeable iterator instead and can throw a SQLException.iteratorThrow in interface ForeignCollection<T>public CloseableIterator<T> iteratorThrow(int flags)
ForeignCollectionForeignCollection.iteratorThrow() but while specifying flags for the results. This is necessary with certain database
types. The resultFlags could be something like ResultSet.TYPE_SCROLL_INSENSITIVE or other values.iteratorThrow in interface ForeignCollection<T>public CloseableWrappedIterable<T> getWrappedIterable()
ForeignCollectionCloseableWrappedIterable but multiple threads can each call this to get their own closeable iterable.getWrappedIterable in interface ForeignCollection<T>public CloseableWrappedIterable<T> getWrappedIterable(int flags)
ForeignCollectionForeignCollection.getWrappedIterable() but while specifying flags for the results. This is necessary with certain
database types. The resultFlags could be something like ResultSet.TYPE_SCROLL_INSENSITIVE or other values.getWrappedIterable in interface ForeignCollection<T>public void close()
CloseableWrappedIterableIterable.iterator() method.close in interface CloseableWrappedIterable<T>close in interface Closeableclose in interface AutoCloseablepublic void closeLastIterator()
ForeignCollectionCollection.iterator() method.
NOTE: For lazy collections, this is not reentrant. If multiple threads are getting iterators from a lazy
collection from the same object then you should use ForeignCollection.getWrappedIterable() to get a reentrant wrapped
iterable for each thread instead.
closeLastIterator in interface ForeignCollection<T>public boolean isEager()
ForeignCollectionisEager in interface ForeignCollection<T>public int size()
size in interface Collection<T>public boolean isEmpty()
isEmpty in interface Collection<T>public boolean contains(Object o)
contains in interface Collection<T>public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>public Object[] toArray()
toArray in interface Collection<T>public <E> E[] toArray(E[] array)
toArray in interface Collection<T>public boolean add(T data)
BaseForeignCollectionadd in interface ForeignCollection<T>add in interface Collection<T>add in class BaseForeignCollection<T,ID>Collection.add(Object)public boolean addAll(Collection<? extends T> collection)
BaseForeignCollectionaddAll in interface Collection<T>addAll in class BaseForeignCollection<T,ID>public boolean remove(Object data)
BaseForeignCollectionremove in interface Collection<T>remove in class BaseForeignCollection<T,ID>public boolean removeAll(Collection<?> collection)
BaseForeignCollectionremoveAll in interface Collection<T>removeAll in class BaseForeignCollection<T,ID>public boolean retainAll(Collection<?> collection)
BaseForeignCollectionretainAll in interface Collection<T>retainAll in class BaseForeignCollection<T,ID>public int updateAll()
throws SQLException
ForeignCollectionupdateAll in interface ForeignCollection<T>SQLExceptionpublic int refreshAll()
throws SQLException
ForeignCollectionForeignCollection.refreshCollection().refreshAll in interface ForeignCollection<T>SQLExceptionpublic int refreshCollection()
throws SQLException
ForeignCollectionrefreshCollection in interface ForeignCollection<T>SQLExceptionpublic boolean equals(Object obj)
equals in interface Collection<T>equals in class Objectpublic int hashCode()
hashCode in interface Collection<T>hashCode in class ObjectThis documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.