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

com.kolibrifx.plovercrest.server.streams.QueryStreamProvider Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
 */

package com.kolibrifx.plovercrest.server.streams;

import java.util.Map;
import com.kolibrifx.lancebill.query.QueryDefinition;
import com.kolibrifx.lancebill.query.QueryMatcher;

public abstract class QueryStreamProvider extends SingleNameStreamProvider {
    private final QueryDefinition queryDefinition;

    public QueryStreamProvider(final QueryDefinition queryDefinition) {
        super(queryDefinition.unparse());
        this.queryDefinition = queryDefinition;
    }

    @Override
    public final  Stream tryOpen(final StreamEngine engine, final String name, final Class elementClass) {
        final Map parameterMap = QueryMatcher.tryMatch(queryDefinition, name);
        if (parameterMap == null) {
            return null;
        }
        return tryOpen(engine, name, parameterMap, elementClass);
    }

    protected abstract  Stream tryOpen(StreamEngine engine, String query, Map parameterMap,
                                             Class elementClass);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy