]> git.somenet.org - pub/jan/lsdc.git/blob - src/at/ac/tuwien/lsdc/types/Application.java
Application now implements Comparable (compares timestamp of two apps) and SchedSimul...
[pub/jan/lsdc.git] / src / at / ac / tuwien / lsdc / types / Application.java
1 package at.ac.tuwien.lsdc.types;
2
3 public class Application implements Comparable<Application> {
4         
5         private int id;
6         private long timestamp;
7         private int size;
8         private int ram;
9         private int cpu;
10         private int duration;
11         
12         public Application(int id, long timestamp, int size, int ram, int cpu, int duration) {
13                 this.id = id;
14                 this.timestamp = timestamp;
15                 this.size = size;
16                 this.ram = ram;
17                 this.cpu = cpu;
18                 this.duration = duration;
19         }
20         
21         public int getID() {
22                 return id;
23         }
24
25         public long getTimestamp() {
26                 return timestamp;
27         }
28
29         public int getSize() {
30                 return size;
31         }
32
33         public int getRam() {
34                 return ram;
35         }
36
37         public int getCpu() {
38                 return cpu;
39         }
40
41         public int getDuration() {
42                 return duration;
43         }
44         
45         public String toString() {
46                 return new String("App ID: " + id + " Timestamp: " + timestamp + " size: " + size + " ram: " + ram + " cpu: " + cpu + " duration: " + duration);
47         }
48
49         @Override
50         public int compareTo(Application other) {
51                 final int BEFORE = -1;
52             final int EQUAL = 0;
53             final int AFTER = 1;
54
55             //this optimization is usually worthwhile, and can
56             //always be added
57             if ( this == other ) return EQUAL;
58             if ( this.getTimestamp() == other.getTimestamp() ) return EQUAL;
59             if ( this.getTimestamp() <  other.getTimestamp() ) return BEFORE;
60             if ( this.getTimestamp() >  other.getTimestamp() ) return AFTER;
61
62             return EQUAL;
63         }
64
65 }