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

com.liferay.portal.kernel.search.generic.BooleanClauseFactoryImpl Maven / Gradle / Ivy

There is a newer version: 7.4.3.112-ga112
Show newest version
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.portal.kernel.search.generic;

import com.liferay.portal.kernel.search.BooleanClause;
import com.liferay.portal.kernel.search.BooleanClauseFactory;
import com.liferay.portal.kernel.search.BooleanClauseOccur;
import com.liferay.portal.kernel.search.BooleanClauseOccurImpl;
import com.liferay.portal.kernel.search.Query;
import com.liferay.portal.kernel.search.SearchContext;
import com.liferay.portal.kernel.search.filter.Filter;
import com.liferay.portal.kernel.search.filter.TermFilter;

/**
 * @author Bruno Farache
 */
public class BooleanClauseFactoryImpl implements BooleanClauseFactory {

	@Override
	public BooleanClause create(Query query, String occur) {
		BooleanClauseOccur booleanClauseOccur = new BooleanClauseOccurImpl(
			occur);

		return new BooleanClauseImpl<>(query, booleanClauseOccur);
	}

	/**
	 * @deprecated As of Wilberforce (7.0.x), replaced by {@link #create(Query,
	 *             String)}
	 */
	@Deprecated
	@Override
	public BooleanClause create(
		SearchContext searchContext, Query query, String occur) {

		return create(query, occur);
	}

	/**
	 * @deprecated As of Wilberforce (7.0.x), replaced by {@link #create(String,
	 *             String, String)}}
	 */
	@Deprecated
	@Override
	public BooleanClause create(
		SearchContext searchContext, String field, String value, String occur) {

		return create(field, value, occur);
	}

	@Override
	public BooleanClause create(
		String field, String value, String occur) {

		Query query = new TermQueryImpl(field, value);

		BooleanClauseOccur booleanClauseOccur = new BooleanClauseOccurImpl(
			occur);

		return new BooleanClauseImpl<>(query, booleanClauseOccur);
	}

	@Override
	public BooleanClause createFilter(
		Filter filter, BooleanClauseOccur booleanClauseOccur) {

		return new BooleanClauseImpl<>(filter, booleanClauseOccur);
	}

	@Override
	public BooleanClause createFilter(
		String field, String value, BooleanClauseOccur booleanClauseOccur) {

		TermFilter termFilter = new TermFilter(field, value);

		return new BooleanClauseImpl(termFilter, booleanClauseOccur);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy