game.libraries.general
Class Aggregate

java.lang.Object
  |
  +--game.libraries.general.Aggregate

public class Aggregate
extends java.lang.Object

Static class to calculate aggregated statistics.


Nested Class Summary
static interface Aggregate.Value
           
 
Constructor Summary
Aggregate()
           
 
Method Summary
static float average(java.util.Collection collection, Aggregate.Value value)
          Averages the characteristic over the included objects.
static void execute(java.util.Collection collection, Aggregate.Value value)
          Merely executes the get call for each object in the collection.
static float maximum(java.util.Collection collection, Aggregate.Value value)
          Finds the maximum of the characteristic over the included objects.
static java.lang.Object maximumObject(java.util.Collection collection, Aggregate.Value value)
          Finds object with the maximum of the characteristic over the included objects.
static float minimum(java.util.Collection collection, Aggregate.Value value)
          Finds the minimum of the characteristic over the included objects.
static float sum(java.util.Collection collection, Aggregate.Value value)
          Sums the characteristic over the included objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Aggregate

public Aggregate()
Method Detail

execute

public static void execute(java.util.Collection collection,
                           Aggregate.Value value)
Merely executes the get call for each object in the collection.

Parameters:
value - the value interface to get the data.
collection - the collection to iterate over.

sum

public static float sum(java.util.Collection collection,
                        Aggregate.Value value)
Sums the characteristic over the included objects.

Parameters:
value - the value interface to get the data.
collection - the collection to iterate over.
Returns:
the sum.

average

public static float average(java.util.Collection collection,
                            Aggregate.Value value)
Averages the characteristic over the included objects.

Parameters:
value - the value interface to get the data.
collection - the collection to iterate over.
Returns:
the average (if it exists, if not, return 0).

minimum

public static float minimum(java.util.Collection collection,
                            Aggregate.Value value)
Finds the minimum of the characteristic over the included objects.

Parameters:
value - the value interface to get the data.
collection - the collection to iterate over.
Returns:
the minimum.

maximum

public static float maximum(java.util.Collection collection,
                            Aggregate.Value value)
Finds the maximum of the characteristic over the included objects.

Parameters:
value - the value interface to get the data.
collection - the collection to iterate over.
Returns:
the maximum.

maximumObject

public static java.lang.Object maximumObject(java.util.Collection collection,
                                             Aggregate.Value value)
Finds object with the maximum of the characteristic over the included objects.

Parameters:
value - the value interface to get the data.
collection - the collection to iterate over.
Returns:
the object with the maximum.