|
4 | 4 | import br.com.zbra.androidlinq.exception.MultipleElementsFoundException; |
5 | 5 |
|
6 | 6 | import java.math.BigDecimal; |
| 7 | +import java.math.MathContext; |
7 | 8 | import java.util.List; |
8 | 9 | import java.util.Map; |
9 | 10 | import java.util.NoSuchElementException; |
@@ -203,6 +204,81 @@ interface Stream<T> extends Iterable<T> { |
203 | 204 | */ |
204 | 205 | BigDecimal sum(SelectorBigDecimal<T> selector); |
205 | 206 |
|
| 207 | + /** |
| 208 | + * Computes the average of the sequence of Byte values that are obtained by invoking |
| 209 | + * a transform function on each element of the input sequence. |
| 210 | + * |
| 211 | + * @param selector A transform function to apply to each element. |
| 212 | + * @return The average of the projected values. |
| 213 | + */ |
| 214 | + Byte average(SelectorByte<T> selector); |
| 215 | + |
| 216 | + /** |
| 217 | + * Computes the average of the sequence of Short values that are obtained by invoking |
| 218 | + * a transform function on each element of the input sequence. |
| 219 | + * |
| 220 | + * @param selector A transform function to apply to each element. |
| 221 | + * @return The average of the projected values. |
| 222 | + */ |
| 223 | + Short average(SelectorShort<T> selector); |
| 224 | + |
| 225 | + /** |
| 226 | + * Computes the average of the sequence of Integer values that are obtained by invoking |
| 227 | + * a transform function on each element of the input sequence. |
| 228 | + * |
| 229 | + * @param selector A transform function to apply to each element. |
| 230 | + * @return The average of the projected values. |
| 231 | + */ |
| 232 | + Integer average(SelectorInteger<T> selector); |
| 233 | + |
| 234 | + /** |
| 235 | + * Computes the average of the sequence of Long values that are obtained by invoking |
| 236 | + * a transform function on each element of the input sequence. |
| 237 | + * |
| 238 | + * @param selector A transform function to apply to each element. |
| 239 | + * @return The average of the projected values. |
| 240 | + */ |
| 241 | + Long average(SelectorLong<T> selector); |
| 242 | + |
| 243 | + /** |
| 244 | + * Computes the average of the sequence of Float values that are obtained by invoking |
| 245 | + * a transform function on each element of the input sequence. |
| 246 | + * |
| 247 | + * @param selector A transform function to apply to each element. |
| 248 | + * @return The average of the projected values. |
| 249 | + */ |
| 250 | + Float average(SelectorFloat<T> selector); |
| 251 | + |
| 252 | + /** |
| 253 | + * Computes the average of the sequence of Double values that are obtained by invoking |
| 254 | + * a transform function on each element of the input sequence. |
| 255 | + * |
| 256 | + * @param selector A transform function to apply to each element. |
| 257 | + * @return The average of the projected values. |
| 258 | + */ |
| 259 | + Double average(SelectorDouble<T> selector); |
| 260 | + |
| 261 | + /** |
| 262 | + * Computes the average of the sequence of BigDecimal values that are obtained by invoking |
| 263 | + * a transform function on each element of the input sequence. |
| 264 | + * |
| 265 | + * @param selector A transform function to apply to each element. |
| 266 | + * @return The average of the projected values. |
| 267 | + */ |
| 268 | + BigDecimal average(SelectorBigDecimal<T> selector); |
| 269 | + |
| 270 | + /** |
| 271 | + * Computes the average of the sequence of BigDecimal values that are obtained by invoking |
| 272 | + * a transform function on each element of the input sequence. |
| 273 | + * |
| 274 | + * @param selector A transform function to apply to each element. |
| 275 | + * @param mathContext Math context for operating with theses BigDecimals |
| 276 | + * @return The average of the projected values. |
| 277 | + * @see BigDecimal#divide(BigDecimal, MathContext) |
| 278 | + * @see MathContext |
| 279 | + */ |
| 280 | + BigDecimal average(SelectorBigDecimal<T> selector, MathContext mathContext); |
| 281 | + |
206 | 282 | /** |
207 | 283 | * Computes the min of the sequence of values that are obtained by invoking |
208 | 284 | * a transform function on each element of the input sequence. |
|
0 commit comments