alshabib | 144a294 | 2014-09-25 18:44:02 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cli.net; |
| 2 | |
| 3 | import java.util.List; |
| 4 | import java.util.SortedSet; |
| 5 | |
| 6 | import org.apache.karaf.shell.console.Completer; |
| 7 | import org.apache.karaf.shell.console.completer.StringsCompleter; |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 8 | import org.onlab.onos.net.flow.FlowEntry.FlowEntryState; |
alshabib | 144a294 | 2014-09-25 18:44:02 -0700 | [diff] [blame] | 9 | |
| 10 | /** |
| 11 | * Device ID completer. |
| 12 | */ |
| 13 | public class FlowRuleStatusCompleter 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 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 19 | FlowEntryState[] states = FlowEntryState.values(); |
alshabib | 144a294 | 2014-09-25 18:44:02 -0700 | [diff] [blame] | 20 | SortedSet<String> strings = delegate.getStrings(); |
| 21 | for (int i = 0; i < states.length; i++) { |
| 22 | strings.add(states[i].toString().toLowerCase()); |
| 23 | } |
| 24 | strings.add(FlowsListCommand.ANY); |
| 25 | |
| 26 | // Now let the completer do the work for figuring out what to offer. |
| 27 | return delegate.complete(buffer, cursor, candidates); |
| 28 | } |
| 29 | |
| 30 | } |