]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/BasicNameVersion.java
Start / stop modules
[gpl/argeo-slc.git] / runtime / org.argeo.slc.specs / src / main / java / org / argeo / slc / BasicNameVersion.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.argeo.slc;
18
19 import java.io.Serializable;
20
21
22 public class BasicNameVersion implements NameVersion, Comparable<NameVersion>,
23 Serializable {
24 private static final long serialVersionUID = -5127304279136195127L;
25 private String name;
26 private String version;
27
28 public BasicNameVersion() {
29 }
30
31 public BasicNameVersion(String name, String version) {
32 this.name = name;
33 this.version = version;
34 }
35
36 public BasicNameVersion(NameVersion nameVersion) {
37 this.name = nameVersion.getName();
38 this.version = nameVersion.getVersion();
39 }
40
41 public String getName() {
42 return name;
43 }
44
45 public void setName(String name) {
46 this.name = name;
47 }
48
49 public String getVersion() {
50 return version;
51 }
52
53 public void setVersion(String version) {
54 this.version = version;
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (obj instanceof NameVersion) {
60 NameVersion nameVersion = (NameVersion) obj;
61 return name.equals(nameVersion.getName())
62 && version.equals(nameVersion.getVersion());
63 } else
64 return false;
65 }
66
67 @Override
68 public int hashCode() {
69 return name.hashCode() + version.hashCode();
70 }
71
72 @Override
73 public String toString() {
74 return name + ":" + version;
75 }
76
77 public int compareTo(NameVersion o) {
78 if (o.getName().equals(name))
79 return version.compareTo(o.getVersion());
80 else
81 return name.compareTo(o.getName());
82 }
83
84 }