blob: 7e32137c436f55802a02dc9b77f7619165f35a76 [file] [log] [blame]
Thomas Vachuskabf916ea2015-05-20 18:24:34 -07001/*
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.incubator.net.tunnel;
jcc4a20a5f2015-04-30 15:43:39 +080018
19import java.util.Objects;
20
21/**
22 * Represents for a unique tunnel name. TunnelId is generated by ONOS while
23 * TunnelName is given by producer. The consumer can borrow tunnels with
24 * TunnelId or TunnelName.
25 */
26public final class TunnelName {
27 private final String str;
28
29 // Default constructor for serialization
30 private TunnelName(String tunnelName) {
31 this.str = tunnelName;
32 }
33
34
35 /**
36 * Creates a tunnel name using the supplied URI string.
37 *
38 * @param tunnelName tunnel name string
39 * @return tunnel name object
40 */
41 public static TunnelName tunnelName(String tunnelName) {
42 return new TunnelName(tunnelName);
43 }
44
45 /**
46 * The string of tunnel name.
47 *
48 * @return the string of tunnel name
49 */
50 public String value() {
51 return str;
52 }
53
54 @Override
55 public int hashCode() {
56 return Objects.hash(str);
57 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj) {
62 return true;
63 }
64 if (obj instanceof TunnelName) {
65 final TunnelName that = (TunnelName) obj;
66 return this.getClass() == that.getClass()
67 && Objects.equals(this.str, that.str);
68 }
69 return false;
70 }
71
72 @Override
73 public String toString() {
74 return str;
75 }
76}