Next version of JABA
[jabaws.git] / engine / compbio / engine / ClusterJobId.java
1 /* Copyright (c) 2009 Peter Troshin\r
2  *  \r
3  *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \r
4  * \r
5  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
6  *  Apache License version 2 as published by the Apache Software Foundation\r
7  * \r
8  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
9  *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
10  *  License for more details.\r
11  * \r
12  *  A copy of the license is in apache_license.txt. It is also available here:\r
13  * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
14  * \r
15  * Any republication or derived work distributed in source code form\r
16  * must include this copyright and license notice.\r
17  */\r
18 \r
19 package compbio.engine;\r
20 \r
21 import compbio.util.Util;\r
22 import compbio.util.annotation.Immutable;\r
23 \r
24 @Immutable\r
25 public class ClusterJobId {\r
26 \r
27         final String jobId;\r
28 \r
29         public ClusterJobId(String jobId) {\r
30                 if (Util.isEmpty(jobId)) {\r
31                         throw new NullPointerException("JobId must be provided!");\r
32                 }\r
33                 if (compbio.engine.client.Util.isValidJobId(jobId)) {\r
34                         throw new IllegalArgumentException(\r
35                                         "JobId is expected but taskid seems to be provided! "\r
36                                                         + jobId);\r
37                 }\r
38                 this.jobId = jobId;\r
39         }\r
40 \r
41         public String getJobId() {\r
42                 return jobId;\r
43         }\r
44 \r
45         @Override\r
46         public int hashCode() {\r
47                 final int prime = 31;\r
48                 int result = 1;\r
49                 result = prime * result + ((jobId == null) ? 0 : jobId.hashCode());\r
50                 return result;\r
51         }\r
52 \r
53         @Override\r
54         public boolean equals(Object obj) {\r
55                 if (this == obj)\r
56                         return true;\r
57                 if (obj == null)\r
58                         return false;\r
59                 if (getClass() != obj.getClass())\r
60                         return false;\r
61                 ClusterJobId other = (ClusterJobId) obj;\r
62                 if (jobId == null) {\r
63                         if (other.jobId != null)\r
64                                 return false;\r
65                 } else if (!jobId.equals(other.jobId))\r
66                         return false;\r
67                 return true;\r
68         }\r
69 \r
70 }\r