Committed by
Ray Milkey
[ONOS-3116] Port Pair Group Id for SFC
Change-Id: I2a71c2ada80d6c860454a4e4c700537387e8ae48
Showing
1 changed file
with
95 additions
and
0 deletions
1 | +/* | ||
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 | +package org.onosproject.vtnrsc; | ||
17 | + | ||
18 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
19 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
20 | + | ||
21 | +import java.util.UUID; | ||
22 | + | ||
23 | +import com.google.common.base.Objects; | ||
24 | + | ||
25 | +/** | ||
26 | + * Representation of a Port Pair Group ID. | ||
27 | + */ | ||
28 | +public final class PortPairGroupId { | ||
29 | + | ||
30 | + private final UUID portPairGroupId; | ||
31 | + | ||
32 | + /** | ||
33 | + * Private constructor for port pair group id. | ||
34 | + * | ||
35 | + * @param id UUID id of port pair group | ||
36 | + */ | ||
37 | + private PortPairGroupId(UUID id) { | ||
38 | + checkNotNull(id, "Port pair group id can not be null"); | ||
39 | + this.portPairGroupId = id; | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * Constructor to create port pair group id from UUID. | ||
44 | + * | ||
45 | + * @param id UUID of port pair group id | ||
46 | + * @return object of port pair group id | ||
47 | + */ | ||
48 | + public static PortPairGroupId portPairGroupId(UUID id) { | ||
49 | + return new PortPairGroupId(id); | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * Constructor to create port pair group id from string. | ||
54 | + * | ||
55 | + * @param id port pair group id in string | ||
56 | + * @return object of port pair group id | ||
57 | + */ | ||
58 | + public static PortPairGroupId portPairGroupId(String id) { | ||
59 | + return new PortPairGroupId(UUID.fromString(id)); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * Returns the value of port pair group id. | ||
64 | + * | ||
65 | + * @return port pair group id | ||
66 | + */ | ||
67 | + public UUID value() { | ||
68 | + return portPairGroupId; | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public boolean equals(Object obj) { | ||
73 | + if (this == obj) { | ||
74 | + return true; | ||
75 | + } | ||
76 | + | ||
77 | + if (obj.getClass() == this.getClass()) { | ||
78 | + PortPairGroupId that = (PortPairGroupId) obj; | ||
79 | + return Objects.equal(this.portPairGroupId, that.portPairGroupId); | ||
80 | + } | ||
81 | + return false; | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public int hashCode() { | ||
86 | + return Objects.hashCode(this.portPairGroupId); | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public String toString() { | ||
91 | + return toStringHelper(this) | ||
92 | + .add("portPairGroupId", portPairGroupId.toString()) | ||
93 | + .toString(); | ||
94 | + } | ||
95 | +} |
-
Please register or login to post a comment