From 4d94035f170dc428937980ee8f7c5a0960a79846 Mon Sep 17 00:00:00 2001 From: Shekhar Gulati Date: Fri, 12 May 2017 15:22:41 +0530 Subject: [PATCH] Formatted code to move private methods down --- src/main/java/strman/Strman.java | 33 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/strman/Strman.java b/src/main/java/strman/Strman.java index 2486956..08ddd2b 100644 --- a/src/main/java/strman/Strman.java +++ b/src/main/java/strman/Strman.java @@ -1290,6 +1290,22 @@ public abstract class Strman { } + /** + * Counts the number of occurrences of each character in the string + * + * @param input The input string + * @return A map containing the number of occurrences of each character in the string + */ + public static Map charsCount(String input) { + if (isNullOrEmpty(input)) { + return Collections.emptyMap(); + } + + return input.chars() + .mapToObj(c -> (char) c) + .collect(groupingBy(identity(), counting())); + } + private static void validate(String value, Predicate predicate, final Supplier supplier) { if (predicate.test(value)) { throw new IllegalArgumentException(supplier.get()); @@ -1309,20 +1325,5 @@ public abstract class Strman { } return countSubstr(value.substring(offset), subStr, allowOverlapping, ++count); } - - /** - * Counts the number of occurrences of each character in the string - * - * @param input The input string - * @return A map containing the number of occurrences of each character in the string - */ - public static Map charsCount(String input) { - if (isNullOrEmpty(input)) { - return Collections.emptyMap(); - } - - return input.chars() - .mapToObj(c -> (char) c) - .collect(groupingBy(identity(), counting())); - } } +