Package com.inductiveautomation.rm.base
Class RMKeyChainAggr
- java.lang.Object
-
- com.inductiveautomation.rm.base.RMKeyChainAggr
-
- All Implemented Interfaces:
RMKey.Get
,RMKeyChain.Get
public class RMKeyChainAggr extends java.lang.Object implements RMKey.Get, RMKeyChain.Get
A class to evaluate keys on lists.
-
-
Constructor Summary
Constructors Constructor Description RMKeyChainAggr(java.util.List aList)
Creates a new RMKeyChainAggregator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double
average(java.util.List aList, RMKeyChain aKeyChain)
Returns the average resulting by evaluating the keychain on given list objects.static java.lang.Double
averageX(java.util.List aList, RMKeyChain aKeyChain)
Returns the average resulting by evaluating the keychain on given list objects.static int
count(java.util.List aList, RMKeyChain aKeyChain)
Returns the count of the given list or if keychain is present, all non-null values.static int
countDeep(java.util.List aList, RMKeyChain aKeyChain)
Returns the count of all non-null leaf nodes in given list.static int
countUnique(java.util.List aList, RMKeyChain aKeyChain)
Returns the count of the unique values for a given list and key chain.static java.util.List
filter(java.util.List aList, RMKeyChain aKeyChain)
Returns the original list with items that fail the given boolean key chain removed.static java.lang.Object
get(java.util.List aList, RMKeyChain aKeyChain)
Returns the specific object that meets the criteria.static java.lang.reflect.Method
getAggrMethodImpl(java.lang.String aName)
Returns a method for a method name (assuming {List,KeyChain} args).java.lang.Object
getKeyChainValue(java.lang.Object aRoot, RMKeyChain aKeyChain)
Override to give list chance to implement this.java.lang.Object
getKeyValue(java.lang.String aKey)
Override to give list chance to implement this.static java.lang.Object
getListValue(java.lang.Object anObj, RMKeyChain aKeyChain)
Silly method to support DatasetKeys like: List1Key.List2Key, which returns a flattened Master/Detail list.protected RMKeyChain
getMethodArgs(RMKeyChain aKeyChain)
Returns the method args.protected java.lang.String
getMethodName(RMKeyChain aKeyChain)
Returns the method name for a KeyChain.static java.util.List
group(java.util.List aList, RMKeyChain aKeyChain)
Returns the original list grouped by the given key chain.static java.lang.String
join(java.util.List aList, RMKeyChain aKeyChain)
Aggregator version of join.static java.util.List
listOf(java.util.List aList, RMKeyChain aKeyChain)
Returns a list of objects by evaluating keychain on given list.static java.lang.Object
max(java.util.List aList, RMKeyChain aKeyChain)
Returns the maximum result of evaluating the keychain on given list objects.static java.lang.Object
min(java.util.List aList, RMKeyChain aKeyChain)
Returns the minimum result of evaluating the keychain on given list objects.static boolean
shouldRecurse(java.util.List aList, RMKeyChain aKeyChain)
Returns whether given list should be recursed into for aggregate calculations.static double
total(java.util.List aList, RMKeyChain aKeyChain)
Returns the total resulting from evaluating given keychain on given list of objects (nulls are zero).static double
total2(java.util.List aList, RMKeyChain aKeyChain)
Returns the total resulting from evaluating given keychain on given list of objects (nulls are zero).static java.lang.Double
totalX(java.util.List aList, RMKeyChain aKeyChain)
Returns the total resulting from evaluating given keychain on given list of objects (nulls short circuit).
-
-
-
Method Detail
-
getKeyValue
public java.lang.Object getKeyValue(java.lang.String aKey)
Override to give list chance to implement this.- Specified by:
getKeyValue
in interfaceRMKey.Get
-
getKeyChainValue
public java.lang.Object getKeyChainValue(java.lang.Object aRoot, RMKeyChain aKeyChain)
Override to give list chance to implement this.- Specified by:
getKeyChainValue
in interfaceRMKeyChain.Get
-
getMethodName
protected java.lang.String getMethodName(RMKeyChain aKeyChain)
Returns the method name for a KeyChain.
-
getMethodArgs
protected RMKeyChain getMethodArgs(RMKeyChain aKeyChain)
Returns the method args.
-
getAggrMethodImpl
public static java.lang.reflect.Method getAggrMethodImpl(java.lang.String aName)
Returns a method for a method name (assuming {List,KeyChain} args).
-
total
public static double total(java.util.List aList, RMKeyChain aKeyChain)
Returns the total resulting from evaluating given keychain on given list of objects (nulls are zero).
-
total2
public static double total2(java.util.List aList, RMKeyChain aKeyChain)
Returns the total resulting from evaluating given keychain on given list of objects (nulls are zero).
-
totalX
public static java.lang.Double totalX(java.util.List aList, RMKeyChain aKeyChain)
Returns the total resulting from evaluating given keychain on given list of objects (nulls short circuit).
-
count
public static int count(java.util.List aList, RMKeyChain aKeyChain)
Returns the count of the given list or if keychain is present, all non-null values.
-
countDeep
public static int countDeep(java.util.List aList, RMKeyChain aKeyChain)
Returns the count of all non-null leaf nodes in given list.
-
countUnique
public static int countUnique(java.util.List aList, RMKeyChain aKeyChain)
Returns the count of the unique values for a given list and key chain.
-
average
public static double average(java.util.List aList, RMKeyChain aKeyChain)
Returns the average resulting by evaluating the keychain on given list objects.
-
averageX
public static java.lang.Double averageX(java.util.List aList, RMKeyChain aKeyChain)
Returns the average resulting by evaluating the keychain on given list objects.
-
min
public static java.lang.Object min(java.util.List aList, RMKeyChain aKeyChain)
Returns the minimum result of evaluating the keychain on given list objects.
-
max
public static java.lang.Object max(java.util.List aList, RMKeyChain aKeyChain)
Returns the maximum result of evaluating the keychain on given list objects.
-
get
public static java.lang.Object get(java.util.List aList, RMKeyChain aKeyChain)
Returns the specific object that meets the criteria.
-
filter
public static java.util.List filter(java.util.List aList, RMKeyChain aKeyChain)
Returns the original list with items that fail the given boolean key chain removed.
-
group
public static java.util.List group(java.util.List aList, RMKeyChain aKeyChain)
Returns the original list grouped by the given key chain.
-
join
public static java.lang.String join(java.util.List aList, RMKeyChain aKeyChain)
Aggregator version of join. aKeyChain is an arglist with 2 args, as in join(getName, "\n") The first arg is the keychain to be evaluated for each object in list, and the second arg is the separator string.
-
listOf
public static java.util.List listOf(java.util.List aList, RMKeyChain aKeyChain)
Returns a list of objects by evaluating keychain on given list.
-
shouldRecurse
public static boolean shouldRecurse(java.util.List aList, RMKeyChain aKeyChain)
Returns whether given list should be recursed into for aggregate calculations.
-
getListValue
public static java.lang.Object getListValue(java.lang.Object anObj, RMKeyChain aKeyChain)
Silly method to support DatasetKeys like: List1Key.List2Key, which returns a flattened Master/Detail list.
-
-