600c9eeaec62ff71e504d52ffe2bd79f4c8d24e9
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / ModuleIdentifier.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, 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.controller.config.api;
9
10 import org.opendaylight.yangtools.concepts.Identifier;
11
12 public class ModuleIdentifier implements Identifier {
13     private static final long serialVersionUID = 1L;
14     private final String factoryName;
15     private final String instanceName;
16
17     public ModuleIdentifier(final String factoryName, final String instanceName) {
18         if (factoryName == null) {
19             throw new IllegalArgumentException("Parameter 'factoryName' is null");
20         }
21         if (instanceName == null) {
22             throw new IllegalArgumentException("Parameter 'instanceName' is null");
23         }
24         this.factoryName = factoryName;
25         this.instanceName = instanceName;
26     }
27
28     public String getFactoryName() {
29         return factoryName;
30     }
31
32     public String getInstanceName() {
33         return instanceName;
34     }
35
36     @Override
37     public boolean equals(final Object object) {
38         if (this == object) {
39             return true;
40         }
41         if (object == null || getClass() != object.getClass()) {
42             return false;
43         }
44
45         ModuleIdentifier that = (ModuleIdentifier) object;
46
47         if (!factoryName.equals(that.factoryName)) {
48             return false;
49         }
50         if (!instanceName.equals(that.instanceName)) {
51             return false;
52         }
53
54         return true;
55     }
56
57     @Override
58     public int hashCode() {
59         int result = factoryName.hashCode();
60         result = 31 * result + instanceName.hashCode();
61         return result;
62     }
63
64     @Override
65     public String toString() {
66         return "ModuleIdentifier{" + "factoryName='" + factoryName + '\''
67                 + ", instanceName='" + instanceName + '\'' + '}';
68     }
69 }