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