Pier Ventre | f5d7236 | 2016-07-17 12:02:14 +0200 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Pier Ventre | f5d7236 | 2016-07-17 12:02:14 +0200 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.net.behaviour; |
| 18 | |
| 19 | import com.google.common.base.MoreObjects; |
| 20 | |
| 21 | import java.util.Objects; |
| 22 | |
| 23 | /** |
| 24 | * Represents for a mirroring name. |
| 25 | */ |
| 26 | public 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 | } |