Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 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. |
Ray Milkey | 8526700 | 2016-11-16 11:06:35 -0800 | [diff] [blame] | 15 | * |
| 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 Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 20 | */ |
Thomas Vachuska | 9bb3235 | 2015-09-25 11:31:22 -0700 | [diff] [blame] | 21 | package org.onosproject.acl; |
Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 22 | |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 23 | import org.onlab.util.Identifier; |
| 24 | |
Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 25 | /** |
| 26 | * ACL rule identifier suitable as an external key. |
| 27 | * <p>This class is immutable.</p> |
| 28 | */ |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 29 | public final class RuleId extends Identifier<Long> { |
Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 30 | /** |
| 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 Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 44 | super(0L); |
Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 45 | } |
| 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 Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 53 | super(value); |
Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the backing value. |
| 58 | * |
| 59 | * @return the value |
| 60 | */ |
| 61 | public long fingerprint() { |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 62 | return identifier; |
Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public String toString() { |
Jian Li | d79fb94 | 2016-02-29 13:42:23 -0800 | [diff] [blame] | 67 | return "0x" + Long.toHexString(identifier); |
Pengfei Lu | e0c02e2 | 2015-07-07 15:41:31 +0800 | [diff] [blame] | 68 | } |
| 69 | } |