blob: 355b8736860f4aa1eeaa2ce2e89908b112ef772e [file] [log] [blame]
Pier Ventref5d72362016-07-17 12:02:14 +02001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Pier Ventref5d72362016-07-17 12:02:14 +02003 *
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.net.behaviour;
18
19import com.google.common.base.MoreObjects;
20
21import java.util.Objects;
22
23/**
24 * Represents for a mirroring name.
25 */
26public final class MirroringName {
27
28 private final String name;
29
30 private MirroringName(String name) {
31 this.name = name;
32 }
33
34 /**
35 * Creates a mirroring name using the supplied string.
36 *
37 * @param name mirroring name
38 * @return a port mirroring name
39 */
40 public static MirroringName mirroringName(String name) {
41 return new MirroringName(name);
42 }
43
44 /**
45 * Returns the mirroring name string.
46 *
47 * @return name string
48 */
49 public String name() {
50 return name;
51 }
52
53 @Override
54 public int hashCode() {
55 return name.hashCode();
56 }
57
58 @Override
59 public boolean equals(Object obj) {
60 if (this == obj) {
61 return true;
62 }
63 if (obj instanceof MirroringName) {
64 final MirroringName that = (MirroringName) obj;
65 return this.getClass() == that.getClass() &&
66 Objects.equals(this.name, that.name);
67 }
68 return false;
69 }
70
71 @Override
72 public String toString() {
73 return MoreObjects.toStringHelper(getClass())
74 .add("name", name)
75 .toString();
76 }
77
78}