blob: e8e70d10aea719b48325a20e9738553e8ce40edc [file] [log] [blame]
Carmelo Cascone326ad2d2017-11-28 18:09:13 -08001/*
2 * Copyright 2017-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
17package org.onosproject.net.pi.runtime;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.net.DeviceId;
21
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * Global identifier of a PI entity applied to a device, unique in the scope of
26 * the whole network.
27 */
28@Beta
29public abstract class PiHandle<E extends PiEntity> {
30
31 private final DeviceId deviceId;
32 private final E piEntity;
33
34 protected PiHandle(DeviceId deviceId, E piEntity) {
35 this.deviceId = checkNotNull(deviceId);
36 this.piEntity = checkNotNull(piEntity);
37 }
38
39 /**
40 * Returns the device ID of this handle.
41 *
42 * @return device ID
43 */
44 public final DeviceId deviceId() {
45 return deviceId;
46 }
47
48 /**
49 * Returns the type of entity identified by this handle.
50 *
51 * @return PI entity type
52 */
53 public final PiEntityType entityType() {
54 return piEntity.piEntityType();
55 }
56
57 /**
58 * The entity to which this handle is associated.
59 *
60 * @return PI entity
61 */
62 public final E piEntity() {
63 return piEntity;
64 }
65
66 @Override
67 public abstract int hashCode();
68
69 @Override
70 public abstract boolean equals(Object obj);
71
72 @Override
73 public abstract String toString();
74}