Replace ConstantString by lambda expression

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2019-05-06 20:51:12 -04:00
parent 24e57eca2f
commit e5c3bb0152
3 changed files with 6 additions and 41 deletions

View File

@ -40,48 +40,12 @@ package net.bigeon.gclc.manager;
import java.util.function.Supplier;
/*-
* #%L
* Generic Command Ligne console
* %%
* Copyright (C) 2014 - 2018 Bigeon
* %%
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
* #L%
*/
import net.bigeon.gclc.tools.ConstantString;
/** A console input that return empty to all prompting.
*
* @author Emmanuel Bigeon */
public final class EmptyInput implements ConsoleInput {
private static final ConstantString CONSTANT_STRING = new ConstantString("");
private static final Supplier<String> CONSTANT_STRING = () -> "";
/** The empty prompter. */
public static final ConsoleInput INSTANCE = new EmptyInput();

View File

@ -79,7 +79,6 @@ import java.io.PrintStream;
import java.nio.charset.Charset;
import java.util.function.Supplier;
import net.bigeon.gclc.tools.ConstantString;
import net.bigeon.gclc.utils.ReadingRunnable;
/** A console using the input stream and print stream.
@ -90,7 +89,7 @@ import net.bigeon.gclc.utils.ReadingRunnable;
public final class StreamConsoleInput implements ConsoleInput {
/** The default prompt. */
public static final Supplier<String> DEFAULT_PROMPT = new ConstantString("> "); //$NON-NLS-1$
public static final Supplier<String> DEFAULT_PROMPT = () -> ("> "); //$NON-NLS-1$
/** The command prompt. It can be changed. */
private Supplier<String> prompt = DEFAULT_PROMPT;
@ -213,7 +212,7 @@ public final class StreamConsoleInput implements ConsoleInput {
* @see net.bigeon.gclc.manager.ConsoleInput#setPrompt(java.lang.String) */
@Override
public void setPrompt(final String prompt) {
this.prompt = new ConstantString(prompt);
this.prompt = () -> (prompt);
}
@Override

View File

@ -73,7 +73,9 @@ import java.util.function.Supplier;
/** A supplier of string that hold a constant string.
*
* @author Emmanuel Bigeon */
* @author Emmanuel Bigeon
* @since 2.1.2, use a lambda expression instead */
@Deprecated
public class ConstantString implements Supplier<String> {
private final String string;