com.eventsourcing.queries.QueryFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eventsourcing-queries Show documentation
Show all versions of eventsourcing-queries Show documentation
Event capture and querying framework for Java
/**
* Copyright (c) 2016, All Contributors (see CONTRIBUTORS file)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.eventsourcing.queries;
import com.eventsourcing.Entity;
import com.eventsourcing.EntityHandle;
import com.eventsourcing.hlc.HybridTimestamp;
import com.eventsourcing.index.EntityIndex;
import com.eventsourcing.index.EntityQueryFactory;
import com.googlecode.cqengine.IndexedCollection;
import com.googlecode.cqengine.query.Query;
import java.util.function.Function;
public class QueryFactory {
/**
* @see LatestAssociatedEntryQuery
* @param collection collection to query against
* @param query query as is
* @param timestampAttribute timestamp attribute
* @param entity type
* @return a query
*/
public static Query>
isLatestEntity(final IndexedCollection> collection,
final Query> query,
final EntityIndex timestampAttribute) {
return new IsLatestEntity<>(collection, query, timestampAttribute.getAttribute());
}
/**
* @see LatestAssociatedEntryQuery
* @param collection collection to query against
* @param query query returning function
* @param timestampAttribute timestamp attribute
* @param entity type
* @return a query
*/
public static Query>
isLatestEntity(final IndexedCollection> collection,
final Function, Query>> query,
final EntityIndex timestampAttribute) {
return new IsLatestEntity<>(collection, query, timestampAttribute.getAttribute());
}
}