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 |
Ray Milkey | 7b3981b | 2015-02-12 09:15:44 -0800 | [diff] [blame^] | 57 | * @param deviceId device id |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 58 | */ |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 59 | public CompletedBatchOperation(boolean success, Set<? extends FlowRule> failures, |
| 60 | DeviceId deviceId) { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 61 | this.success = success; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 62 | this.failures = ImmutableSet.copyOf(failures); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 63 | this.failedIds = Collections.emptySet(); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 64 | this.deviceId = deviceId; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 65 | } |
| 66 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 67 | |
| 68 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 69 | @Override |
| 70 | public boolean isSuccess() { |
| 71 | return success; |
| 72 | } |
| 73 | |
| 74 | @Override |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 75 | public Set<FlowRule> failedItems() { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 76 | return failures; |
| 77 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 78 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 79 | public Set<Long> failedIds() { |
| 80 | return failedIds; |
| 81 | } |
| 82 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 83 | public DeviceId deviceId() { |
| 84 | return this.deviceId; |
| 85 | } |
| 86 | |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 87 | @Override |
| 88 | public String toString() { |
| 89 | return MoreObjects.toStringHelper(getClass()) |
| 90 | .add("success?", success) |
| 91 | .add("failedItems", failures) |
| 92 | .add("failedIds", failedIds) |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 93 | .add("deviceId", deviceId) |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 94 | .toString(); |
| 95 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 96 | } |