blob: 7a972ffc58d9dca49193fe2cab4b1aa5d4c33075 [file] [log] [blame]
jaegonkimfbf61432019-03-16 09:37:53 +09001/*
2 * Copyright 2019-present Open Networking Foundation
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.workflow.cli;
17
18import org.apache.karaf.shell.api.action.lifecycle.Service;
19import org.onosproject.cli.AbstractChoicesCompleter;
20import org.onosproject.workflow.api.WorkplaceStore;
21
22import java.util.List;
23import java.util.stream.Collectors;
24
25import static org.onlab.osgi.DefaultServiceDirectory.getService;
26
27/**
28 * Workflow context name completer.
29 */
30@Service
31public class WorkFlowCtxtNameCompleter extends AbstractChoicesCompleter {
32 @Override
33 protected List<String> choices() {
34 WorkplaceStore workplaceStore = getService(WorkplaceStore.class);
35 return workplaceStore.getContexts().stream()
36 .map(workplace -> workplace.name())
37 .collect(Collectors.toList());
38 }
39}