mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-10-20 06:24:05 +00:00
Fixed #8. Added support for isLowerCase function
This commit is contained in:
@@ -493,6 +493,17 @@ public abstract class Strman {
|
||||
return append(value.substring(0, index), substr, value.substring(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if String is lower case
|
||||
*
|
||||
* @param value The input String
|
||||
* @return true if String is lowercase false otherwise
|
||||
*/
|
||||
public static boolean isLowerCase(final String value) {
|
||||
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
|
||||
return Objects.equals(value, value.toLowerCase());
|
||||
}
|
||||
|
||||
public static String leftPad(final String value, final String pad, final int length) {
|
||||
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
|
||||
if (value.length() >= length) {
|
||||
|
||||
@@ -396,4 +396,17 @@ public class StrmanTest {
|
||||
assertThat(insert("foobar", "x", 6), equalTo("foobarx"));
|
||||
assertThat(insert("foo bar", "asadasd", 100), equalTo("foo bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isLowerCase_shouldBeTrueWhenStringIsLowerCase() throws Exception {
|
||||
assertThat(isLowerCase(""), equalTo(true));
|
||||
assertThat(isLowerCase("foo"), equalTo(true));
|
||||
assertThat(isLowerCase("foobarfoo"), equalTo(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isLowerCase_shouldBeFalseWhenStringIsNotLowerCase() throws Exception {
|
||||
assertThat(isLowerCase("Foo"), equalTo(false));
|
||||
assertThat(isLowerCase("foobarfooA"), equalTo(false));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user