1 package com.atlassian.plugin.loaders.classloading;
2
3 import java.io.File;
4
5 public class DeploymentUnit implements Comparable
6 {
7 private final File path;
8 private long lastModifiedAtTimeOfDeployment;
9
10 public DeploymentUnit(File path)
11 {
12 if (path == null)
13 {
14 throw new IllegalArgumentException("File should not be null!");
15 }
16 this.path = path;
17 this.lastModifiedAtTimeOfDeployment = path.lastModified();
18 }
19
20 public long lastModified()
21 {
22 return lastModifiedAtTimeOfDeployment;
23 }
24
25 public File getPath()
26 {
27 return path;
28 }
29
30 public int compareTo(Object o)
31 {
32 if (!(o instanceof DeploymentUnit))
33 return 1;
34
35 return path.compareTo(((DeploymentUnit) o).getPath());
36 }
37
38 public boolean equals(Object o)
39 {
40 if (this == o) return true;
41 if (!(o instanceof DeploymentUnit)) return false;
42
43 final DeploymentUnit deploymentUnit = (DeploymentUnit) o;
44
45 if (!path.equals(deploymentUnit.path)) return false;
46 if (lastModifiedAtTimeOfDeployment != deploymentUnit.lastModifiedAtTimeOfDeployment) return false;
47
48 return true;
49 }
50
51 public int hashCode()
52 {
53 int result;
54 result = path.hashCode();
55 result = 31 * result + (int) (lastModifiedAtTimeOfDeployment ^ (lastModifiedAtTimeOfDeployment >>> 32));
56 return result;
57 }
58
59 public String toString()
60 {
61 return "Unit: " + path.toString() + " (" + lastModifiedAtTimeOfDeployment + ")";
62 }
63 }