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

com.mysema.query.lucene.QueryElement Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
package com.mysema.query.lucene;

import javax.annotation.Nullable;

import org.apache.lucene.search.Query;

import com.mysema.query.types.Constant;
import com.mysema.query.types.ConstantImpl;
import com.mysema.query.types.Visitor;
import com.mysema.query.types.expr.BooleanExpression;

/**
 * QueryElement wraps a Lucene Query
 *
 * @author tiwe
 *
 */
public class QueryElement extends BooleanExpression{

    private static final long serialVersionUID = 470868107363840155L;

    private final Query query;

    @Nullable
    private volatile Constant expr;

    public QueryElement(Query query){
        this.query = query;
    }

    @Override
    public  R accept(Visitor v, C context) {
        if (expr == null){
            expr = ConstantImpl.create(query.toString());
        }
        return expr.accept(v, context);
    }

    @Override
    public boolean equals(Object o) {
        return o instanceof QueryElement && ((QueryElement)o).query.equals(query);
    }

    @Override
    public int hashCode(){
        return query.hashCode();
    }

    public Query getQuery() {
        return query;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy