com.kolibrifx.plovercrest.server.streams.QueryStreamProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plovercrest-server Show documentation
Show all versions of plovercrest-server Show documentation
Plovercrest server library.
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);
}