2 * Copyright 2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.incubator.net.virtual;
18 import org.onlab.packet.ChassisId;
19 import org.onosproject.net.DefaultDevice;
20 import org.onosproject.net.DeviceId;
21 import org.onosproject.net.provider.ProviderId;
23 import java.util.Objects;
25 import static com.google.common.base.MoreObjects.*;
28 * Default representation of a virtual device.
30 public class DefaultVirtualDevice extends DefaultDevice implements VirtualDevice {
32 private static final String VIRTUAL = "virtual";
33 private static final ProviderId PID = new ProviderId(VIRTUAL, VIRTUAL);
35 private final NetworkId networkId;
38 * Creates a network element attributed to the specified provider.
40 * @param networkId network identifier
41 * @param id device identifier
43 public DefaultVirtualDevice(NetworkId networkId, DeviceId id) {
44 super(PID, id, Type.VIRTUAL, VIRTUAL, VIRTUAL, VIRTUAL, VIRTUAL,
46 this.networkId = networkId;
50 public NetworkId networkId() {
55 public int hashCode() {
56 return 31 * super.hashCode() + Objects.hash(networkId);
60 public boolean equals(Object obj) {
64 if (obj instanceof DefaultVirtualDevice) {
65 DefaultVirtualDevice that = (DefaultVirtualDevice) obj;
66 return super.equals(that) && Objects.equals(this.networkId, that.networkId);
72 public String toString() {
73 return toStringHelper(this).add("networkId", networkId).toString();