Class TypeAndTarget<E extends Enum<E>,T>
- Type Parameters:
E-
A convenient pattern for users to specify a command is that of type and target. This emphasizes that users often need to specify what kind of action to take, and what subject to take the action on. This concept pervades programming, exmplified by a simple
function(object) call
To facilitate this pattern in op templates with the help of type safety, this helper type allows for the scanning of a map for a matching enum field. If any map key matches one of the possible enum values, case-insensitively, and with only a single match, then the matching enum value is taken as a specific type of action, and the matching value in the map is taken as the intended target.
Further, the target may be indirect, such as a binding, rather than a specific literal or structured
value. In such cases, only a lambda-style function may be available. The provided targetFunction is
a LongFunction of Object which can be called to return an associated target value once the
cycle value is known.
public enum LandMovers {
BullDozer,
DumpTruck
}
and a parsed op like
(json)
{
"op": {
"bulldozer": "{dozerid}"
}
}
(yaml)
op:
bulldozer: "{dozerid}
the result will be returned with the following:
enumId: (Enum field) BullDozer
field: (String) bulldozer
targetFunction: (long l) -> template function for {dozerid}
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
enumId
-
field
-
targetFunction
-
-
Constructor Details
-
TypeAndTarget
-