blob: 7dc1c5e0a20d49e06c40590db1bd41d9803fda1e [file] [log] [blame]
Sho SHIMIZUf01fe1c2016-05-02 14:41:18 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
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 */
16package org.onosproject.net.resource;
17
18import com.google.common.annotations.Beta;
19
20/**
Sho SHIMIZUcf98b1a2016-05-18 15:11:31 -070021 * 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 SHIMIZUf01fe1c2016-05-02 14:41:18 -070023 * This class is intended to be used only by the ResourceService implementation.
24 */
25@Beta
Sho SHIMIZUcf98b1a2016-05-18 15:11:31 -070026public interface DiscreteResourceCodec<T> {
Sho SHIMIZUf01fe1c2016-05-02 14:41:18 -070027 /**
Sho SHIMIZUcf98b1a2016-05-18 15:11:31 -070028 * Encodes the specified object to an integer.
Sho SHIMIZUf01fe1c2016-05-02 14:41:18 -070029 *
30 * @param resource resource
31 * @return encoded integer
32 */
Sho SHIMIZUcf98b1a2016-05-18 15:11:31 -070033 int encode(T resource);
Sho SHIMIZUf01fe1c2016-05-02 14:41:18 -070034
35 /**
Sho SHIMIZUcf98b1a2016-05-18 15:11:31 -070036 * Decodes the specified integer to an object.
Sho SHIMIZUf01fe1c2016-05-02 14:41:18 -070037 *
Sho SHIMIZUf01fe1c2016-05-02 14:41:18 -070038 * @param value encoded integer
39 * @return decoded discrete resource
40 */
Sho SHIMIZUcf98b1a2016-05-18 15:11:31 -070041 T decode(int value);
Sho SHIMIZUf01fe1c2016-05-02 14:41:18 -070042}