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

io.bretty.console.view.DefaultIndexNumberFormatter Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 3.4
Show newest version
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