Reformat JoinerSplitter

This commit is contained in:
pivovarit 2017-02-11 18:40:14 +01:00
parent c670ac9166
commit 5218116a80
1 changed files with 30 additions and 26 deletions

View File

@ -7,30 +7,34 @@ import java.util.stream.Stream;
public class JoinerSplitter { public class JoinerSplitter {
public static String join ( String[] arrayOfString ) { public static String join(String[] arrayOfString) {
return Arrays.asList(arrayOfString) return Arrays
.stream() .asList(arrayOfString)
.map(x -> x) .stream()
.collect(Collectors.joining(",")); .map(x -> x)
} .collect(Collectors.joining(","));
}
public static String joinWithPrefixPostFix ( String[] arrayOfString ) {
return Arrays.asList(arrayOfString) public static String joinWithPrefixPostFix(String[] arrayOfString) {
.stream() return Arrays
.map(x -> x) .asList(arrayOfString)
.collect(Collectors.joining(",","[","]")); .stream()
} .map(x -> x)
.collect(Collectors.joining(",", "[", "]"));
public static List<String> split ( String str ) { }
return Stream.of(str.split(","))
.map (elem -> new String(elem)) public static List<String> split(String str) {
.collect(Collectors.toList()); return Stream
} .of(str.split(","))
.map(elem -> new String(elem))
public static List<Character> splitToListOfChar ( String str ) { .collect(Collectors.toList());
return str.chars() }
.mapToObj(item -> (char) item)
.collect(Collectors.toList()); public static List<Character> splitToListOfChar(String str) {
} return str
.chars()
.mapToObj(item -> (char) item)
.collect(Collectors.toList());
}
} }