blob: ba7e0eaf55cb23ddf6e811b500f2b53acc357c53 [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
Ray Milkeyc53a0d22018-10-09 15:06:38 -070021import org.apache.karaf.shell.api.action.lifecycle.Service;
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -080022import org.onlab.util.Identifier;
23import org.onosproject.cli.AbstractChoicesCompleter;
24import org.onosproject.newoptical.OpticalConnectivity;
25import org.onosproject.newoptical.api.OpticalPathService;
26
27import static org.onosproject.cli.AbstractShellCommand.get;
28
29/**
30 * Completer for OpticalConnectivityId.
31 */
Ray Milkeyc53a0d22018-10-09 15:06:38 -070032@Service
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -080033public class OpticalConnectivityIdCompleter extends AbstractChoicesCompleter {
34
35 @Override
36 protected List<String> choices() {
37 OpticalPathService opticalPathService = get(OpticalPathService.class);
38
39 return opticalPathService.listConnectivity().stream()
40 .map(OpticalConnectivity::id)
41 .map(Identifier::id)
42 .map(String::valueOf)
43 .collect(Collectors.toList());
44 }
45
46}