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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 18 | |
| 19 | import java.util.Collections; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 20 | import java.util.Set; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 21 | |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 22 | import com.google.common.base.MoreObjects; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 23 | import com.google.common.collect.ImmutableSet; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 24 | import org.onosproject.net.DeviceId; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 25 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Representation of a completed flow rule batch operation. |
| 28 | */ |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 29 | public class CompletedBatchOperation implements BatchOperationResult<FlowRule> { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 30 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 31 | private final boolean success; |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 32 | private final Set<FlowRule> failures; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 33 | private final Set<Long> failedIds; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 34 | private final DeviceId deviceId; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Creates a new batch completion result. |
| 38 | * |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 39 | * @param success indicates whether the completion is successful |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 40 | * @param failures set of any failures encountered |
| 41 | * @param failedIds (optional) set of failed operation ids |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 42 | * @param deviceId the device this operation completed for |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 43 | */ |
| 44 | public CompletedBatchOperation(boolean success, Set<? extends FlowRule> failures, |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 45 | Set<Long> failedIds, DeviceId deviceId) { |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 46 | this.success = success; |
| 47 | this.failures = ImmutableSet.copyOf(failures); |
| 48 | this.failedIds = ImmutableSet.copyOf(failedIds); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 49 | this.deviceId = deviceId; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 50 | } |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 51 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 52 | /** |
| 53 | * Creates a new batch completion result. |
| 54 | * |
| 55 | * @param success indicates whether the completion is successful. |
| 56 | * @param failures set of any failures encountered |
| 57 | */ |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 58 | public CompletedBatchOperation(boolean success, Set<? extends FlowRule> failures, |
| 59 | DeviceId deviceId) { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 60 | this.success = success; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 61 | this.failures = ImmutableSet.copyOf(failures); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 62 | this.failedIds = Collections.emptySet(); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 63 | this.deviceId = deviceId; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 66 | |
| 67 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 68 | @Override |
| 69 | public boolean isSuccess() { |
| 70 | return success; |
| 71 | } |
| 72 | |
| 73 | @Override |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 74 | public Set<FlowRule> failedItems() { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 75 | return failures; |
| 76 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 77 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 78 | public Set<Long> failedIds() { |
| 79 | return failedIds; |
| 80 | } |
| 81 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 82 | public DeviceId deviceId() { |
| 83 | return this.deviceId; |
| 84 | } |
| 85 | |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 86 | @Override |
| 87 | public String toString() { |
| 88 | return MoreObjects.toStringHelper(getClass()) |
| 89 | .add("success?", success) |
| 90 | .add("failedItems", failures) |
| 91 | .add("failedIds", failedIds) |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame^] | 92 | .add("deviceId", deviceId) |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 93 | .toString(); |
| 94 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 95 | } |