Madan Jampani | c27b6b2 | 2016-02-05 11:36:31 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Madan Jampani | c27b6b2 | 2016-02-05 11:36:31 -0800 | [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 | package org.onosproject.iptopology.api; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | import org.onosproject.net.Element; |
| 23 | |
| 24 | /** |
| 25 | * Default Device interface implementation. |
| 26 | */ |
| 27 | public class DefaultDeviceIntf implements DeviceIntf { |
| 28 | |
| 29 | private final Element element; |
| 30 | private final DeviceInterface deviceInterface; |
| 31 | |
| 32 | /** |
| 33 | * Constructor to initialize device interface parameters. |
| 34 | * |
| 35 | * @param element parent network element |
| 36 | * @param deviceInterface device interface |
| 37 | */ |
| 38 | public DefaultDeviceIntf(Element element, DeviceInterface deviceInterface) { |
| 39 | this.element = element; |
| 40 | this.deviceInterface = deviceInterface; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public Element element() { |
| 45 | return element; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public DeviceInterface deviceInterface() { |
| 50 | return deviceInterface; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public int hashCode() { |
| 55 | return Objects.hash(element, deviceInterface); |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public boolean equals(Object obj) { |
| 60 | if (this == obj) { |
| 61 | return true; |
| 62 | } |
| 63 | |
| 64 | if (obj instanceof DefaultDeviceIntf) { |
| 65 | final DefaultDeviceIntf other = (DefaultDeviceIntf) obj; |
| 66 | return Objects.equals(this.element.id(), other.element.id()) |
| 67 | && Objects.equals(this.deviceInterface, other.deviceInterface); |
| 68 | } |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public String toString() { |
| 74 | return toStringHelper(this) |
| 75 | .add("element", element.id()) |
| 76 | .add("deviceInterface", deviceInterface) |
| 77 | .toString(); |
| 78 | } |
Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 79 | } |