Package de.bwaldvogel.mongo.backend
Class AbstractMongoCollection<P>
- java.lang.Object
-
- de.bwaldvogel.mongo.backend.AbstractMongoCollection<P>
-
- All Implemented Interfaces:
MongoCollection<P>
public abstract class AbstractMongoCollection<P> extends java.lang.Object implements MongoCollection<P>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringidField
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMongoCollection(MongoDatabase database, java.lang.String collectionName, java.lang.String idField)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDocument(Document document)protected abstract PaddDocumentInternal(Document document)voidaddIndex(Index<P> index)protected static java.lang.Iterable<Document>applySkipAndLimit(java.util.List<Document> documents, int numberToSkip, int numberToReturn)intcount(Document query, int skip, int limit)intdeleteDocuments(Document selector, int limit)protected static DocumentComparatorderiveComparator(Document orderBy)protected booleandocumentMatchesQuery(Document document, Document query)voiddrop()voiddropIndex(java.lang.String indexName)DocumentfindAndModify(Document query)protected PfindDocumentPosition(Document document)java.lang.StringgetCollectionName()MongoDatabasegetDatabase()protected abstract intgetDataSize()protected abstract DocumentgetDocument(P position)intgetNumIndexes()DocumentgetStats()DocumenthandleDistinct(Document query)java.lang.Iterable<Document>handleQuery(Document queryObject, int numberToSkip, int numberToReturn, Document fieldSelector)protected abstract voidhandleUpdate(P position, Document oldDocument, Document newDocument)voidinsertDocuments(java.util.List<Document> documents)protected static booleanisNaturalDescending(Document orderBy)protected abstract java.lang.Iterable<Document>matchDocuments(Document query, Document orderBy, int numberToSkip, int numberToReturn)protected java.lang.Iterable<Document>matchDocuments(Document query, java.lang.Iterable<P> positions, Document orderBy, int numberToSkip, int numberToReturn)voidremoveDocument(Document document)protected abstract voidremoveDocument(P position)voidrenameTo(MongoDatabase newDatabase, java.lang.String newCollectionName)protected voidsortDocumentsInMemory(java.util.List<Document> documents, Document orderBy)protected abstract java.util.stream.Stream<DocumentWithPosition<P>>streamAllDocumentsWithPosition()java.lang.StringtoString()protected abstract voidupdateDataSize(int sizeDelta)DocumentupdateDocuments(Document selector, Document updateQuery, ArrayFilters arrayFilters, boolean isMulti, boolean isUpsert)Documentvalidate()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.bwaldvogel.mongo.MongoCollection
count, getDatabaseName, getFullName, handleQuery, handleQuery, handleQueryAsStream, isEmpty, queryAll, queryAllAsStream
-
-
-
-
Constructor Detail
-
AbstractMongoCollection
protected AbstractMongoCollection(MongoDatabase database, java.lang.String collectionName, java.lang.String idField)
-
-
Method Detail
-
sortDocumentsInMemory
protected void sortDocumentsInMemory(java.util.List<Document> documents, Document orderBy)
-
matchDocuments
protected abstract java.lang.Iterable<Document> matchDocuments(Document query, Document orderBy, int numberToSkip, int numberToReturn)
-
matchDocuments
protected java.lang.Iterable<Document> matchDocuments(Document query, java.lang.Iterable<P> positions, Document orderBy, int numberToSkip, int numberToReturn)
-
isNaturalDescending
protected static boolean isNaturalDescending(Document orderBy)
-
deriveComparator
protected static DocumentComparator deriveComparator(Document orderBy)
-
updateDataSize
protected abstract void updateDataSize(int sizeDelta)
-
getDataSize
protected abstract int getDataSize()
-
addDocument
public void addDocument(Document document)
- Specified by:
addDocumentin interfaceMongoCollection<P>
-
getDatabase
public MongoDatabase getDatabase()
- Specified by:
getDatabasein interfaceMongoCollection<P>
-
getCollectionName
public java.lang.String getCollectionName()
- Specified by:
getCollectionNamein interfaceMongoCollection<P>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
addIndex
public void addIndex(Index<P> index)
- Specified by:
addIndexin interfaceMongoCollection<P>
-
drop
public void drop()
- Specified by:
dropin interfaceMongoCollection<P>
-
dropIndex
public void dropIndex(java.lang.String indexName)
- Specified by:
dropIndexin interfaceMongoCollection<P>
-
findAndModify
public Document findAndModify(Document query)
- Specified by:
findAndModifyin interfaceMongoCollection<P>
-
handleQuery
public java.lang.Iterable<Document> handleQuery(Document queryObject, int numberToSkip, int numberToReturn, Document fieldSelector)
- Specified by:
handleQueryin interfaceMongoCollection<P>
-
handleDistinct
public Document handleDistinct(Document query)
- Specified by:
handleDistinctin interfaceMongoCollection<P>
-
insertDocuments
public void insertDocuments(java.util.List<Document> documents)
- Specified by:
insertDocumentsin interfaceMongoCollection<P>
-
deleteDocuments
public int deleteDocuments(Document selector, int limit)
- Specified by:
deleteDocumentsin interfaceMongoCollection<P>
-
updateDocuments
public Document updateDocuments(Document selector, Document updateQuery, ArrayFilters arrayFilters, boolean isMulti, boolean isUpsert)
- Specified by:
updateDocumentsin interfaceMongoCollection<P>
-
handleUpdate
protected abstract void handleUpdate(P position, Document oldDocument, Document newDocument)
-
getNumIndexes
public int getNumIndexes()
- Specified by:
getNumIndexesin interfaceMongoCollection<P>
-
count
public int count(Document query, int skip, int limit)
- Specified by:
countin interfaceMongoCollection<P>
-
getStats
public Document getStats()
- Specified by:
getStatsin interfaceMongoCollection<P>
-
removeDocument
public void removeDocument(Document document)
- Specified by:
removeDocumentin interfaceMongoCollection<P>
-
validate
public Document validate()
- Specified by:
validatein interfaceMongoCollection<P>
-
renameTo
public void renameTo(MongoDatabase newDatabase, java.lang.String newCollectionName)
- Specified by:
renameToin interfaceMongoCollection<P>
-
removeDocument
protected abstract void removeDocument(P position)
-
applySkipAndLimit
protected static java.lang.Iterable<Document> applySkipAndLimit(java.util.List<Document> documents, int numberToSkip, int numberToReturn)
-
streamAllDocumentsWithPosition
protected abstract java.util.stream.Stream<DocumentWithPosition<P>> streamAllDocumentsWithPosition()
-
-