blob: 468d7d65190d2dfcda02722228d85b3f9d247c57 [file] [log] [blame]
breezestarsdf95f9f2016-09-16 15:35:25 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
breezestarsdf95f9f2016-09-16 15:35:25 -07003 *
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 */
breezestarsdf95f9f2016-09-16 15:35:25 -070016package org.onosproject.vpls.cli.completer;
17
breezestarsdf95f9f2016-09-16 15:35:25 -070018import org.onosproject.cli.AbstractChoicesCompleter;
Yi Tsengf4e13e32017-03-30 15:38:39 -070019import org.onosproject.vpls.api.Vpls;
20import org.onosproject.vpls.api.VplsData;
breezestarsdf95f9f2016-09-16 15:35:25 -070021
Yi Tsengf4e13e32017-03-30 15:38:39 -070022import java.util.Collection;
breezestarsdf95f9f2016-09-16 15:35:25 -070023import java.util.List;
Yi Tsengf4e13e32017-03-30 15:38:39 -070024import java.util.stream.Collectors;
breezestarsdf95f9f2016-09-16 15:35:25 -070025
26import static org.onosproject.cli.AbstractShellCommand.get;
27
28/**
Luca Pretedce16f82016-11-22 13:11:56 -080029 * VPLS name completer.
breezestarsdf95f9f2016-09-16 15:35:25 -070030 */
Luca Pretedce16f82016-11-22 13:11:56 -080031public class VplsNameCompleter extends AbstractChoicesCompleter {
breezestarsdf95f9f2016-09-16 15:35:25 -070032
Yi Tsengf4e13e32017-03-30 15:38:39 -070033 protected static Vpls vpls;
34
breezestarsdf95f9f2016-09-16 15:35:25 -070035 @Override
Luca Pretedce16f82016-11-22 13:11:56 -080036 public List<String> choices() {
Yi Tsengf4e13e32017-03-30 15:38:39 -070037 if (vpls == null) {
38 vpls = get(Vpls.class);
39 }
40 Collection<VplsData> vplses = vpls.getAllVpls();
41 return vplses.stream().map(VplsData::name).collect(Collectors.toList());
breezestarsdf95f9f2016-09-16 15:35:25 -070042 }
43}