io.bretty.console.view.DefaultIndexNumberFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of console-view Show documentation
Show all versions of console-view Show documentation
A Java framework to instantly build the View layer of your command line app. No more worries about anything like
printing menus or validating user inputs. Just focus on your app logic.
package io.bretty.console.view;
/**
* A singleton class to format index number in user menu, e.g. for index 0 (i.e the first one in menu items), the output is {@code "1) "}
*/
public final class DefaultIndexNumberFormatter implements IndexNumberFormatter {
/**
* Singleton
*/
public static final DefaultIndexNumberFormatter INSTANCE = new DefaultIndexNumberFormatter();
private DefaultIndexNumberFormatter() {
}
/**
* @param index the index number of a menu item in a menu (starting from 0)
* @return e.g. for index 0 (i.e the first one in menu items), the output is {@code "1) "}
*/
@Override
public String format(int index) {
return (index + 1) + ") ";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy