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