blob: 96974dbf6d14b271b371838fe37615a2958f9b94 [file] [log] [blame]
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -08003 *
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.newoptical.cli;
17
18import java.util.List;
19import java.util.stream.Collectors;
20
21import org.onlab.util.Identifier;
22import org.onosproject.cli.AbstractChoicesCompleter;
23import org.onosproject.newoptical.OpticalConnectivity;
24import org.onosproject.newoptical.api.OpticalPathService;
25
26import static org.onosproject.cli.AbstractShellCommand.get;
27
28/**
29 * Completer for OpticalConnectivityId.
30 */
31public class OpticalConnectivityIdCompleter extends AbstractChoicesCompleter {
32
33 @Override
34 protected List<String> choices() {
35 OpticalPathService opticalPathService = get(OpticalPathService.class);
36
37 return opticalPathService.listConnectivity().stream()
38 .map(OpticalConnectivity::id)
39 .map(Identifier::id)
40 .map(String::valueOf)
41 .collect(Collectors.toList());
42 }
43
44}