public class CheckDBBase.CollectionChecker extends Object
Modifier and Type | Field and Description |
---|---|
protected Set<EntityMapper.Field> |
allFields
The set allFields will grow to contain all fields, based on mappers, which are removed one by one by the
'field' method.
|
protected com.mongodb.DBCollection |
collection |
protected String |
collectionName |
protected int |
count |
protected com.mongodb.DBCursor |
cursor |
protected boolean |
isEmpty |
protected EntityMapper |
mapper |
protected long |
nrRecordsInCollection |
protected List<CheckDBBase.UniquenessChecker<?>> |
uniquenessCheckers |
Constructor and Description |
---|
CollectionChecker(String collectionName,
EntityMapper<?> mapper) |
Modifier and Type | Method and Description |
---|---|
protected <T> CheckDBBase.UniquenessChecker<T> |
createUniquenessChecker(boolean logAsErrors,
EntityMapper.Field<?>... fieldPath)
Creates a new
CheckDBBase.UniquenessChecker for this collection. |
void |
done() |
void |
error(Uid<?> recordId,
String message,
String fieldPath,
Exception exception) |
boolean |
hasNext() |
<T> Tuple<Uid<?>,T> |
next() |
<T> Tuple<Uid<?>,T> |
next(boolean recordIdIsUUID) |
void |
warning(Uid<?> recordId,
String message,
String fieldPath) |
@Nonnull protected final com.mongodb.DBCollection collection
@Nullable protected final com.mongodb.DBCursor cursor
@Nonnull protected final EntityMapper mapper
@Nonnull protected final Set<EntityMapper.Field> allFields
protected long nrRecordsInCollection
protected int count
protected final boolean isEmpty
protected final String collectionName
protected final List<CheckDBBase.UniquenessChecker<?>> uniquenessCheckers
public CollectionChecker(@Nonnull String collectionName, @Nonnull EntityMapper<?> mapper)
public boolean hasNext()
public void done()
public void error(@Nonnull Uid<?> recordId, @Nonnull String message, @Nullable String fieldPath, @Nullable Exception exception)
public void warning(@Nonnull Uid<?> recordId, @Nonnull String message, @Nullable String fieldPath)
@Nonnull protected <T> CheckDBBase.UniquenessChecker<T> createUniquenessChecker(boolean logAsErrors, @Nonnull EntityMapper.Field<?>... fieldPath)
CheckDBBase.UniquenessChecker
for this collection. The returned UniquenessChecker
must only
be used for data contained within this collection, otherwise uniqueness violations will be reported on the
wrong collection.
Values to check for uniqueness can then be added to it using add(Uid, Object)
or add(Uid, Collection)
. The actual check will be performed once all other checks in this
CollectionChecker
have been finished, to ensure that all values to check for uniqueness have been
added to the UniquenessChecker
.T
- The type of the values to check for uniquenesslogAsErrors
- True if violations are logged as errors, false if logged as warnings.fieldPath
- The field path within the collection that needs to be unique over all the elements of the
collection.UniquenessChecker
.Copyright © 2018 TomTom International BV. All rights reserved.