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.BooleanClause;
018    import com.liferay.portal.kernel.search.BooleanClauseOccur;
019    import com.liferay.portal.kernel.util.StringBundler;
020    
021    /**
022     * @author Michael C. Han
023     */
024    public class BooleanClauseImpl<T> implements BooleanClause<T> {
025    
026            public BooleanClauseImpl(T t, BooleanClauseOccur booleanClauseOccur) {
027                    _t = t;
028    
029                    _booleanClauseOccur = booleanClauseOccur;
030            }
031    
032            @Override
033            public BooleanClauseOccur getBooleanClauseOccur() {
034                    return _booleanClauseOccur;
035            }
036    
037            @Override
038            public T getClause() {
039                    return _t;
040            }
041    
042            /**
043             * @deprecated As of 7.0.0, replaced by {@link #getClause}
044             */
045            @Deprecated
046            @Override
047            public T getQuery() {
048                    return getClause();
049            }
050    
051            @Override
052            public String toString() {
053                    StringBundler sb = new StringBundler(5);
054    
055                    sb.append("{");
056                    sb.append(_booleanClauseOccur);
057                    sb.append("(");
058                    sb.append(_t);
059                    sb.append(")}");
060    
061                    return sb.toString();
062            }
063    
064            private final BooleanClauseOccur _booleanClauseOccur;
065            private final T _t;
066    
067    }