Reputation: 3973
I am looking for an effective way to create a list/map etc out of the below two lists, which I can use to get both current and past status of a rule.
List<Boolean> rulesCurrentStatus = new ArrayList<Boolean>(); // 3 Rules: false/true meaning if the rule passed of failed
rulesCurrentStatus.add(false);
rulesCurrentStatus.add(true);
rulesCurrentStatus.add(false);
List<Boolean> rulesPreviousStatus = new ArrayList<Boolean>(); // Previous state of the above 3 rules.
rulesPreviousStatus.add(true);
rulesPreviousStatus.add(true);
rulesPreviousStatus.add(false);
Upvotes: 0
Views: 717
Reputation: 195209
if I understood you right, you want to get the status history of a rule. then maybe this could help:
Map<Rule( or ruleName as String), List<Boolean>>
the key in that map is the rule object or e.g. a String indicate which rule. the value is a list (ArrayList for example), stores the status history. for example:
{"rule1":[True, False,True] //1st,2nd,3rd(current) status
"rule2":[True,False]
...
}
thus if you want to get the whole status-history of a rule by
List<Boolean> history = map.get("someRule")
then you could add new status, or get certain status by playing with the List.
if you only need pre and current, you could declare the List with initial capacity.
Upvotes: 1
Reputation: 1135
You can use Map with key of String type and value of Boolean type. You can differentiate between current and previous value using the key. e.g. Store all current values with key something similar C#1,C#2 and store previous values with key something similar P#1, P#2 etc.
Upvotes: 1