BundleDiagInfos with getBundlesStateMap()
[odlparent.git] / bundles-test-lib / src / main / java / org / opendaylight / odlparent / bundlestest / lib / BundleSymbolicNameWithVersion.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.odlparent.bundlestest.lib;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.io.Serializable;
13
14 /**
15  * Bundle's symbolic name + its version.
16  *
17  * @author Michael Vorburger.ch
18  */
19 public final class BundleSymbolicNameWithVersion implements Serializable {
20     private static final long serialVersionUID = 1L;
21
22     private final String symbolicName;
23     private final String version;
24
25     public BundleSymbolicNameWithVersion(String symbolicName, String version) {
26         this.symbolicName = requireNonNull(symbolicName, "symbolicName");
27         this.version = requireNonNull(version, "version");
28     }
29
30     public String getSymbolicName() {
31         return symbolicName;
32     }
33
34     public String getVersion() {
35         return version;
36     }
37
38     @Override
39     public int hashCode() {
40         final int prime = 31;
41         int result = 1;
42         result = prime * result + symbolicName.hashCode();
43         result = prime * result + version.hashCode();
44         return result;
45     }
46
47     @Override
48     public boolean equals(Object obj) {
49         if (this == obj) {
50             return true;
51         }
52         if (obj == null) {
53             return false;
54         }
55         if (!(obj instanceof BundleSymbolicNameWithVersion)) {
56             return false;
57         }
58         BundleSymbolicNameWithVersion other = (BundleSymbolicNameWithVersion) obj;
59         if (!symbolicName.equals(other.symbolicName)) {
60             return false;
61         }
62         if (!version.equals(other.version)) {
63             return false;
64         }
65         return true;
66     }
67
68     @Override
69     public String toString() {
70         return symbolicName + ":" + version;
71     }
72
73 }