Skip to content

Commit 0908176

Browse files
committed
Fixes minor style issues.
1 parent c80ded7 commit 0908176

File tree

3 files changed

+27
-37
lines changed

3 files changed

+27
-37
lines changed

pom.xml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>nu.olivertwistor</groupId>
88
<artifactId>java-tui</artifactId>
9-
<version>0.2.0</version>
9+
<version>0.3.0</version>
1010

1111
<licenses>
1212
<license>
@@ -16,14 +16,6 @@
1616
</license>
1717
</licenses>
1818

19-
<dependencies>
20-
<dependency>
21-
<groupId>org.jetbrains</groupId>
22-
<artifactId>annotations-java5</artifactId>
23-
<version>RELEASE</version>
24-
<scope>compile</scope>
25-
</dependency>
26-
</dependencies>
2719
<packaging>jar</packaging>
2820

2921
<properties>

src/main/java/nu/olivertwistor/java/tui/Terminal.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
import java.nio.charset.Charset;
88
import java.nio.charset.StandardCharsets;
99
import 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"})
2324
public 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
/**

src/main/java/nu/olivertwistor/java/tui/UnclosableInputStream.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package nu.olivertwistor.java.tui;
22

3-
import org.jetbrains.annotations.NonNls;
4-
import org.jetbrains.annotations.NotNull;
5-
63
import java.io.IOException;
74
import java.io.InputStream;
85

96
/**
107
* A decorator for InputStream. It does what the underlying InputStream does
11-
* with the exception of {@link InputStream#close()}. Instead of closing it, it
12-
* does nothing.
8+
* except for {@link InputStream#close()}. Instead of closing it, it does
9+
* nothing.
1310
*
1411
* @author nkukhar https://stackoverflow.com/users/369280/nkukhar
1512
* @author Johan Nilsson
@@ -19,7 +16,8 @@
1916
* @see <a href="https://stackoverflow.com/a/14962425/2267803">
2017
* Idea taken from an Stack Overflow answer by nkukhar</a>
2118
*/
22-
@SuppressWarnings({"ClassWithoutLogger", "PublicMethodWithoutLogging"})
19+
@SuppressWarnings({"ClassWithoutLogger", "PublicMethodWithoutLogging",
20+
"WeakerAccess"})
2321
public final class UnclosableInputStream extends InputStream
2422
{
2523
/**
@@ -49,13 +47,13 @@ public int read() throws IOException
4947
}
5048

5149
@Override
52-
public int read(@NotNull final byte[] b) throws IOException
50+
public int read(final byte[] b) throws IOException
5351
{
5452
return this.inputStream.read(b);
5553
}
5654

5755
@Override
58-
public int read(@NotNull final byte[] b, final int off, final int len)
56+
public int read(final byte[] b, final int off, final int len)
5957
throws IOException
6058
{
6159
return this.inputStream.read(b, off, len);
@@ -103,11 +101,9 @@ public void close()
103101
}
104102

105103
@Override
106-
@NonNls
107104
public String toString()
108105
{
109-
return "UnclosableInputStream{" +
110-
"inputStream=" + this.inputStream +
111-
'}';
106+
return String.format("UnclosableInputStream[inputStream=%s]",
107+
this.inputStream);
112108
}
113109
}

0 commit comments

Comments
 (0)