blob: 373b41bee0816ce74f7911247662efd717cf2c19 [file] [log] [blame]
Esin Karaman971fb7f2017-12-28 13:44:52 +00001/*
2 * Copyright 2018-present Open Networking Foundation
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
18package org.onosproject.drivers.bmv2.api.runtime;
19
20import org.onosproject.net.DeviceId;
21
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * Global identifier of an entity applied to a BMv2 device.
26 * @param <E> an object extending Bmv2Entity
27 */
28public abstract class Bmv2Handle<E extends Bmv2Entity> {
29
30 private final DeviceId deviceId;
31 private final E bmv2Entity;
32
33 protected Bmv2Handle(DeviceId deviceId, E bmv2Entity) {
34 this.deviceId = checkNotNull(deviceId);
35 this.bmv2Entity = checkNotNull(bmv2Entity);
36 }
37
38 /**
39 * Returns the device ID of this handle.
40 *
41 * @return device ID
42 */
43 public final DeviceId deviceId() {
44 return deviceId;
45 }
46
47 /**
48 * Returns the type of entity identified by this handle.
49 *
50 * @return BMv2 entity type
51 */
52 public final Bmv2EntityType entityType() {
53 return bmv2Entity.entityType();
54 }
55
56 /**
57 * The entity to which this handle is associated.
58 *
59 * @return Bmv2 entity
60 */
61 public final E bmv2Entity() {
62 return bmv2Entity;
63 }
64
65 @Override
66 public abstract int hashCode();
67
68 @Override
69 public abstract boolean equals(Object obj);
70
71 @Override
72 public abstract String toString();
73}