tom | 5f35f7c | 2014-09-08 18:38:19 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.cli.net; |
| 2 | |
| 3 | import org.apache.karaf.shell.console.Completer; |
| 4 | import org.apache.karaf.shell.console.completer.StringsCompleter; |
| 5 | import org.onlab.onos.net.MastershipRole; |
| 6 | |
| 7 | import java.util.List; |
| 8 | import java.util.SortedSet; |
| 9 | |
| 10 | /** |
| 11 | * Device mastership role completer. |
| 12 | */ |
| 13 | public class RoleCompleter implements Completer { |
| 14 | @Override |
| 15 | public int complete(String buffer, int cursor, List<String> candidates) { |
| 16 | // Delegate string completer |
| 17 | StringsCompleter delegate = new StringsCompleter(); |
| 18 | SortedSet<String> strings = delegate.getStrings(); |
| 19 | strings.add(MastershipRole.MASTER.toString().toLowerCase()); |
| 20 | strings.add(MastershipRole.STANDBY.toString().toLowerCase()); |
| 21 | strings.add(MastershipRole.NONE.toString().toLowerCase()); |
| 22 | |
| 23 | // Now let the completer do the work for figuring out what to offer. |
| 24 | return delegate.complete(buffer, cursor, candidates); |
| 25 | } |
| 26 | |
| 27 | } |