All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xipki.shell.DynamicEnumCompleter Maven / Gradle / Ivy

There is a newer version: 6.3.4
Show newest version
// Copyright (c) 2013-2023 xipki. All rights reserved.
// License Apache License 2.0

package org.xipki.shell;

import org.apache.karaf.shell.api.console.CommandLine;
import org.apache.karaf.shell.api.console.Completer;
import org.apache.karaf.shell.api.console.Session;
import org.apache.karaf.shell.support.completers.StringsCompleter;

import java.util.List;
import java.util.Set;

/**
 * Completer with dynamic enums.
 *
 * @author Lijun Liao (xipki)
 * @since 2.0.0
 */

public abstract class DynamicEnumCompleter implements Completer {

  protected abstract Set getEnums();

  @Override
  public int complete(Session session, CommandLine commandLine, List candidates) {
    StringsCompleter delegate = new StringsCompleter();

    for (String s : getEnums()) {
      delegate.getStrings().add(s);
    }

    return delegate.complete(session, commandLine, candidates);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy