blob: 4474b4cbc6ad25e0417cf3c3337c44ea57dc49fb [file] [log] [blame]
Avantika-Huawei73862d42016-05-12 18:58:06 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Avantika-Huawei73862d42016-05-12 18:58:06 +05303 *
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 */
16package org.onosproject.pce.pceservice;
17
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053018import org.onlab.util.Identifier;
Avantika-Huawei73862d42016-05-12 18:58:06 +053019import org.onosproject.net.resource.ResourceConsumer;
20
21import com.google.common.annotations.Beta;
Carmelo Casconef36a7ae2016-05-15 12:46:19 -070022import org.onosproject.net.resource.ResourceConsumerId;
Avantika-Huawei73862d42016-05-12 18:58:06 +053023
24/**
25 * Tunnel resource consumer identifier suitable to be used as a consumer id for
26 * resource allocations.
27 */
28@Beta
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053029public final class TunnelConsumerId extends Identifier<Long> implements ResourceConsumer {
Avantika-Huawei73862d42016-05-12 18:58:06 +053030
31 /**
32 * Creates a tunnel resource consumer identifier from the specified long value.
33 *
34 * @param value long value to be used as tunnel resource consumer id
35 * @return tunnel resource consumer identifier
36 */
37 public static TunnelConsumerId valueOf(long value) {
38 return new TunnelConsumerId(value);
39 }
40
41 /**
42 * Initializes object for serializer.
43 */
44 public TunnelConsumerId() {
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053045 super(0L);
Avantika-Huawei73862d42016-05-12 18:58:06 +053046 }
47
48 /**
49 * Constructs the tunnel resource consumer id corresponding to a given long
50 * value.
51 *
52 * @param value the underlying value in long representation of this tunnel
53 * resource consumer id
54 */
55 public TunnelConsumerId(long value) {
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053056 super(value);
Avantika-Huawei73862d42016-05-12 18:58:06 +053057 }
58
59 /**
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053060 * Returns the backing identifier value.
Avantika-Huawei73862d42016-05-12 18:58:06 +053061 *
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053062 * @return value backing identifier value
Avantika-Huawei73862d42016-05-12 18:58:06 +053063 */
64 public long value() {
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053065 return identifier;
Avantika-Huawei73862d42016-05-12 18:58:06 +053066 }
67
68 @Override
69 public String toString() {
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053070 return "0x" + Long.toHexString(identifier);
Avantika-Huawei73862d42016-05-12 18:58:06 +053071 }
72
Carmelo Casconef36a7ae2016-05-15 12:46:19 -070073 @Override
74 public ResourceConsumerId consumerId() {
Avantika-Huaweidbdf7722016-05-21 14:20:31 +053075 return ResourceConsumerId.of(this);
Carmelo Casconef36a7ae2016-05-15 12:46:19 -070076 }
Avantika-Huawei73862d42016-05-12 18:58:06 +053077}