source: src/main/java/genius/core/utility/ConditionalZeroConstraint.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.1 KB
Line 
1package genius.core.utility;
2
3import java.util.HashMap;
4
5import genius.core.Bid;
6
7public class ConditionalZeroConstraint extends RConstraint {
8
9 private Integer issueIndex;
10 private HashMap<Integer, String> checkList;
11 private String valueToBeChecked;
12
13 public ConditionalZeroConstraint(int index, String valueToBeChecked) {
14 this.checkList = new HashMap<Integer, String>();
15 this.issueIndex = index;
16 this.valueToBeChecked = valueToBeChecked;
17 }
18
19 @Override
20 public void addContraint(Integer issueIndex, String conditionToBeCheck) {
21 this.checkList.put(issueIndex, conditionToBeCheck);
22 }
23
24 @Override
25 public Integer getIssueIndex() {
26 return this.issueIndex;
27 }
28
29 @Override
30 public boolean willZeroUtility(Bid bid) {
31
32 boolean check = true;
33 for (Integer index : this.checkList.keySet()) {
34 if (!this.checkList.get(index).equals(
35 bid.getValue(index).toString()))
36 check = false;
37 }
38
39 if (check == true) {
40 if (!bid.getValue(issueIndex).toString().contains(valueToBeChecked))
41 return true;
42 }
43 return false;
44
45 }
46
47}
Note: See TracBrowser for help on using the repository browser.