All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.javers.repository.api.QueryParams Maven / Gradle / Ivy
package org.javers.repository.api;
import org.javers.common.string.ToStringBuilder;
import org.javers.core.metamodel.object.SnapshotType;
import org.javers.repository.jql.QueryBuilder;
import java.time.Instant;
import java.util.*;
import org.javers.core.commit.CommitId;
import java.time.LocalDateTime;
/**
* Container for additional query parameters
* used for filtering Snapshots to be fetched from database.
*
* @author michal wesolowski
* @see QueryParamsBuilder
*/
public class QueryParams {
private final int limit;
private final int skip;
private final LocalDateTime from;
private final Instant fromInstant;
private final LocalDateTime to;
private final Instant toInstant;
private final CommitId toCommitId;
private final Set commitIds;
private final Long version;
private final String author;
private final Map commitProperties;
private final boolean aggregate;
private final Set changedProperties;
private final SnapshotType snapshotType;
private final boolean loadCommitProps;
private final Integer snapshotQueryLimit;
QueryParams(int limit, int skip, LocalDateTime from, Instant fromInstant, LocalDateTime to, Instant toInstant, Set commitIds, Long version, String author, Map commitProperties, boolean aggregate, Set changedProperties, CommitId toCommitId, SnapshotType snapshotType, boolean loadCommitProps, Integer snapshotQueryLimit) {
this.snapshotQueryLimit = snapshotQueryLimit;
this.limit = limit;
this.skip = skip;
this.from = from;
this.fromInstant = fromInstant;
this.to = to;
this.toInstant = toInstant;
this.commitIds = Collections.unmodifiableSet(commitIds);
this.version = version;
this.author = author;
this.commitProperties = Collections.unmodifiableMap(commitProperties);
this.aggregate = aggregate;
this.changedProperties = Collections.unmodifiableSet(changedProperties);
this.toCommitId = toCommitId;
this.snapshotType = snapshotType;
this.loadCommitProps = loadCommitProps;
}
public QueryParams changeAggregate(boolean newAggregate) {
return QueryParamsBuilder.copy(this)
.withChildValueObjects(newAggregate).build();
}
public QueryParams nextPage() {
return QueryParamsBuilder.copy(this)
.skip(skip + limit).build();
}
/**
* @see QueryBuilder#limit(int)
*/
public int limit() {
return limit;
}
/**
* @see QueryBuilder#skip(int)
*/
public int skip() {
return skip;
}
public boolean hasSnapshotQueryLimit() {
return snapshotQueryLimit != null;
}
public Optional snapshotQueryLimit() {
return Optional.ofNullable(snapshotQueryLimit);
}
/**
* @see QueryBuilder#from(LocalDateTime)
*/
public Optional from() {
return Optional.ofNullable(from);
}
/**
* @see QueryBuilder#fromInstant(Instant)
*/
public Optional fromInstant() {
return Optional.ofNullable(fromInstant);
}
/**
* @see QueryBuilder#to(LocalDateTime)
*/
public Optional to() {
return Optional.ofNullable(to);
}
/**
* @see QueryBuilder#toInstant(Instant)
*/
public Optional toInstant() {
return Optional.ofNullable(toInstant);
}
/**
* @see QueryBuilder#toCommitId(CommitId)
*/
public Optional toCommitId() {
return Optional.ofNullable(toCommitId);
}
/**
* @see QueryBuilder#withCommitIds(Collection)
*/
public Set commitIds() {
return Collections.unmodifiableSet(commitIds);
}
/**
* @see QueryBuilder#withCommitProperty(String, String)
*/
public Map commitProperties() {
return commitProperties != null ?
commitProperties : Collections.emptyMap();
}
/**
* @see QueryBuilder#withChangedPropertyIn(String...)
*/
public Set changedProperties() {
return Collections.unmodifiableSet(changedProperties);
}
/**
* @see QueryBuilder#withVersion(long)
*/
public Optional version() {
return Optional.ofNullable(version);
}
/**
* @see QueryBuilder#byAuthor(String)
*/
public Optional author() {
return Optional.ofNullable(author);
}
/**
* @see QueryBuilder#withChildValueObjects()
*/
public boolean isAggregate() {
return aggregate;
}
public boolean isLoadCommitProps() {
return loadCommitProps;
}
/**
* @see QueryBuilder#withSnapshotType(SnapshotType)
*/
public Optional snapshotType() {
return Optional.ofNullable(snapshotType);
}
@Override
public String toString() {
return ToStringBuilder.toString(this,
"aggregate", aggregate,
"from", from,
"fromInstant", fromInstant,
"to", to,
"toInstant", toInstant,
"toCommitId", toCommitId,
"commitIds", commitIds,
"changeProperties", changedProperties,
"version", version,
"author", author,
"snapshotType", snapshotType,
"limit", limit,
"skip", skip,
"snapshotQueryLimit", snapshotQueryLimit);
}
}