Fixed #35. Added support for surround function

This commit is contained in:
Shekhar Gulati
2016-05-22 18:07:46 +05:30
parent c1b1a70eaa
commit 1b7c268bbe
2 changed files with 25 additions and 0 deletions
+16
View File
@@ -961,6 +961,22 @@ public abstract class Strman {
return result;
}
/**
* Surrounds a 'value' with the given 'prefix' and 'suffix'.
*
* @param value The input String
* @param prefix prefix. If suffix is null then prefix is used
* @param suffix suffix
* @return The String with surround substrs!
*/
public static String surround(final String value, final String prefix, final String suffix) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
String _prefix = Optional.ofNullable(prefix).orElse("");
return append(_prefix, value, Optional.ofNullable(suffix).orElse(_prefix));
}
public static String decode(final String value, final int digits, final int radix) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return Arrays