source: src/main/java/genius/core/StrategyParameters.java@ 209

Last change on this file since 209 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.7 KB
Line 
1package genius.core;
2
3import java.io.Serializable;
4import java.util.HashMap;
5
6/**
7 * Simple class which stores the parameters given to a negotiation strategy, for
8 * example an concession factor.
9 *
10 * @author Mark Hendrikx
11 */
12public class StrategyParameters implements Serializable {
13
14 /**
15 *
16 */
17 private static final long serialVersionUID = 265616574821536192L;
18 /** Parameters as specified in the agent repository. */
19 protected HashMap<String, String> strategyParam;
20
21 /**
22 * Create an empty hashmap of parameters.
23 */
24 public StrategyParameters() {
25 strategyParam = new HashMap<String, String>();
26 }
27
28 /**
29 * Add a parameter to the list of parameters.
30 *
31 * @param name
32 * of the parameter.
33 * @param value
34 * of the parameter.
35 */
36 public void addVariable(String name, String value) {
37 strategyParam.put(name, value);
38 }
39
40 /**
41 * Returns the value of the parameter with the given name as string.
42 *
43 * @param name
44 * of the given parameter.
45 * @return value of the parameter as string.
46 */
47 public String getValueAsString(String name) {
48 return strategyParam.get(name);
49 }
50
51 /**
52 * Returns the value of the parameter with the given name as double.
53 *
54 * @param name
55 * of the given parameter.
56 * @return value of the parameter as double.
57 */
58 public double getValueAsDouble(String name) {
59 return Double.parseDouble(strategyParam.get(name));
60 }
61
62 @Override
63 public String toString() {
64 String result = "";
65 for (String key: this.strategyParam.keySet()) {
66 result += ";" + key + "=" + this.strategyParam.get(key);
67 }
68 return result;
69 }
70}
Note: See TracBrowser for help on using the repository browser.