blob: 6d94bc28abad1724726f07f641117597401fe6ab [file] [log] [blame]
Madan Jampanic27b6b22016-02-05 11:36:31 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.iptopology.api;
18
19import static com.google.common.base.MoreObjects.toStringHelper;
20
21import java.util.Objects;
22
23/**
24 * Domain Identifier(32 Bit).
25 */
26public class DomainId {
27 private final int domainIdentifier;
28
29 /**
30 * Constructor to initialize domain identifier.
31 *
32 * @param domainIdentifier domain identifier
33 */
34 public DomainId(int domainIdentifier) {
35 this.domainIdentifier = domainIdentifier;
36 }
37
38 /**
39 * Obtain domain identifier.
40 *
41 * @return domain identifier
42 */
43 public int domainIdentifier() {
44 return domainIdentifier;
45 }
46
47 @Override
48 public int hashCode() {
49 return Objects.hash(domainIdentifier);
50 }
51
52 @Override
53 public boolean equals(Object obj) {
54 if (this == obj) {
55 return true;
56 }
57
58 if (obj instanceof DomainId) {
59 DomainId other = (DomainId) obj;
60 return Objects.equals(domainIdentifier, other.domainIdentifier);
61 }
62 return false;
63 }
64
65 @Override
66 public String toString() {
67 return toStringHelper(this)
68 .add("domainIdentifier", domainIdentifier)
69 .toString();
70 }
Satish Kf6d87cb2015-11-30 19:59:22 +053071}