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