Passed
Push — master ( ba4614...ebb470 )
by Alessandro
05:51
created

compareTo(FlawSolution)   A

Complexity

Conditions 3

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
dl 0
loc 5
rs 10
c 1
b 0
f 0
eloc 5
1
package it.cnr.istc.pst.platinum.ai.framework.microkernel.resolver.timeline.scheduling;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
6
import it.cnr.istc.pst.platinum.ai.framework.domain.component.Decision;
7
import it.cnr.istc.pst.platinum.ai.framework.microkernel.lang.flaw.FlawSolution;
8
9
/**
10
 * 
11
 * @author alessandro
12
 *
13
 */
14
public class OverlappingSetSchedule extends FlawSolution {
0 ignored issues
show
Bug introduced by
Override the "equals" method in this class.
Loading history...
15
	
16
	private List<PrecedenceConstraint> constraints;				// precedence constraints
17
	
18
	/**
19
	 * 
20
	 * @param cs
21
	 * @param cost
22
	 */
23
	protected OverlappingSetSchedule(OverlappingSet cs, double cost) {
24
		super(cs, cost);
25
		this.constraints = new ArrayList<>();
26
	}
27
	
28
	/**
29
	 * 
30
	 * @param reference
31
	 * @param target
32
	 */
33
	public void addConstraint(Decision reference, Decision target) {
34
		
35
		// create constraint data
36
		PrecedenceConstraint pc = new PrecedenceConstraint(reference, target);
37
		// add constraint
38
		this.constraints.add(pc);
39
	}
40
	
41
	/**
42
	 * 
43
	 * @return
44
	 */
45
	public List<PrecedenceConstraint> getConstraints() {
46
		return new ArrayList<>(this.constraints);
47
	}
48
	
49
	/**
50
	 * 
51
	 */
52
	@Override
53
	public int compareTo(FlawSolution o) {
54
		OverlappingSetSchedule schedule = (OverlappingSetSchedule) o;
55
		return this.constraints.size() > schedule.constraints.size() ? -1 : 
56
			this.constraints.size() < schedule.constraints.size() ? 1 : 0;
57
	}
58
}
59