154 /**
155 * Returns the average of values recorded, or zero if no values have been
156 * recorded.
157 *
158 * @return The average of values, or zero if none
159 */
160 public final double getAverage() {
161 return getCount() > 0 ? (double) getSum() / getCount() : 0.0d;
162 }
163
164 @Override
165 /**
166 * {@inheritDoc}
167 *
168 * Returns a non-empty string representation of this object suitable for
169 * debugging. The exact presentation format is unspecified and may vary
170 * between implementations and versions.
171 */
172 public String toString() {
173 return String.format(
174 "%s{count=%d, sum=%d, min=%d, average=%d, max=%d}",
175 this.getClass().getSimpleName(),
176 getCount(),
177 getSum(),
178 getMin(),
179 getAverage(),
180 getMax());
181 }
182 }
|
154 /**
155 * Returns the average of values recorded, or zero if no values have been
156 * recorded.
157 *
158 * @return The average of values, or zero if none
159 */
160 public final double getAverage() {
161 return getCount() > 0 ? (double) getSum() / getCount() : 0.0d;
162 }
163
164 @Override
165 /**
166 * {@inheritDoc}
167 *
168 * Returns a non-empty string representation of this object suitable for
169 * debugging. The exact presentation format is unspecified and may vary
170 * between implementations and versions.
171 */
172 public String toString() {
173 return String.format(
174 "%s{count=%d, sum=%d, min=%d, average=%f, max=%d}",
175 this.getClass().getSimpleName(),
176 getCount(),
177 getSum(),
178 getMin(),
179 getAverage(),
180 getMax());
181 }
182 }
|