001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.search.generic;
016    
017    import com.liferay.portal.kernel.search.BaseQueryImpl;
018    import com.liferay.portal.kernel.search.Query;
019    import com.liferay.portal.kernel.search.query.QueryVisitor;
020    
021    import java.util.Collections;
022    import java.util.HashSet;
023    import java.util.Set;
024    
025    /**
026     * @author Michael C. Han
027     */
028    public class DisMaxQuery extends BaseQueryImpl {
029    
030            @Override
031            public <T> T accept(QueryVisitor<T> queryVisitor) {
032                    return queryVisitor.visitQuery(this);
033            }
034    
035            public void addQuery(Query query) {
036                    _queries.add(query);
037            }
038    
039            public Set<Query> getQueries() {
040                    return Collections.unmodifiableSet(_queries);
041            }
042    
043            public Float getTieBreaker() {
044                    return _tieBreaker;
045            }
046    
047            @Override
048            public boolean hasChildren() {
049                    return !isEmpty();
050            }
051    
052            public boolean isEmpty() {
053                    return _queries.isEmpty();
054            }
055    
056            public void setTieBreaker(Float tieBreaker) {
057                    _tieBreaker = tieBreaker;
058            }
059    
060            private final Set<Query> _queries = new HashSet<>();
061            private Float _tieBreaker;
062    
063    }