Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.flow; |
| 17 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 18 | |
| 19 | import java.util.Collections; |
| 20 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 21 | import java.util.Set; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 22 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 23 | import com.google.common.collect.ImmutableSet; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 24 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Representation of a completed flow rule batch operation. |
| 27 | */ |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 28 | public class CompletedBatchOperation implements BatchOperationResult<FlowRule> { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 29 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 30 | private final boolean success; |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 31 | private final Set<FlowRule> failures; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 32 | private final Set<Long> failedIds; |
| 33 | |
| 34 | /** |
| 35 | * Creates a new batch completion result. |
| 36 | * |
| 37 | * @param success indicates whether the completion is successful. |
| 38 | * @param failures set of any failures encountered |
| 39 | * @param failedIds (optional) set of failed operation ids |
| 40 | */ |
| 41 | public CompletedBatchOperation(boolean success, Set<? extends FlowRule> failures, |
| 42 | Set<Long> failedIds) { |
| 43 | this.success = success; |
| 44 | this.failures = ImmutableSet.copyOf(failures); |
| 45 | this.failedIds = ImmutableSet.copyOf(failedIds); |
| 46 | } |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 47 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 48 | /** |
| 49 | * Creates a new batch completion result. |
| 50 | * |
| 51 | * @param success indicates whether the completion is successful. |
| 52 | * @param failures set of any failures encountered |
| 53 | */ |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 54 | public CompletedBatchOperation(boolean success, Set<? extends FlowRule> failures) { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 55 | this.success = success; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 56 | this.failures = ImmutableSet.copyOf(failures); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 57 | this.failedIds = Collections.emptySet(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 60 | |
| 61 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 62 | @Override |
| 63 | public boolean isSuccess() { |
| 64 | return success; |
| 65 | } |
| 66 | |
| 67 | @Override |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 68 | public Set<FlowRule> failedItems() { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 69 | return failures; |
| 70 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 71 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 72 | public Set<Long> failedIds() { |
| 73 | return failedIds; |
| 74 | } |
| 75 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 76 | } |