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                    if (_count || _max || _mean || _min || _missing ||
052                            _standardDeviation || _sum || _sumOfSquares) {
053    
054                            return true;
055                    }
056    
057                    return false;
058            }
059    
060            public boolean isMax() {
061                    return _max;
062            }
063    
064            public boolean isMean() {
065                    return _mean;
066            }
067    
068            public boolean isMin() {
069                    return _min;
070            }
071    
072            public boolean isMissing() {
073                    return _missing;
074            }
075    
076            public boolean isStandardDeviation() {
077                    return _standardDeviation;
078            }
079    
080            public boolean isSum() {
081                    return _sum;
082            }
083    
084            public boolean isSumOfSquares() {
085                    return _sumOfSquares;
086            }
087    
088            public void setCount(boolean count) {
089                    _count = count;
090            }
091    
092            public void setField(String field) {
093                    _field = field;
094            }
095    
096            public void setMax(boolean max) {
097                    _max = max;
098            }
099    
100            public void setMean(boolean mean) {
101                    _mean = mean;
102            }
103    
104            public void setMin(boolean min) {
105                    _min = min;
106            }
107    
108            public void setMissing(boolean missing) {
109                    _missing = missing;
110            }
111    
112            public void setStandardDeviation(boolean standardDeviation) {
113                    _standardDeviation = standardDeviation;
114            }
115    
116            public void setSum(boolean sum) {
117                    _sum = sum;
118            }
119    
120            public void setSumOfSquares(boolean sumOfSquares) {
121                    _sumOfSquares = sumOfSquares;
122            }
123    
124            @Override
125            public String toString() {
126                    StringBundler sb = new StringBundler(19);
127    
128                    sb.append("{count=");
129                    sb.append(_count);
130                    sb.append(", field=");
131                    sb.append(_field);
132                    sb.append(", max=");
133                    sb.append(_max);
134                    sb.append(", mean=");
135                    sb.append(_mean);
136                    sb.append(", min=");
137                    sb.append(_min);
138                    sb.append(", missing=");
139                    sb.append(_missing);
140                    sb.append(", standardDeviation=");
141                    sb.append(_standardDeviation);
142                    sb.append(", sum=");
143                    sb.append(_sum);
144                    sb.append(", sumOfSquares=");
145                    sb.append(_sumOfSquares);
146                    sb.append("}");
147    
148                    return sb.toString();
149            }
150    
151            private boolean _count;
152            private String _field;
153            private boolean _max;
154            private boolean _mean;
155            private boolean _min;
156            private boolean _missing;
157            private boolean _standardDeviation;
158            private boolean _sum;
159            private boolean _sumOfSquares;
160    
161    }