Test Setup Failed
Push — master ( bb3bf3...1e7564 )
by Alessandro
17:55
created

toString()   A

Complexity

Conditions 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
dl 0
loc 18
rs 9.9
c 0
b 0
f 0
1
package it.cnr.istc.pst.platinum.control.lang;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
6
/**
7
 * 
8
 * @author alessandro
9
 *
10
 */
11
public class AgentTaskDescription extends PlatformMessage {
0 ignored issues
show
Bug introduced by
Override the "equals" method in this class.
Loading history...
12
	
13
	private List<TokenDescription> goals;
14
	private List<TokenDescription> facts;
15
	
16
	/**
17
	 * 
18
	 * @param id
19
	 */
20
	public AgentTaskDescription(long id) {
21
		super(id);
22
		this.goals = new ArrayList<>();
23
		this.facts = new ArrayList<>();
24
	}
25
	
26
	/**
27
	 * 
28
	 * @param fact
29
	 */
30
	public void addFactDescription(TokenDescription fact) {
31
		this.facts.add(fact);
32
	}
33
	
34
	/**
35
	 * 
36
	 * @param goal
37
	 */
38
	public void addGoalDescription(TokenDescription goal) {
39
		this.goals.add(goal);
40
	}
41
	
42
	/**
43
	 * 
44
	 * @return
45
	 */
46
	public List<TokenDescription> getFacts() {
47
		return new ArrayList<>(this.facts);
48
	}
49
	
50
	/**
51
	 * 
52
	 * @return
53
	 */
54
	public List<TokenDescription> getGoals() {
55
		return new ArrayList<>(this.goals);
56
	}
57
	
58
	/**
59
	 * 
60
	 */
61
	@Override
62
	public String toString() {
63
		// JSON style description
64
		String json = "{\n\tgoals: [\n";
65
		for (TokenDescription goal : goals) {
66
			// add JSON object description
67
			json += "\t\t" + goal + ",\n";
0 ignored issues
show
Performance introduced by
String concatenation with + is inefficient. Doing so in a loop may incur a significant performance penalty. Consider using a StringBuilder instead
Loading history...
68
		}
69
						
70
		json += "\t],\n\n\tfacts: [\n";
71
		for (TokenDescription fact : this.facts) {
72
			// add JSON object description
73
			json += "\t\t" + fact + ",\n";
0 ignored issues
show
Performance introduced by
String concatenation with + is inefficient. Doing so in a loop may incur a significant performance penalty. Consider using a StringBuilder instead
Loading history...
74
		}
75
				
76
		json += "\t],\n\n}\n";
77
		// get JSON
78
		return json;
79
	}
80
}
81