com.avaje.ebeanservice.elastic.query.EQuery Maven / Gradle / Ivy
package com.avaje.ebeanservice.elastic.query;
import com.avaje.ebean.plugin.BeanType;
import com.avaje.ebean.text.json.JsonBeanReader;
import com.avaje.ebean.text.json.JsonContext;
import com.avaje.ebean.text.json.JsonReadOptions;
import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.ebeanservice.elastic.search.bean.BeanSearchParser;
import com.fasterxml.jackson.core.JsonParser;
/**
* Class for processing query requests.
*/
public class EQuery {
protected final SpiQuery query;
protected final BeanType beanType;
protected final JsonContext jsonContext;
protected final JsonReadOptions jsonOptions;
public EQuery(SpiQuery query, JsonContext jsonContext, JsonReadOptions jsonOptions) {
this.query = query;
this.beanType = query.getBeanDescriptor();
this.jsonContext = jsonContext;
this.jsonOptions = jsonOptions;
}
public EQuery(BeanType beanType, JsonContext jsonContext, JsonReadOptions options) {
this.query = null;
this.beanType = beanType;
this.jsonContext = jsonContext;
this.jsonOptions = options;
}
/**
* Create a bean parser for the given json.
*/
protected BeanSearchParser createParser(JsonParser json) {
JsonBeanReader reader = createReader(json);
return createParser(json, reader);
}
/**
* Create a bean reader for the given json.
*/
public JsonBeanReader createReader(JsonParser json) {
return jsonContext.createBeanReader(beanType, json, jsonOptions);
}
private BeanSearchParser createParser(JsonParser json, JsonBeanReader reader) {
return new BeanSearchParser(json, beanType, reader, query.getLazyLoadMany());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy