From 9e644af344b27c74b7187dbc2b9194453de4e653 Mon Sep 17 00:00:00 2001 From: iaforek Date: Tue, 16 May 2017 16:05:38 +0100 Subject: [PATCH] BAEL-838 Tiny change to keep code consistant. Return null or empty. (#1866) * Code for Dependency Injection Article. * Added Java based configuration. Downloaded formatter.xml and reformatted all changed files. Manually changed tab into 4 spaces in XML configuration files. * BAEL-434 - Spring Roo project files generated by Spring Roo. No formatting applied. Added POM, java and resources folders. * Moved project from roo to spring-roo folder. * BAEL-838 Initial code showing how to remove last char - helper class and tests. * BAEL-838 Corrected Helper class and associated empty string test case. Added StringUtils.substing tests. * BAEL-838 Refromatted code using formatter.xml. Added Assert.assertEquals import. Renamed test to follow convention. Reordered tests. * BAEL-838 - Added regex method and updated tests. * BAEL-838 Added new line examples. * BAEL-838 Renamed RemoveLastChar class to StringHelper and added Java8 examples. Refactord code. * BAEL-838 Changed method names * BAEL-838 Tiny change to keep code consistant. Return null or empty. * BAEL-838 Removed unresolved conflict. --- core-java/src/main/java/com/baeldung/string/StringHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java/src/main/java/com/baeldung/string/StringHelper.java b/core-java/src/main/java/com/baeldung/string/StringHelper.java index 93ce1b684e11..ad2a0b3419f7 100644 --- a/core-java/src/main/java/com/baeldung/string/StringHelper.java +++ b/core-java/src/main/java/com/baeldung/string/StringHelper.java @@ -21,6 +21,6 @@ public static String removeLastCharOptional(String s) { public static String removeLastCharRegexOptional(String s) { return Optional.ofNullable(s) .map(str -> str.replaceAll(".$", "")) - .orElse(null); + .orElse(s); } }