breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 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 | */ |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 16 | package org.onosproject.vpls.cli.completer; |
| 17 | |
Ray Milkey | 32ce0ed | 2018-10-10 15:39:24 -0700 | [diff] [blame] | 18 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 19 | import org.onosproject.cli.AbstractChoicesCompleter; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 20 | import org.onosproject.vpls.api.Vpls; |
| 21 | import org.onosproject.vpls.api.VplsData; |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 22 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 23 | import java.util.Collection; |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 24 | import java.util.List; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 25 | import java.util.stream.Collectors; |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 26 | |
| 27 | import static org.onosproject.cli.AbstractShellCommand.get; |
| 28 | |
| 29 | /** |
Luca Prete | dce16f8 | 2016-11-22 13:11:56 -0800 | [diff] [blame] | 30 | * VPLS name completer. |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 31 | */ |
Ray Milkey | 32ce0ed | 2018-10-10 15:39:24 -0700 | [diff] [blame] | 32 | @Service |
Luca Prete | dce16f8 | 2016-11-22 13:11:56 -0800 | [diff] [blame] | 33 | public class VplsNameCompleter extends AbstractChoicesCompleter { |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 34 | |
Ray Milkey | 074ba9b | 2018-02-06 10:23:41 -0800 | [diff] [blame] | 35 | protected Vpls vpls; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 36 | |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 37 | @Override |
Luca Prete | dce16f8 | 2016-11-22 13:11:56 -0800 | [diff] [blame] | 38 | public List<String> choices() { |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 39 | if (vpls == null) { |
| 40 | vpls = get(Vpls.class); |
| 41 | } |
| 42 | Collection<VplsData> vplses = vpls.getAllVpls(); |
| 43 | return vplses.stream().map(VplsData::name).collect(Collectors.toList()); |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 44 | } |
| 45 | } |