58d05821126b4b86dfbbd7257e44412f5eb16212
[onosfw.git] /
1 /*
2  * Copyright 2015 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  */
16 package org.onosproject.pcepio.protocol;
17
18 import org.jboss.netty.buffer.ChannelBuffer;
19 import org.onosproject.pcepio.exceptions.PcepParseException;
20 import org.onosproject.pcepio.types.PcepObjectHeader;
21
22 /**
23  * Abstraction of an entity providing PCEP Bandwidth Object.
24  */
25 public interface PcepBandwidthObject {
26
27     /**
28      * Returns bandwidth value.
29      *
30      * @return bandwidth value
31      */
32     int getBandwidth();
33
34     /**
35      * Sets bandwidth with specified value.
36      *
37      * @param iBandwidth Bandwidth's value
38      */
39     void setBandwidth(int iBandwidth);
40
41     /**
42      * Writes the BandwidthObject into channel buffer.
43      *
44      * @param bb channel buffer
45      * @return Returns the writerIndex of this buffer
46      * @throws PcepParseException if bandwidth object header fails to write in channel buffer
47      */
48     int write(ChannelBuffer bb) throws PcepParseException;
49
50     /**
51      * Builder interface with get and set functions to build bandwidth object.
52      */
53     interface Builder {
54
55         /**
56          * Builds BandwidthObject.
57          *
58          * @return BandwidthObject
59          * @throws PcepParseException if build fails while creating PcepBandwidthObject
60          */
61         PcepBandwidthObject build() throws PcepParseException;
62
63         /**
64          * Returns bandwidth object header.
65          *
66          * @return bandwidth object header
67          */
68         PcepObjectHeader getBandwidthObjHeader();
69
70         /**
71          * Sets bandwidth object header and returns its builder.
72          *
73          * @param obj Bandwidth object header
74          * @return Builder by setting Bandwidth object header
75          */
76         Builder setBandwidthObjHeader(PcepObjectHeader obj);
77
78         /**
79          * Returns bandwidth value.
80          *
81          * @return bandwidth
82          */
83         int getBandwidth();
84
85         /**
86          * Sets bandwidth value and return its builder.
87          *
88          * @param iBandwidth bandwidth value
89          * @return Builder by setting bandwidth
90          */
91         Builder setBandwidth(int iBandwidth);
92
93         /**
94          * Sets P flag in Bandwidth object header and returns its builder.
95          *
96          * @param value boolean value to set P flag
97          * @return Builder by setting P flag
98          */
99         Builder setPFlag(boolean value);
100
101         /**
102          * Sets I flag in Bandwidth object header and returns its builder.
103          *
104          * @param value boolean value to set I flag
105          * @return Builder by setting I flag
106          */
107         Builder setIFlag(boolean value);
108     }
109 }