f5ccb4a53cb6bcb07ef3d547d950fa9e76720fa8
[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 public class ModuleIdentifier {
11     private static final long serialVersionUID = 1L;
12     private final String factoryName, instanceName;
13
14     public ModuleIdentifier(String factoryName, String instanceName) {
15         if (factoryName == null)
16             throw new IllegalArgumentException(
17                     "Parameter 'factoryName' is null");
18         if (instanceName == null)
19             throw new IllegalArgumentException(
20                     "Parameter 'instanceName' is null");
21         this.factoryName = factoryName;
22         this.instanceName = instanceName;
23     }
24
25     public String getFactoryName() {
26         return factoryName;
27     }
28
29     public String getInstanceName() {
30         return instanceName;
31     }
32
33     @Override
34     public boolean equals(Object o) {
35         if (this == o)
36             return true;
37         if (o == null || getClass() != o.getClass())
38             return false;
39
40         ModuleIdentifier that = (ModuleIdentifier) o;
41
42         if (!factoryName.equals(that.factoryName))
43             return false;
44         if (!instanceName.equals(that.instanceName))
45             return false;
46
47         return true;
48     }
49
50     @Override
51     public int hashCode() {
52         int result = factoryName.hashCode();
53         result = 31 * result + instanceName.hashCode();
54         return result;
55     }
56
57     @Override
58     public String toString() {
59         return "ModuleIdentifier{" + "factoryName='" + factoryName + '\''
60                 + ", instanceName='" + instanceName + '\'' + '}';
61     }
62 }