1 | package schedframe.resources.units; |
---|
2 | |
---|
3 | import java.util.ArrayList; |
---|
4 | import java.util.List; |
---|
5 | |
---|
6 | |
---|
7 | |
---|
8 | public class Applications extends AbstractResourceUnit { |
---|
9 | |
---|
10 | |
---|
11 | protected List<String> applicationNames; |
---|
12 | |
---|
13 | public Applications(String resId){ |
---|
14 | super(StandardResourceUnitName.APPLICATION, resId); |
---|
15 | |
---|
16 | this.resourceType = ResourceUnitType.DISCRETE_RESOURCE; |
---|
17 | this.applicationNames = new ArrayList<String>(2); |
---|
18 | } |
---|
19 | |
---|
20 | public Applications(String resId, List<String> names){ |
---|
21 | super(StandardResourceUnitName.APPLICATION, resId); |
---|
22 | |
---|
23 | this.resourceType = ResourceUnitType.DISCRETE_RESOURCE; |
---|
24 | |
---|
25 | if(names == null) |
---|
26 | this.applicationNames = new ArrayList<String>(2); |
---|
27 | else |
---|
28 | this.applicationNames = names; |
---|
29 | } |
---|
30 | |
---|
31 | public void addApplication(String name){ |
---|
32 | this.applicationNames.add(name); |
---|
33 | } |
---|
34 | |
---|
35 | public List<String> getApplicationNames(){ |
---|
36 | return this.applicationNames; |
---|
37 | } |
---|
38 | |
---|
39 | public boolean containsApplication(String name){ |
---|
40 | return this.applicationNames.contains(name); |
---|
41 | } |
---|
42 | |
---|
43 | public int getAmount() { |
---|
44 | return this.applicationNames.size(); |
---|
45 | } |
---|
46 | |
---|
47 | public int getFreeAmount() { |
---|
48 | return this.getAmount(); |
---|
49 | } |
---|
50 | |
---|
51 | public int getUsedAmount() { |
---|
52 | return 0; |
---|
53 | } |
---|
54 | |
---|
55 | public void setUsedAmount(int amount) { |
---|
56 | } |
---|
57 | |
---|
58 | public ResourceUnit toDiscrete() throws ClassNotFoundException { |
---|
59 | return this; |
---|
60 | } |
---|
61 | |
---|
62 | public int compareTo(ResourceUnit o) { |
---|
63 | return 0; |
---|
64 | } |
---|
65 | |
---|
66 | public String toString(){ |
---|
67 | StringBuffer buffer = new StringBuffer(); |
---|
68 | for(int i = 0; i < this.applicationNames.size(); i++){ |
---|
69 | buffer.append(this.applicationNames.get(i) + ", "); |
---|
70 | } |
---|
71 | |
---|
72 | return getName() + ": " + buffer.toString(); |
---|
73 | } |
---|
74 | } |
---|