mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-10-10 06:13:58 +00:00
Resolved#71
This commit is contained in:
@@ -1164,6 +1164,37 @@ public abstract class Strman {
|
||||
return head(input).toLowerCase() + tail(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies whether String is enclosed by encloser
|
||||
*
|
||||
* @param input The input String
|
||||
* @param encloser String which encloses input String
|
||||
* @return true if enclosed false otherwise
|
||||
*/
|
||||
public static boolean isEnclosedBetween(final String input, final String encloser) {
|
||||
return isEnclosedBetween(input, encloser, encloser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies whether String is enclosed by encloser
|
||||
*
|
||||
* @param input The input String
|
||||
* @param leftEncloser String which encloses input String
|
||||
* @return true if enclosed false otherwise
|
||||
*/
|
||||
public static boolean isEnclosedBetween(final String input, final String leftEncloser, String rightEncloser) {
|
||||
if (input == null) {
|
||||
throw new IllegalArgumentException("input can't be null");
|
||||
}
|
||||
if (leftEncloser == null) {
|
||||
throw new IllegalArgumentException("leftEncloser can't be null");
|
||||
}
|
||||
if (rightEncloser == null) {
|
||||
throw new IllegalArgumentException("rightEncloser can't be null");
|
||||
}
|
||||
return input.startsWith(leftEncloser) && input.endsWith(rightEncloser);
|
||||
}
|
||||
|
||||
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