blob: 2877ea17fa6a396c622c527574d8c1dd00a96e08 [file] [log] [blame]
Pengfei Lue0c02e22015-07-07 15:41:31 +08001/*
2 * Copyright 2015 Open Networking Laboratory
3 * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
4 * Advisers: Keqiu Li and Heng Qi
5 * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
6 * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
Thomas Vachuska9bb32352015-09-25 11:31:22 -070020package org.onosproject.acl;
Pengfei Lue0c02e22015-07-07 15:41:31 +080021
Jian Lid79fb942016-02-29 13:42:23 -080022import org.onlab.util.Identifier;
23
Pengfei Lue0c02e22015-07-07 15:41:31 +080024/**
25 * ACL rule identifier suitable as an external key.
26 * <p>This class is immutable.</p>
27 */
Jian Lid79fb942016-02-29 13:42:23 -080028public final class RuleId extends Identifier<Long> {
Pengfei Lue0c02e22015-07-07 15:41:31 +080029 /**
30 * Creates an ACL rule identifier from the specified long value.
31 *
32 * @param value long value
33 * @return ACL rule identifier
34 */
35 public static RuleId valueOf(long value) {
36 return new RuleId(value);
37 }
38
39 /**
40 * Constructor for serializer.
41 */
42 RuleId() {
Jian Lid79fb942016-02-29 13:42:23 -080043 super(0L);
Pengfei Lue0c02e22015-07-07 15:41:31 +080044 }
45
46 /**
47 * Constructs the ID corresponding to a given long value.
48 *
49 * @param value the underlying value of this ID
50 */
51 RuleId(long value) {
Jian Lid79fb942016-02-29 13:42:23 -080052 super(value);
Pengfei Lue0c02e22015-07-07 15:41:31 +080053 }
54
55 /**
56 * Returns the backing value.
57 *
58 * @return the value
59 */
60 public long fingerprint() {
Jian Lid79fb942016-02-29 13:42:23 -080061 return identifier;
Pengfei Lue0c02e22015-07-07 15:41:31 +080062 }
63
64 @Override
65 public String toString() {
Jian Lid79fb942016-02-29 13:42:23 -080066 return "0x" + Long.toHexString(identifier);
Pengfei Lue0c02e22015-07-07 15:41:31 +080067 }
68}