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 | |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 18 | import org.onosproject.cli.AbstractChoicesCompleter; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 19 | import org.onosproject.vpls.api.Vpls; |
| 20 | import org.onosproject.vpls.api.VplsData; |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 21 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 22 | import java.util.Collection; |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 23 | import java.util.List; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 24 | import java.util.stream.Collectors; |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 25 | |
| 26 | import static org.onosproject.cli.AbstractShellCommand.get; |
| 27 | |
| 28 | /** |
Luca Prete | dce16f8 | 2016-11-22 13:11:56 -0800 | [diff] [blame] | 29 | * VPLS name completer. |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 30 | */ |
Luca Prete | dce16f8 | 2016-11-22 13:11:56 -0800 | [diff] [blame] | 31 | public class VplsNameCompleter extends AbstractChoicesCompleter { |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 32 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 33 | protected static Vpls vpls; |
| 34 | |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 35 | @Override |
Luca Prete | dce16f8 | 2016-11-22 13:11:56 -0800 | [diff] [blame] | 36 | public List<String> choices() { |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 37 | 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()); |
breezestars | df95f9f | 2016-09-16 15:35:25 -0700 | [diff] [blame] | 42 | } |
| 43 | } |