Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [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 | */ |
| 16 | package org.onosproject.net.resource; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | |
| 20 | /** |
Sho SHIMIZU | cf98b1a | 2016-05-18 15:11:31 -0700 | [diff] [blame] | 21 | * Represents the common interface to encode an object of the specified type to an integer, |
| 22 | * and to decode an integer to an object of the specified type. |
Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [diff] [blame] | 23 | * This class is intended to be used only by the ResourceService implementation. |
| 24 | */ |
| 25 | @Beta |
Sho SHIMIZU | cf98b1a | 2016-05-18 15:11:31 -0700 | [diff] [blame] | 26 | public interface DiscreteResourceCodec<T> { |
Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [diff] [blame] | 27 | /** |
Sho SHIMIZU | cf98b1a | 2016-05-18 15:11:31 -0700 | [diff] [blame] | 28 | * Encodes the specified object to an integer. |
Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [diff] [blame] | 29 | * |
| 30 | * @param resource resource |
| 31 | * @return encoded integer |
| 32 | */ |
Sho SHIMIZU | cf98b1a | 2016-05-18 15:11:31 -0700 | [diff] [blame] | 33 | int encode(T resource); |
Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
Sho SHIMIZU | cf98b1a | 2016-05-18 15:11:31 -0700 | [diff] [blame] | 36 | * Decodes the specified integer to an object. |
Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [diff] [blame] | 37 | * |
Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [diff] [blame] | 38 | * @param value encoded integer |
| 39 | * @return decoded discrete resource |
| 40 | */ |
Sho SHIMIZU | cf98b1a | 2016-05-18 15:11:31 -0700 | [diff] [blame] | 41 | T decode(int value); |
Sho SHIMIZU | f01fe1c | 2016-05-02 14:41:18 -0700 | [diff] [blame] | 42 | } |