142 /**
143 * Returns the average of values recorded, or zero if no values have been
144 * recorded.
145 *
146 * @return the average of values, or zero if none
147 */
148 public final double getAverage() {
149 return getCount() > 0 ? (double) getSum() / getCount() : 0.0d;
150 }
151
152 @Override
153 /**
154 * {@inheritDoc}
155 *
156 * Returns a non-empty string representation of this object suitable for
157 * debugging. The exact presentation format is unspecified and may vary
158 * between implementations and versions.
159 */
160 public String toString() {
161 return String.format(
162 "%s{count=%d, sum=%d, min=%d, average=%d, max=%d}",
163 this.getClass().getSimpleName(),
164 getCount(),
165 getSum(),
166 getMin(),
167 getAverage(),
168 getMax());
169 }
170 }
|
142 /**
143 * Returns the average of values recorded, or zero if no values have been
144 * recorded.
145 *
146 * @return the average of values, or zero if none
147 */
148 public final double getAverage() {
149 return getCount() > 0 ? (double) getSum() / getCount() : 0.0d;
150 }
151
152 @Override
153 /**
154 * {@inheritDoc}
155 *
156 * Returns a non-empty string representation of this object suitable for
157 * debugging. The exact presentation format is unspecified and may vary
158 * between implementations and versions.
159 */
160 public String toString() {
161 return String.format(
162 "%s{count=%d, sum=%d, min=%d, average=%f, max=%d}",
163 this.getClass().getSimpleName(),
164 getCount(),
165 getSum(),
166 getMin(),
167 getAverage(),
168 getMax());
169 }
170 }
|