blob: feb225c3c057a50ae91bea84ae64140e32dee72a [file] [log] [blame]
Jonathan Hartfce51472017-01-26 16:57:33 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Jonathan Hartfce51472017-01-26 16:57:33 -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 */
16
17package org.onosproject.cli.net.completer;
18
19import org.onosproject.cli.AbstractChoicesCompleter;
20import org.onosproject.incubator.net.intf.Interface;
21import org.onosproject.incubator.net.intf.InterfaceService;
22
23import java.util.List;
24import java.util.stream.Collectors;
25
26import static org.onlab.osgi.DefaultServiceDirectory.getService;
27
28/**
29 * Completer for interface names.
30 */
31public class InterfaceNameCompleter extends AbstractChoicesCompleter {
32
33 @Override
34 protected List<String> choices() {
35 InterfaceService interfaceService = getService(InterfaceService.class);
36
37 return interfaceService.getInterfaces().stream()
38 .map(Interface::name)
39 .filter(name -> !name.equals(Interface.NO_INTERFACE_NAME))
40 .collect(Collectors.toList());
41 }
42
43}