mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-10-19 14:04:00 +00:00
Resolved #50
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
package strman;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -498,7 +497,7 @@ public abstract class Strman {
|
||||
* @param first The first String
|
||||
* @param second The second String
|
||||
* @return true if first and second are not equal false otherwise
|
||||
* @deprecated use unequal instead
|
||||
* @deprecated use unequal instead
|
||||
*/
|
||||
public static boolean inequal(final String first, final String second) {
|
||||
return !Objects.equals(first, second);
|
||||
@@ -721,11 +720,10 @@ public abstract class Strman {
|
||||
public static String removeLeft(final String value, final String prefix, final boolean caseSensitive) {
|
||||
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
|
||||
validate(prefix, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
|
||||
BiFunction<String, String, String> fx = (f, s) -> f.startsWith(s) ? f.replaceFirst(s, "") : f;
|
||||
if (caseSensitive) {
|
||||
return fx.apply(value, prefix);
|
||||
return value.startsWith(prefix) ? value.substring(prefix.length()) : value;
|
||||
}
|
||||
return fx.apply(value.toLowerCase(), prefix.toLowerCase());
|
||||
return value.toLowerCase().startsWith(prefix.toLowerCase()) ? value.substring(prefix.length()) : value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -802,7 +800,7 @@ public abstract class Strman {
|
||||
if (caseSensitive) {
|
||||
return value.replace(search, newValue);
|
||||
}
|
||||
return value.toLowerCase().replace(search.toLowerCase(), newValue);
|
||||
return Pattern.compile(search, Pattern.CASE_INSENSITIVE).matcher(value).replaceAll(Matcher.quoteReplacement(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1061,7 +1059,7 @@ public abstract class Strman {
|
||||
public static String toDecamelize(final String value, final String chr) {
|
||||
String camelCasedString = toCamelCase(value);
|
||||
String[] words = camelCasedString.split("(?=\\p{Upper})");
|
||||
return Arrays.stream(words).map(w -> w.toLowerCase()).collect(joining(Optional.ofNullable(chr).orElse(" ")));
|
||||
return Arrays.stream(words).map(String::toLowerCase).collect(joining(Optional.ofNullable(chr).orElse(" ")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user