Srikanth Vavilapalli | 37a461b | 2015-04-07 15:12:32 -0700 | [diff] [blame] | 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.segmentrouting.grouphandler; |
| 17 | |
| 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | |
| 20 | import org.onosproject.net.PortNumber; |
| 21 | |
| 22 | /** |
| 23 | * Representation of policy group bucket identifier. Not exposed to |
| 24 | * the application and only to be used internally. |
| 25 | */ |
| 26 | public class GroupBucketIdentifier { |
| 27 | private int label; |
| 28 | private BucketOutputType type; |
| 29 | private PortNumber outPort; |
| 30 | private PolicyGroupIdentifier outGroup; |
| 31 | |
| 32 | protected enum BucketOutputType { |
| 33 | PORT, |
| 34 | GROUP |
| 35 | } |
| 36 | |
| 37 | protected GroupBucketIdentifier(int label, |
| 38 | PortNumber outPort) { |
| 39 | this.label = label; |
| 40 | this.type = BucketOutputType.PORT; |
| 41 | this.outPort = checkNotNull(outPort); |
| 42 | this.outGroup = null; |
| 43 | } |
| 44 | |
| 45 | protected GroupBucketIdentifier(int label, |
| 46 | PolicyGroupIdentifier outGroup) { |
| 47 | this.label = label; |
| 48 | this.type = BucketOutputType.GROUP; |
| 49 | this.outPort = null; |
| 50 | this.outGroup = checkNotNull(outGroup); |
| 51 | } |
| 52 | |
| 53 | protected int label() { |
| 54 | return this.label; |
| 55 | } |
| 56 | |
| 57 | protected BucketOutputType type() { |
| 58 | return this.type; |
| 59 | } |
| 60 | |
| 61 | protected PortNumber outPort() { |
| 62 | return this.outPort; |
| 63 | } |
| 64 | |
| 65 | protected PolicyGroupIdentifier outGroup() { |
| 66 | return this.outGroup; |
| 67 | } |
| 68 | } |
| 69 | |