Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -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. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.core; |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 17 | |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 18 | import com.google.common.base.MoreObjects; |
| 19 | import org.onlab.util.Identifier; |
| 20 | |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 21 | /** |
| 22 | * Group identifier. |
| 23 | */ |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 24 | public class GroupId extends Identifier<Integer> { |
| 25 | |
| 26 | public GroupId(int id) { |
| 27 | super(id); |
| 28 | } |
| 29 | |
| 30 | // Constructor for serialization |
| 31 | private GroupId() { |
| 32 | super(0); |
| 33 | } |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 34 | |
| 35 | /** |
Saurav Das | 100e3b8 | 2015-04-30 11:12:10 -0700 | [diff] [blame] | 36 | * Returns a group ID as an integer value. |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 37 | * The method is not intended for use by application developers. |
| 38 | * Return data type may change in the future release. |
| 39 | * |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 40 | * @param id int value |
| 41 | * @return group ID |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 42 | */ |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 43 | public static GroupId valueOf(int id) { |
| 44 | return new GroupId(id); |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public String toString() { |
| 49 | return MoreObjects.toStringHelper(this) |
| 50 | .add("id", "0x" + Integer.toHexString(identifier)) |
| 51 | .toString(); |
| 52 | } |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 53 | } |