]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/build/BasicNameVersion.java
e0c915acdebe5d9ff208887739ad4d2ccfa66e83
[gpl/argeo-slc.git] / runtime / org.argeo.slc.specs / src / main / java / org / argeo / slc / build / 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.build;
18
19 public class BasicNameVersion implements NameVersion, Comparable<NameVersion> {
20 private String name;
21 private String version;
22
23 public BasicNameVersion() {
24 }
25
26 public BasicNameVersion(String name, String version) {
27 this.name = name;
28 this.version = version;
29 }
30
31 public BasicNameVersion(NameVersion nameVersion) {
32 this.name = nameVersion.getName();
33 this.version = nameVersion.getVersion();
34 }
35
36 public String getName() {
37 return name;
38 }
39
40 public void setName(String name) {
41 this.name = name;
42 }
43
44 public String getVersion() {
45 return version;
46 }
47
48 public void setVersion(String version) {
49 this.version = version;
50 }
51
52 @Override
53 public boolean equals(Object obj) {
54 if (obj instanceof NameVersion) {
55 NameVersion nameVersion = (NameVersion) obj;
56 return name.equals(nameVersion.getName())
57 && version.equals(nameVersion.getVersion());
58 } else
59 return false;
60 }
61
62 @Override
63 public int hashCode() {
64 return name.hashCode() + version.hashCode();
65 }
66
67 @Override
68 public String toString() {
69 return name + ":" + version;
70 }
71
72 public int compareTo(NameVersion o) {
73 if (o.getName().equals(name))
74 return version.compareTo(o.getVersion());
75 else
76 return name.compareTo(o.getName());
77 }
78
79 }