blob: 9391cce02457c0ae3f01bdbd296c9401e9a9fff5 [file] [log] [blame]
Pengfei Lue0c02e22015-07-07 15:41:31 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Pengfei Lue0c02e22015-07-07 15:41:31 +08003 *
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.
Ray Milkey85267002016-11-16 11:06:35 -080015 *
16 * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
17 * Advisers: Keqiu Li and Heng Qi
18 * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
19 * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
Pengfei Lue0c02e22015-07-07 15:41:31 +080020 */
Thomas Vachuska9bb32352015-09-25 11:31:22 -070021package org.onosproject.acl;
Pengfei Lue0c02e22015-07-07 15:41:31 +080022
Jian Lid79fb942016-02-29 13:42:23 -080023import org.onlab.util.Identifier;
24
Pengfei Lue0c02e22015-07-07 15:41:31 +080025/**
26 * ACL rule identifier suitable as an external key.
27 * <p>This class is immutable.</p>
28 */
Jian Lid79fb942016-02-29 13:42:23 -080029public final class RuleId extends Identifier<Long> {
Pengfei Lue0c02e22015-07-07 15:41:31 +080030 /**
31 * Creates an ACL rule identifier from the specified long value.
32 *
33 * @param value long value
34 * @return ACL rule identifier
35 */
36 public static RuleId valueOf(long value) {
37 return new RuleId(value);
38 }
39
40 /**
41 * Constructor for serializer.
42 */
43 RuleId() {
Jian Lid79fb942016-02-29 13:42:23 -080044 super(0L);
Pengfei Lue0c02e22015-07-07 15:41:31 +080045 }
46
47 /**
48 * Constructs the ID corresponding to a given long value.
49 *
50 * @param value the underlying value of this ID
51 */
52 RuleId(long value) {
Jian Lid79fb942016-02-29 13:42:23 -080053 super(value);
Pengfei Lue0c02e22015-07-07 15:41:31 +080054 }
55
56 /**
57 * Returns the backing value.
58 *
59 * @return the value
60 */
61 public long fingerprint() {
Jian Lid79fb942016-02-29 13:42:23 -080062 return identifier;
Pengfei Lue0c02e22015-07-07 15:41:31 +080063 }
64
65 @Override
66 public String toString() {
Jian Lid79fb942016-02-29 13:42:23 -080067 return "0x" + Long.toHexString(identifier);
Pengfei Lue0c02e22015-07-07 15:41:31 +080068 }
69}