org.crsh.cli.spi
Class Completion

java.lang.Object
  extended by 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:

  1. 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.
  2. 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:

Example: a completer that would complete colors could

Example: a completer that would complete java packages could

See Also:
Serialized Form

Nested Class Summary
static class Completion.Builder
           
 
Field Summary
private static Completion EMPTY
          .
private  String prefix
          .
private  Map<String,Boolean> values
          .
 
Constructor Summary
private Completion(String prefix, Map<String,Boolean> values)
           
 
Method Summary
static Completion.Builder builder(String prefix)
           
static Completion create()
           
static Completion create(String prefix)
           
static Completion create(String suffix, boolean value)
           
static Completion create(String prefix, Map<String,Boolean> suffixes)
           
static Completion create(String prefix, String suffix, boolean value)
           
 boolean equals(Object obj)
           
 Boolean get(String key)
           
 String getPrefix()
           
 int getSize()
           
 Set<String> getValues()
           
 int hashCode()
           
 boolean isEmpty()
           
 Iterator<Map.Entry<String,Boolean>> iterator()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

private static final Completion EMPTY
.


prefix

private final String prefix
.


values

private final Map<String,Boolean> values
.

Constructor Detail

Completion

private Completion(String prefix,
                   Map<String,Boolean> values)
Method Detail

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.