blob: 6cd5a8151afd3a12e009e9660373fd6ecd55d9c5 [file] [log] [blame]
Phaneendra Mandaefb38752015-12-04 00:43:38 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Phaneendra Mandaefb38752015-12-04 00:43:38 +05303 *
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 */
16package org.onosproject.net;
17
18import java.util.Objects;
19
20import com.google.common.base.MoreObjects;
21
22/*
23 * Representation of NSH context header value
24 */
25public final class NshContextHeader {
26
27 private final int nshContextHeader;
28
29 /**
30 * Default constructor.
31 *
32 * @param nshContextHeader nsh context header value.
33 */
34 private NshContextHeader(int nshContextHeader) {
35 this.nshContextHeader = nshContextHeader;
36 }
37
38 /**
39 * Returns the NshContextHeader by setting its value.
40 *
41 * @param nshContextHeader nsh context header value.
42 * @return NshContextHeader
43 */
44 public static NshContextHeader of(int nshContextHeader) {
45 return new NshContextHeader(nshContextHeader);
46 }
47
48
49 /**
50 * Returns nsh context header value.
51 *
52 * @return the nsh context header
53 */
54 public int nshContextHeader() {
55 return nshContextHeader;
56 }
57
58
59 @Override
60 public int hashCode() {
61 return Objects.hash(nshContextHeader);
62 }
63
64 @Override
65 public boolean equals(Object obj) {
66 if (this == obj) {
67 return true;
68 }
69 if (!(obj instanceof NshContextHeader)) {
70 return false;
71 }
72 final NshContextHeader other = (NshContextHeader) obj;
73 return Objects.equals(this.nshContextHeader, other.nshContextHeader);
74 }
75
76 @Override
77 public String toString() {
78 return MoreObjects.toStringHelper(this)
79 .add("nshContextHeader", nshContextHeader)
80 .toString();
81 }
82}
83