org.codelibs.elasticsearch.sstmpl.module.SearchTemplateModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-sstmpl Show documentation
Show all versions of elasticsearch-sstmpl Show documentation
This plugin provides Script-based Search Template.
package org.codelibs.elasticsearch.sstmpl.module;
import java.util.ArrayList;
import java.util.List;
import org.codelibs.elasticsearch.sstmpl.filter.SearchTemplateFilter;
import org.codelibs.elasticsearch.sstmpl.filter.SearchTemplateFilters;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.multibindings.Multibinder;
public class SearchTemplateModule extends AbstractModule {
private final List> searchTemplateFilters = new ArrayList<>();
@Override
protected void configure() {
final Multibinder searchTemplateFilterMultibinder = Multibinder
.newSetBinder(binder(), SearchTemplateFilter.class);
for (final Class extends SearchTemplateFilter> searchTemplateFilter : searchTemplateFilters) {
searchTemplateFilterMultibinder.addBinding().to(
searchTemplateFilter);
}
bind(SearchTemplateFilters.class).asEagerSingleton();
}
public SearchTemplateModule registerSearchTemplateFillter(
final Class extends SearchTemplateFilter> searchTemplateFilter) {
searchTemplateFilters.add(searchTemplateFilter);
return this;
}
}