1 | package parties.feedbackmediator.partialopponentmodel;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 |
|
---|
5 | import genius.core.issue.Value;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | *
|
---|
9 | * @author Reyhan Aydogan
|
---|
10 | *
|
---|
11 | */
|
---|
12 |
|
---|
13 | public class ValuePreferenceNode {
|
---|
14 |
|
---|
15 | private ArrayList<Value> morePreferredList; // more preferred values
|
---|
16 | private ArrayList<Value> lessPreferredList; // less preferred values
|
---|
17 | private ArrayList<Value> equallyPreferredList;
|
---|
18 | private int depth; // depth of the node in the preference graph
|
---|
19 |
|
---|
20 | public ValuePreferenceNode(Value value, int assignedDepth) {
|
---|
21 | morePreferredList = new ArrayList<Value>();
|
---|
22 | lessPreferredList = new ArrayList<Value>();
|
---|
23 | equallyPreferredList = new ArrayList<Value>();
|
---|
24 | addEquallyPreferredValue(value);
|
---|
25 | setDepth(assignedDepth);
|
---|
26 | }
|
---|
27 |
|
---|
28 | public ValuePreferenceNode(Value value) {
|
---|
29 | morePreferredList = new ArrayList<Value>();
|
---|
30 | lessPreferredList = new ArrayList<Value>();
|
---|
31 | equallyPreferredList = new ArrayList<Value>();
|
---|
32 | addEquallyPreferredValue(value);
|
---|
33 | setDepth(1);
|
---|
34 | }
|
---|
35 |
|
---|
36 | public ArrayList<Value> getMorePreferredList() {
|
---|
37 | return morePreferredList;
|
---|
38 | }
|
---|
39 |
|
---|
40 | public void setMorePreferredList(ArrayList<Value> morePreferredList) {
|
---|
41 | this.morePreferredList = morePreferredList;
|
---|
42 | }
|
---|
43 |
|
---|
44 | public void addMorePreferredValue(Value preferredValue) {
|
---|
45 | if (!morePreferredList.contains(preferredValue))
|
---|
46 | this.morePreferredList.add(preferredValue);
|
---|
47 | }
|
---|
48 |
|
---|
49 | public void addMorePreferredValues(ArrayList<Value> preferredValues) {
|
---|
50 |
|
---|
51 | for (Value currentValue : preferredValues) {
|
---|
52 | addMorePreferredValue(currentValue);
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|
56 | // RA: We can also add removeMorePreferredValue or Values method if it is
|
---|
57 | // necessary
|
---|
58 |
|
---|
59 | public ArrayList<Value> getLessPreferredList() {
|
---|
60 | return lessPreferredList;
|
---|
61 | }
|
---|
62 |
|
---|
63 | public void setLessPreferredList(ArrayList<Value> lessPreferredList) {
|
---|
64 | this.lessPreferredList = lessPreferredList;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public void addLessPreferredValue(Value lessPreferredValue) {
|
---|
68 | if (!lessPreferredList.contains(lessPreferredValue))
|
---|
69 | this.lessPreferredList.add(lessPreferredValue);
|
---|
70 | }
|
---|
71 |
|
---|
72 | public void addLessPreferredValues(ArrayList<Value> lessPreferredValues) {
|
---|
73 |
|
---|
74 | for (Value currentValue : lessPreferredValues) {
|
---|
75 | addLessPreferredValue(currentValue);
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | public ArrayList<Value> getEqualPreferredList() {
|
---|
80 | return equallyPreferredList;
|
---|
81 | }
|
---|
82 |
|
---|
83 | public void setEquallyPreferredList(ArrayList<Value> equalPreferredList) {
|
---|
84 | this.equallyPreferredList = equalPreferredList;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public void addEquallyPreferredValue(Value equallyPreferredValue) {
|
---|
88 | if (!equallyPreferredList.contains(equallyPreferredValue))
|
---|
89 | this.equallyPreferredList.add(equallyPreferredValue);
|
---|
90 | }
|
---|
91 |
|
---|
92 | public void addEquallyPreferredValues(ArrayList<Value> equallyPreferredValues) {
|
---|
93 |
|
---|
94 | for (Value currentValue : equallyPreferredValues) {
|
---|
95 | addEquallyPreferredValue(currentValue);
|
---|
96 | }
|
---|
97 | }
|
---|
98 |
|
---|
99 | public int increaseDepth(int amount) {
|
---|
100 | this.depth += amount;
|
---|
101 | return this.depth;
|
---|
102 | }
|
---|
103 |
|
---|
104 | public int getDepth() {
|
---|
105 | return depth;
|
---|
106 | }
|
---|
107 |
|
---|
108 | public void setDepth(int depth) {
|
---|
109 | this.depth = depth;
|
---|
110 | }
|
---|
111 |
|
---|
112 | @Override
|
---|
113 | public String toString() {
|
---|
114 | StringBuffer buffy = new StringBuffer();
|
---|
115 |
|
---|
116 | buffy.append("Values:");
|
---|
117 | for (Value current : equallyPreferredList)
|
---|
118 | buffy.append(" ").append(current);
|
---|
119 |
|
---|
120 | buffy.append("\n\tDepth: ").append(depth).append("\n");
|
---|
121 |
|
---|
122 | buffy.append("\tLess Preferred Node List:");
|
---|
123 |
|
---|
124 | if (lessPreferredList.size() == 0)
|
---|
125 | buffy.append(" None");
|
---|
126 |
|
---|
127 | for (Value lessPreferredValue : lessPreferredList)
|
---|
128 | buffy.append(" ").append(lessPreferredValue.toString());
|
---|
129 |
|
---|
130 | buffy.append("\n\tMore Preferred Node List:");
|
---|
131 |
|
---|
132 | if (morePreferredList.size() == 0)
|
---|
133 | buffy.append(" None");
|
---|
134 |
|
---|
135 | for (Value morePreferredValue : morePreferredList)
|
---|
136 | buffy.append(" ").append(morePreferredValue.toString());
|
---|
137 |
|
---|
138 | return buffy.toString();
|
---|
139 | }
|
---|
140 |
|
---|
141 | }
|
---|