77import java .nio .charset .Charset ;
88import java .nio .charset .StandardCharsets ;
99import java .util .Arrays ;
10+ import java .util .List ;
1011
1112/**
1213 * Utility class for writing to and reading from the terminal (standard input
1314 * and output).
14- *
15+ * <p>
1516 * It has convenience methods for reading strings and integers, as well as
1617 * writing string representations of objects. Many of these methods are
1718 * wrappers for {@link PrintStream} and {@link BufferedReader}.
1819 *
1920 * @since 0.1.0
2021 */
21- @ SuppressWarnings ({"ClassWithoutLogger" , "UtilityClassCanBeEnum " ,
22- "PublicMethodWithoutLogging " })
22+ @ SuppressWarnings ({"ClassWithoutLogger" , "PublicMethodWithoutLogging " ,
23+ "WeakerAccess " })
2324public final class Terminal
2425{
2526 /**
@@ -110,7 +111,7 @@ public static String readString(final String prompt, final Charset charset)
110111 @ SuppressWarnings ("WeakerAccess" )
111112 public static String readString (final String prompt ) throws IOException
112113 {
113- return Terminal . readString (prompt , StandardCharsets .UTF_8 );
114+ return readString (prompt , StandardCharsets .UTF_8 );
114115 }
115116
116117 /**
@@ -129,7 +130,7 @@ public static String readString(final String prompt) throws IOException
129130 */
130131 public static String readString (final Charset charset ) throws IOException
131132 {
132- return Terminal . readString ("" , charset );
133+ return readString ("" , charset );
133134 }
134135
135136 /**
@@ -146,7 +147,7 @@ public static String readString(final Charset charset) throws IOException
146147 */
147148 public static String readString () throws IOException
148149 {
149- return Terminal . readString ("" );
150+ return readString ("" );
150151 }
151152
152153 /**
@@ -169,7 +170,7 @@ public static String readString() throws IOException
169170 */
170171 public static int readInt (final String prompt ) throws IOException
171172 {
172- final String rawInput = Terminal . readString (prompt );
173+ final String rawInput = readString (prompt );
173174 final int intInput = Integer .parseInt (rawInput );
174175
175176 return intInput ;
@@ -191,7 +192,7 @@ public static int readInt(final String prompt) throws IOException
191192 */
192193 public static int readInt () throws IOException
193194 {
194- return Terminal . readInt ("" );
195+ return readInt ("" );
195196 }
196197
197198 /**
@@ -211,17 +212,19 @@ public static int readInt() throws IOException
211212 *
212213 * @throws IOException if reading from standard input failed.
213214 *
214- * @since //todo next released version
215+ * @since 0.3.0
215216 *
216217 * @see BufferedReader#readLine()
217218 */
218219 public static boolean readBoolean (final String prompt ,
219220 final Charset charset ,
220- String ... truthyValues )
221+ final String [] truthyValues )
221222 throws IOException
222223 {
223- final String rawInput = Terminal .readString (prompt , charset );
224- return Arrays .asList (truthyValues ).contains (rawInput );
224+ final String rawInput = readString (prompt , charset );
225+ final List <String > strings = Arrays .asList (truthyValues );
226+
227+ return strings .contains (rawInput );
225228 }
226229
227230 /**
@@ -239,16 +242,15 @@ public static boolean readBoolean(final String prompt,
239242 *
240243 * @throws IOException if reading from standard input failed.
241244 *
242- * @since //todo next released version
245+ * @since 0.3.0
243246 *
244247 * @see BufferedReader#readLine()
245248 */
246249 public static boolean readBoolean (final String prompt ,
247- String ... truthyValues )
250+ final String [] truthyValues )
248251 throws IOException
249252 {
250- return Terminal .readBoolean (
251- prompt , StandardCharsets .UTF_8 , truthyValues );
253+ return readBoolean (prompt , StandardCharsets .UTF_8 , truthyValues );
252254 }
253255
254256 /**
0 commit comments