org.crsh.cli.spi
Class Completion
java.lang.Object
org.crsh.cli.spi.Completion
- All Implemented Interfaces:
- Serializable, Iterable<Map.Entry<String,Boolean>>
public final class Completion
- extends Object
- implements Iterable<Map.Entry<String,Boolean>>, Serializable
An immutable object representing the complation of a value. A completion is described by:
- A prefix: an optional value that is relevant when more than a result is provided. The prefix value must be a
suffix of the completion prefix, it is used to shorten the completed prefix in order to make the completions
values shorter. For instance a path completion returning several values could be displayed in columns, however only
the last name of the path would be displayed and not the full path.
- A list of
Map.Entry<String, Boolean> map where the key is string value of the completion
and the boolean value tells whether the value is a suffix (i.e it ends the value) or not (i.e it can be further
more completed).
The following guidelines should be respected:
- An empty completion means no completion can be determined.
- A singleton map means the match was entire and completion will happen with the unique entry.
- A map containing a list of string values sharing a common prefix indicates to use this common prefix.
- A list containing strings with no common prefix (other than the empty string) instruct to display the list of
possible completions. In that case the completion result prefix is used to preped the returned suffixes when
displayed in rows.
- When a match is considered as entire (the entry value is set to true), the completion should contain a
trailing value that is usually a white space (but it could be a quote for quoted values).
Example: a completer that would complete colors could
- return the result ["lack ":true,"lue ":true] with the prefix "b" for the prefix "b".
- return the result ["e ":true] with the prefix "blu" for the prefix "blu".
- return the result [] for the prefix "z".
Example: a completer that would complete java packages could
- return the map ["ext":true,"ext.spi":false] for the prefix "java.t"
- See Also:
- Serialized Form
builder
public static Completion.Builder builder(String prefix)
create
public static Completion create()
create
public static Completion create(String prefix)
create
public static Completion create(String prefix,
String suffix,
boolean value)
create
public static Completion create(String suffix,
boolean value)
create
public static Completion create(String prefix,
Map<String,Boolean> suffixes)
iterator
public Iterator<Map.Entry<String,Boolean>> iterator()
- Specified by:
iterator in interface Iterable<Map.Entry<String,Boolean>>
getValues
public Set<String> getValues()
isEmpty
public boolean isEmpty()
get
public Boolean get(String key)
getSize
public int getSize()
getPrefix
public String getPrefix()
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
equals
public boolean equals(Object obj)
- Overrides:
equals in class Object
toString
public String toString()
- Overrides:
toString in class Object
Copyright © 2015 eXo Platform SAS. All Rights Reserved.