eae201d38b573064d5b1bcd2377118491f5711d3
[vfc/nfvo/wfengine.git] /
1 /*******************************************************************************
2  * Copyright (c) 2012-2013 University of Stuttgart.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and the Apache License 2.0 which both accompany this distribution,
6  * and are available at http://www.eclipse.org/legal/epl-v10.html
7  * and http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.repository.datatypes;
13
14 public class TypeWithShortName implements Comparable<TypeWithShortName> {
15         
16         private final String type;
17         // we could have used "URI" as type here but this seems to be unnecessary
18         // overhead
19         
20         // this is a kind of ID
21         private final String shortName;
22         
23         
24         public TypeWithShortName(String type, String shortName) {
25                 this.type = type;
26                 this.shortName = shortName;
27         }
28         
29         public String getType() {
30                 return this.type;
31         }
32         
33         public String getShortName() {
34                 return this.shortName;
35         }
36         
37         @Override
38         public boolean equals(Object o) {
39                 if (o instanceof TypeWithShortName) {
40                         return ((TypeWithShortName) o).getType().equals(this.getType());
41                 } else {
42                         return false;
43                 }
44         }
45         
46         @Override
47         public int hashCode() {
48                 return this.getType().hashCode();
49         }
50         
51         @Override
52         public int compareTo(TypeWithShortName o) {
53                 int c = this.getShortName().compareTo(o.getShortName());
54                 if (c == 0) {
55                         // not sure if this will ever happen
56                         c = this.getType().compareTo(o.getType());
57                 }
58                 return c;
59         }
60 }