All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eventsourcing.queries.QueryFactory Maven / Gradle / Ivy

There is a newer version: 0.4.6
Show newest version
/**
 * 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());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy