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;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    
019    import java.io.Serializable;
020    
021    /**
022     * @author Michael C. Han
023     */
024    public class Stats implements Serializable {
025    
026            public static final Stats STANDARD_STATS = new Stats(
027                    true, true, true, true, true);
028    
029            public Stats() {
030            }
031    
032            public Stats(
033                    boolean min, boolean max, boolean sum, boolean count, boolean missing) {
034    
035                    _min = min;
036                    _max = max;
037                    _sum = sum;
038                    _count = count;
039                    _missing = missing;
040            }
041    
042            public String getField() {
043                    return _field;
044            }
045    
046            public boolean isCount() {
047                    return _count;
048            }
049    
050            public boolean isEnabled() {
051                    return _count || _max || _mean || _min || _missing ||
052                            _standardDeviation || _sum || _sumOfSquares;
053            }
054    
055            public boolean isMax() {
056                    return _max;
057            }
058    
059            public boolean isMean() {
060                    return _mean;
061            }
062    
063            public boolean isMin() {
064                    return _min;
065            }
066    
067            public boolean isMissing() {
068                    return _missing;
069            }
070    
071            public boolean isStandardDeviation() {
072                    return _standardDeviation;
073            }
074    
075            public boolean isSum() {
076                    return _sum;
077            }
078    
079            public boolean isSumOfSquares() {
080                    return _sumOfSquares;
081            }
082    
083            public void setCount(boolean count) {
084                    _count = count;
085            }
086    
087            public void setField(String field) {
088                    _field = field;
089            }
090    
091            public void setMax(boolean max) {
092                    _max = max;
093            }
094    
095            public void setMean(boolean mean) {
096                    _mean = mean;
097            }
098    
099            public void setMin(boolean min) {
100                    _min = min;
101            }
102    
103            public void setMissing(boolean missing) {
104                    _missing = missing;
105            }
106    
107            public void setStandardDeviation(boolean standardDeviation) {
108                    _standardDeviation = standardDeviation;
109            }
110    
111            public void setSum(boolean sum) {
112                    _sum = sum;
113            }
114    
115            public void setSumOfSquares(boolean sumOfSquares) {
116                    _sumOfSquares = sumOfSquares;
117            }
118    
119            @Override
120            public String toString() {
121                    StringBundler sb = new StringBundler(19);
122    
123                    sb.append("{count=");
124                    sb.append(_count);
125                    sb.append(", field=");
126                    sb.append(_field);
127                    sb.append(", max=");
128                    sb.append(_max);
129                    sb.append(", mean=");
130                    sb.append(_mean);
131                    sb.append(", min=");
132                    sb.append(_min);
133                    sb.append(", missing=");
134                    sb.append(_missing);
135                    sb.append(", standardDeviation=");
136                    sb.append(_standardDeviation);
137                    sb.append(", sum=");
138                    sb.append(_sum);
139                    sb.append(", sumOfSquares=");
140                    sb.append(_sumOfSquares);
141                    sb.append("}");
142    
143                    return sb.toString();
144            }
145    
146            private boolean _count;
147            private String _field;
148            private boolean _max;
149            private boolean _mean;
150            private boolean _min;
151            private boolean _missing;
152            private boolean _standardDeviation;
153            private boolean _sum;
154            private boolean _sumOfSquares;
155    
156    }