summaryrefslogtreecommitdiffstats
path: root/src/main/java/derms/replica2/Resource.java
blob: 31d40bc3f206569c8840bc2eee3e8621870cd790 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package derms.replica2;

import java.io.Serializable;

class Resource implements Serializable {
  ResourceID id;
  ResourceType type;
  int duration;
  boolean isBorrowed;
  CoordinatorID borrower;
  int borrowDuration;

  Resource(ResourceID id, ResourceType type, int duration, boolean isBorrowed, CoordinatorID borrower, int borrowDuration) {
    this.id = id;
    this.type = type;
    this.duration = duration;
    this.isBorrowed = isBorrowed;
    this.borrower = borrower;
    this.borrowDuration = borrowDuration;
  }

  Resource(ResourceID id, ResourceType type, int duration) {
    this(id, type, duration, false, new CoordinatorID(), -1);
  }

  Resource() {
    this(new ResourceID(), ResourceType.AMBULANCE, 0);
  }

  @Override
  public int hashCode() {
    return id.hashCode();
  }

  @Override
  public String toString() {
    return id+" "+duration;
  }
}