Satish K | f6d87cb | 2015-11-30 19:59:22 +0530 | [diff] [blame] | 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.iptopology.api;
|
| 17 |
|
| 18 | import org.onosproject.net.AbstractElement;
|
| 19 | import org.onosproject.net.Annotations;
|
| 20 | import org.onosproject.net.DeviceId;
|
| 21 | import org.onosproject.net.provider.ProviderId;
|
| 22 |
|
| 23 | import java.util.Objects;
|
| 24 |
|
| 25 | import static com.google.common.base.MoreObjects.toStringHelper;
|
| 26 |
|
| 27 | /**
|
| 28 | * Default ip device model implementation.
|
| 29 | */
|
| 30 | public class DefaultIpDevice extends AbstractElement implements IpDevice {
|
| 31 |
|
| 32 | private final Type type;
|
| 33 | private final IpDeviceIdentifier deviceIdentifier;
|
| 34 | private final DeviceTed deviceTed;
|
| 35 |
|
| 36 |
|
| 37 | /**
|
| 38 | * For Serialization.
|
| 39 | */
|
| 40 | private DefaultIpDevice() {
|
| 41 | this.type = null;
|
| 42 | this.deviceIdentifier = null;
|
| 43 | this.deviceTed = null;
|
| 44 | }
|
| 45 |
|
| 46 | /**
|
| 47 | * Creates a network element attributed to the specified provider.
|
| 48 | *
|
| 49 | * @param providerId identity of the provider
|
| 50 | * @param id device identifier
|
| 51 | * @param type device type
|
| 52 | * @param deviceIdentifier provides device identifier details
|
| 53 | * @param deviceTed device traffic engineering parameters
|
| 54 | * @param annotations optional key/value annotations
|
| 55 | */
|
| 56 | public DefaultIpDevice(ProviderId providerId, DeviceId id, Type type,
|
| 57 | IpDeviceIdentifier deviceIdentifier, DeviceTed deviceTed,
|
| 58 | Annotations... annotations) {
|
| 59 | super(providerId, id, annotations);
|
| 60 | this.type = type;
|
| 61 | this.deviceIdentifier = deviceIdentifier;
|
| 62 | this.deviceTed = deviceTed;
|
| 63 | }
|
| 64 |
|
| 65 | @Override
|
| 66 | public DeviceId id() {
|
| 67 | return (DeviceId) id;
|
| 68 | }
|
| 69 |
|
| 70 | @Override
|
| 71 | public Type type() {
|
| 72 | return type;
|
| 73 | }
|
| 74 |
|
| 75 | @Override
|
| 76 | public IpDeviceIdentifier deviceIdentifier() {
|
| 77 | return deviceIdentifier;
|
| 78 | }
|
| 79 |
|
| 80 | @Override
|
| 81 | public DeviceTed deviceTed() {
|
| 82 | return deviceTed; }
|
| 83 |
|
| 84 | @Override
|
| 85 | public int hashCode() {
|
| 86 | return Objects.hash(type, deviceIdentifier, deviceTed);
|
| 87 | }
|
| 88 |
|
| 89 | @Override
|
| 90 | public boolean equals(Object obj) {
|
| 91 | if (this == obj) {
|
| 92 | return true;
|
| 93 | }
|
| 94 |
|
| 95 | if (obj instanceof DefaultIpDevice) {
|
| 96 | final DefaultIpDevice other = (DefaultIpDevice) obj;
|
| 97 | return Objects.equals(this.id, other.id) &&
|
| 98 | Objects.equals(this.type, other.type) &&
|
| 99 | Objects.equals(this.deviceIdentifier, other.deviceIdentifier) &&
|
| 100 | Objects.equals(this.deviceTed, other.deviceTed);
|
| 101 | }
|
| 102 | return false;
|
| 103 | }
|
| 104 | @Override
|
| 105 | public String toString() {
|
| 106 | return toStringHelper(this)
|
| 107 | .omitNullValues()
|
| 108 | .add("id", id)
|
| 109 | .add("deviceIdentifier", deviceIdentifier)
|
| 110 | .add("deviceTed", deviceTed)
|
| 111 | .toString();
|
| 112 | }
|
| 113 | } |