mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-10-20 06:24:05 +00:00
Resolved #83
This commit is contained in:
@@ -42,8 +42,9 @@ import static java.util.stream.Collectors.*;
|
||||
*/
|
||||
public abstract class Strman {
|
||||
|
||||
private static final Predicate<String> NULL_STRING_PREDICATE = str -> str == null;
|
||||
private static final Predicate<String> NULL_STRING_PREDICATE = Objects::isNull;
|
||||
private static final Supplier<String> NULL_STRING_MSG_SUPPLIER = () -> "'value' should be not null.";
|
||||
private static final String[] EMPTY_ARRAY = new String[0];
|
||||
|
||||
private Strman() {
|
||||
}
|
||||
@@ -1333,6 +1334,19 @@ public abstract class Strman {
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Split lines to an array
|
||||
*
|
||||
* @param input The input String
|
||||
* @return lines in an array
|
||||
*/
|
||||
public static String[] lines(String input) {
|
||||
if (input == null) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
return input.split("\r\n?|\n");
|
||||
}
|
||||
|
||||
private static void validate(String value, Predicate<String> predicate, final Supplier<String> supplier) {
|
||||
if (predicate.test(value)) {
|
||||
throw new IllegalArgumentException(supplier.get());
|
||||
|
||||
Reference in New Issue
Block a user