blob: c1da0ad7c722b24aa38b569447e8eb7f0ee2c14d [file] [log] [blame]
Sho SHIMIZU5cb438e2015-02-04 13:46:00 -08001/*
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 */
16package org.onosproject.net.intent.impl;
17
18import com.google.common.collect.ImmutableList;
19import org.onosproject.net.flow.FlowRuleBatchOperation;
20import org.onosproject.net.intent.Intent;
21
22import java.util.List;
23import java.util.Optional;
24
25import static com.google.common.base.Preconditions.checkNotNull;
26
27class Withdrawing implements IntentUpdate {
28
29 // TODO: define an interface and use it, instead of IntentManager
30 private final IntentManager intentManager;
31 private final Intent intent;
32 private final List<Intent> installables;
33
34 Withdrawing(IntentManager intentManager, Intent intent, List<Intent> installables) {
35 this.intentManager = checkNotNull(intentManager);
36 this.intent = checkNotNull(intent);
37 this.installables = ImmutableList.copyOf(installables);
38 }
39
40 @Override
41 public Optional<IntentUpdate> execute() {
42 List<FlowRuleBatchOperation> batches = intentManager.uninstallIntent(intent, installables);
43
44 return Optional.of(new Withdrawn(intentManager, intent, installables, batches));
45 }
46}