blob: 3ea27c6bf8255b01d1dbdf608150f6e8fc91142f [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/**
21 * Represents the common interface to encode a discrete resource to an integer,
22 * and to decode an integer to a discrete resource.
23 * This class is intended to be used only by the ResourceService implementation.
24 */
25@Beta
26public interface DiscreteResourceCodec {
27 /**
28 * Encodes the specified discrete resource to an integer.
29 *
30 * @param resource resource
31 * @return encoded integer
32 */
33 int encode(DiscreteResource resource);
34
35 /**
36 * Decodes the specified integer to a discrete resource.
37 *
38 * @param parent parent of the returned resource
39 * @param value encoded integer
40 * @return decoded discrete resource
41 */
42 DiscreteResource decode(DiscreteResourceId parent, int value);
43}