Michele Santuari | 05b882c | 2015-11-25 09:40:46 +0100 | [diff] [blame] | 1 | package org.onosproject.cli.net; |
| 2 | |
| 3 | import org.apache.karaf.shell.console.Completer; |
| 4 | import org.apache.karaf.shell.console.completer.StringsCompleter; |
| 5 | import org.onosproject.net.EncapsulationType; |
| 6 | |
| 7 | import java.util.List; |
| 8 | import java.util.SortedSet; |
| 9 | |
| 10 | /** |
| 11 | * Encapsulation type completer. |
| 12 | */ |
| 13 | public class EncapTypeCompleter implements Completer { |
| 14 | |
| 15 | @Override |
| 16 | public int complete(String buffer, int cursor, List<String> candidates) { |
| 17 | // Delegate string completer |
| 18 | StringsCompleter delegate = new StringsCompleter(); |
| 19 | SortedSet<String> strings = delegate.getStrings(); |
| 20 | |
| 21 | for (EncapsulationType encapType : EncapsulationType.values()) { |
| 22 | strings.add(encapType.toString()); |
| 23 | } |
| 24 | |
| 25 | // Now let the completer do the work for figuring out what to offer. |
| 26 | return delegate.complete(buffer, cursor, candidates); |
| 27 | } |
| 28 | } |