001/*
002 *  Copyright 2014 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.cms.search.query;
017
018import java.util.Arrays;
019
020import org.ametys.cms.content.indexing.solr.SolrFieldNames;
021
022/**
023 * Represents a {@link Query} testing the content language.
024 */
025public class ContentLanguageQuery extends AbstractMultivaluedQuery<String>
026{
027    /**
028     * Build a ContentLanguageQuery to test if the contentLanguage property exists.
029     */
030    public ContentLanguageQuery()
031    {
032        this(Operator.EXISTS);
033    }
034    
035    /**
036     * Build a ContentLanguageQuery.
037     * @param value the language equality to test.
038     */
039    public ContentLanguageQuery(String value)
040    {
041        this(Operator.EQ, value);
042    }
043    
044    /**
045     * Build a ContentLanguageQuery.
046     * @param values the languages to test.
047     */
048    public ContentLanguageQuery(String... values)
049    {
050        this(Operator.EQ, values);
051    }
052    
053    /**
054     * Build a ContentLanguageQuery.
055     * @param operator the operator.
056     * @param value the language code.
057     */
058    public ContentLanguageQuery(Operator operator, String value)
059    {
060        this(operator, LogicalOperator.OR, new String[] {value});
061    }
062    
063    /**
064     * Build a ContentLanguageQuery.
065     * @param operator the operator.
066     * @param values the language codes.
067     */
068    public ContentLanguageQuery(Operator operator, String... values)
069    {
070        this(operator, LogicalOperator.OR, values);
071    }
072    
073    /**
074     * Build a ContentLanguageQuery.
075     * @param operator the operator.
076     * @param logicalOperator the logical operator.
077     * @param values the language codes.
078     */
079    public ContentLanguageQuery(Operator operator, LogicalOperator logicalOperator, String... values)
080    {
081        super(SolrFieldNames.CONTENT_LANGUAGE, operator, logicalOperator, Arrays.asList(values));
082    }
083}