Modifier and Type | Method and Description |
---|---|
Object |
abbreviate(Object value,
int maxWidth)
Abbreviates given value to specified max width.
|
Object |
abbreviate(Object value,
int offset,
int maxWidth)
Abbreviates the given value to specified max width starting given offset
|
Object |
abbreviate(Object value,
Object abbrevMarker,
int maxWidth)
Abbreviates the given value to specified max width using specified abbreviation marker
|
Object |
abs(Object value)
Returns the absolute value of a
double value. |
Object |
add(Object value,
Object... valuesToBeAdded)
Adds given
valuesToBeAdded to given value . |
Long |
age(Object dateBefore)
Same as
age(Object, Object) with age unit defaults to days (d) |
Long |
age(Object dateBefore,
Object ageUnit)
Same as
#age(LocalDate, LocalDate, String) with second value being now() |
Long |
age(Object dateBefore,
Object dateAfter,
String ageUnit)
Calculates the age between two given times in specified unit is same as in unit of duration (see
#add(Object, Object) for more info). |
<T> Object |
avg(T... values)
Calculates the average of given array of numbers.
|
Object |
capital_case(Object value)
Same as
StringUtils.capitalize(String) |
Double |
ceil(Object value)
Calculates the celing value of given number according to
Math.ceil(double) |
protected Object |
center(Object value,
int size)
Not exposed
|
protected Object |
center(Object value,
int size,
String pad)
Not exposed
|
Object |
chop(Object str)
Same as
StringUtils.chop(String) |
Object |
chop(Object str,
int size)
|
int |
compare_ic(Object value,
Object otherValue)
Same as
compare(Object, Object) but if values are converted to strings and compared case-insensitvely |
int |
compare(Object value,
Object otherValue)
Compares the given two values and return a integer with value -1, 0 or 1 indicating if first value is less than or equals to or greater than second value.
|
boolean |
contains_ic(Object input,
Object stringToCheckFor)
|
boolean |
contains_whitespace(Object input)
|
boolean |
contains(Object input,
Object stringToCheckFor)
|
int |
count_matches(Object input,
Object substring)
|
protected Object |
country_isocode2(Object value)
Not exposed yet
|
protected Object |
difference(Object value,
Object inValue)
Not exposed
|
boolean |
ends_with_ic(Object value,
Object otherValue)
Same as
ends_with(Object, Object) but checking is case-insensitive |
boolean |
ends_with(Object value,
Object otherValue)
Checks if given value ends with otherValue.
|
Object |
ensure_prefix_ic(Object value,
Object prefix)
Same as
ensure_prefix(Object, Object) but case insensitive |
Object |
ensure_prefix(Object value,
Object prefix)
Ensures that given value (after converted to string) has the given prefix (case sensitive).
|
Object |
ensure_suffix_ic(Object value,
Object suffix)
Same as
ensure_suffix(Object, Object) but case insensitive |
Object |
ensure_suffix(Object value,
Object suffix)
Ensures that given value (after converted to string) has the given suffix (case sensitive).
|
Object |
ensure_wrap(Object input,
Object wrapString)
|
boolean |
equals_to_ic(Object value,
Object otherValue)
Same as
equals_to(Object, Object) but compares the string case insensitively |
boolean |
equals_to(Object value,
Object otherValue)
Compares the given value with other value and returns
true if they are equal. |
Object |
extract_digits(Object str)
Same as
StringUtils.getDigits(String) |
<T> Object |
first_not_blank(T... values)
Returns the first non-blank value from given array.
|
<T> T |
first_not_null(T... values)
Returns the first non
null value from given array. |
<T> T |
first(T... values)
Returns the first value of given array.
|
Double |
floor(Object value)
Calculates the floor value of given number according to
Math.floor(double) |
boolean |
is_blank(Object value)
Checks if given value is blank.
|
boolean |
is_not_blank(String value)
Convenient method, which negates
is_blank(Object) |
<T> String |
join_with(Object separator,
T... objects)
|
<T> String |
join(T... values)
Same as
StringUtils.join(Object...) |
<T> T |
last(T... values)
Returns the last value of given array.
|
Object |
left_pad(Object str,
int len)
Same as
StringUtils.leftPad(String, int) |
Object |
left_pad(Object str,
int size,
Object padChar)
|
Object |
left(Object str,
int len)
Same as
StringUtils.left(String, int) |
Object |
lower_case(Object value)
Same as
StringUtils.lowerCase(String) |
Object |
match_ic(Object value,
Object... matches) |
Object |
match(Object value,
Object... matches) |
Double |
max(Object... values)
Returns the maximum from given array of values.
|
Double |
min(Object... values)
Returns the minimum from given array of values.
|
Object |
normalize_whitespace(Object str)
|
long |
now_millis()
Returns the current unix time, which is number of milliseconds since epoch (1 jan 1970)
|
ZonedDateTime |
now()
Returns the current time
|
Object |
null_if_blank(Object value) |
Object |
null_if_null_string(Object value) |
Object |
null_if_zero(Object value)
If given value is null or zero, then returns
null else returns the Double value |
boolean |
random_boolean()
Generates and returns a random boolean value
|
int |
random_integer()
Generates a random integer between 0 and
Integer.MAX_VALUE (exclusive). |
int |
random_integer(int start,
int end)
Generates a random integer between
start (inclusive) and end (exclusive) |
<T> T |
random_null(T value)
Randomly returns either a
null or specified value |
Object |
random_uuid()
Generates a new random uuid.
|
<T> T |
random_value(List<T> values)
Returns a random value from given set of values.
|
<T> T |
random_value(T... values)
Returns a random value from given set of values.
|
Object |
remove_blanks(List<Object> values) |
Object |
remove_blanks(Object... values) |
Object |
remove_nulls(List<Object> values) |
Object |
remove_nulls(Object... values) |
Object |
remove_prefix_ic(Object str,
Object remove)
|
Object |
remove_prefix(Object str,
Object remove)
|
Object |
remove_suffix_ic(Object str,
Object remove)
|
Object |
remove_suffix(Object str,
Object remove)
|
Object |
remove_whitespace(Object str)
|
Object |
repeat(Object input,
int maxTimes)
Same as
StringUtils.repeat(String, int) |
Object |
repeat(Object input,
Object separator,
int maxTimes)
|
Object |
replace_first_ic(Object input,
Object searchString,
Object replaceString)
|
Object |
replace_first_regex(Object input,
Object searchStringRegex,
Object replaceString)
|
Object |
replace_first(Object input,
Object searchString,
Object replaceString)
|
Object |
replace_ic(Object input,
Object searchString,
Object replaceString)
|
Object |
replace_regex(Object input,
Object searchStringRegex,
Object replaceString)
|
Object |
replace(Object input,
Object searchString,
Object replaceString)
|
Object |
right_pad(Object str,
int len)
|
Object |
right_pad(Object str,
int size,
Object padChar)
|
Object |
right(Object str,
int len)
Same as
StringUtils.right(String, int) |
Object |
round(Object input)
Same as
Precision.round(double, int) with precision of 2 |
Object |
round(Object input,
int precision)
Same as
Precision.round(double, int) |
Object |
round(Object input,
int precision,
String roundingMode)
Same as
Precision.round(double, int, int) |
Integer |
size(Object value)
Calculates the size of given value.
|
List<Object> |
split(Object input)
Same as
StringUtils.split(String) but returns list instead of array |
List<Object> |
split(Object input,
Object separator)
Same as
StringUtils.split(String, String) but returns list instead of array |
boolean |
starts_with_ic(Object value,
Object otherValue)
Same as
starts_with(Object, Object) but check is case-insensitive |
boolean |
starts_with(Object value,
Object otherValue)
Checks if given value starts with otherValue.
|
Object |
strip_to_null(Object input)
Same as
StringUtils.stripToNull(String) |
Object |
strip(Object input)
Same as
StringUtils#strip(CharSequence) |
Object |
substring_after_last(Object value,
Object separator)
|
Object |
substring_after(Object value,
Object separator)
|
Object |
substring_before_last(Object value,
Object separator)
|
Object |
substring_before(Object value,
Object separator)
|
Object |
substring_betweeen(Object value,
Object tag)
|
Object |
substring_between(Object value,
Object begin,
Object end)
|
Object |
substring(Object value,
int start)
|
Object |
substring(Object value,
int start,
int end)
|
Object |
substrings_between(Object value,
Object begin,
Object end)
Same as
StringUtils.substringsBetween(String, String, String) but returns list instead of an array |
Object |
to_boolean(Object value)
Tries to convert the given object to boolean.
|
LocalDate |
to_date(int year,
int month,
int dayOfMonth)
Returns the date of given set of values
|
Object |
to_date(Object value)
Parses given value into date using default date formats (shown below).
|
Object |
to_date(Object value,
Object... formats)
Same as
to_date(Object) but uses given format strings. |
ZonedDateTime |
to_datetime(int year,
int month,
int dayOfMonth)
Same as
to_datetime(int, int, int, int, int, int) but with hours, minutes and seconds as 0 |
ZonedDateTime |
to_datetime(int year,
int month,
int dayOfMonth,
int hour,
int minute,
int second)
Creates and returns a date time object of given input.
|
Object |
to_datetime(Object value)
Parses given value into Datetime using default datetime formats (shown below).
|
Object |
to_datetime(Object value,
Object... formats)
Same as
to_datetime(Object) except that it uses given formats. |
Object |
to_double(Object value)
Tries to convert the given value to double using US regional settings.
|
Object |
to_double(Object value,
Object... formats)
Parses the given value to double using one of the formats strings.
|
Object |
to_integer(Object value)
Same as
to_double(Object) but instead of double, converts to integer |
Object |
to_integer(Object value,
Object... formats)
Same as
to_double(Object, Object...) but instead of double, converts to integer |
Object |
to_long(Object value)
Same as
to_double(Object) but instead of double, converts to long |
Object |
to_long(Object value,
Object... formats)
Same as
to_double(Object, Object...) but instead of double, converts to long |
Object |
to_string(Object value)
Converts the given value is string.
|
Object |
to_string(Object value,
Object format)
Formats the given input using specified format string.
|
LocalDate |
today()
Returns today’s date
|
Object |
trim(Object str)
Trims all leading/trailing whitespaces from given string value according to
StringUtils.trim(String) . |
Object |
truncate(Object input,
int maxWidth)
|
Object |
unwrap(Object input,
Object wrapString)
Same as
StringUtils.unwrap(String, char) |
Object |
upper_case(Object value)
Same as
StringUtils.upperCase(String) |
Object |
wrap(Object input,
Object wrapString)
Same as
StringUtils.wrap(String, String) |
public Object abbreviate(Object value, int maxWidth)
Abbreviates given value to specified max width.
public Object abbreviate(Object value, int offset, int maxWidth)
Abbreviates the given value to specified max width starting given offset
public Object abbreviate(Object value, Object abbrevMarker, int maxWidth)
Abbreviates the given value to specified max width using specified abbreviation marker
public Object abs(Object value)
Returns the absolute value of a double
value.
Same as Math.abs(double)
public Object add(Object value, Object... valuesToBeAdded)
Adds given valuesToBeAdded
to given value
.
If value is null, then null is returned. If valuesToBeAdded
is null, then value is returned as is.
The behavior of this method depends on the type of the value.
If value is number, each of valuesToBeAdded
must be a valid number (positive or negative) and they will be added to value.
If value is list/array, then each of valuesToBeAdded
will be appended.
If value is either date or datetime, then each of valuesToBeAdded
is considered as duration string.
Duration is represented as {value}{unit}
where value is any integer (positive or negative) and unit is one of following values (case sensitive)
ms -> milli seconds s -> seconds m -> minutes h -> hours w -> weeks M -> months y -> years
For ex.,
10s -> 10 seconds -10s -> minus 10 seconds 10m -> 10 minutes 2w -> two weeks -5w -> minus five weeks
value
- the value to which the toAdd to be “added”valuesToBeAdded
- the list of values to be “added” to valuepublic Long age(Object dateBefore, Object dateAfter, String ageUnit)
Calculates the age between two given times in specified unit is same as in unit of duration (see #add(Object, Object)
for more info).
dateBefore
- the before date or datetimedateAfter
- the after date or datetimeageUnit
- the unit of agenull
if any of inputs are nullpublic Long age(Object dateBefore, Object ageUnit)
Same as #age(LocalDate, LocalDate, String)
with second value being now()
public Long age(Object dateBefore)
Same as age(Object, Object)
with age unit defaults to days (d)
public <T> Object avg(T... values)
Calculates the average of given array of numbers. If array is blank, then returns null.
values
- the array of numbersnull
if input array is blankpublic Object capital_case(Object value)
Same as StringUtils.capitalize(String)
public Double ceil(Object value)
Calculates the celing value of given number according to Math.ceil(double)
public Object chop(Object str)
Same as StringUtils.chop(String)
public int compare(Object value, Object otherValue)
Compares the given two values and return a integer with value -1, 0 or 1 indicating if first value is less than or equals to or greater than second value.
This method supports comparing various types of values. The type of the first value is taken as the comparison type and second value is converted to that type.
If values are string, then they are compare case-sensitively.
value
- the value to compare to other valueotherValue
- the other valuepublic int compare_ic(Object value, Object otherValue)
Same as compare(Object, Object)
but if values are converted to strings and compared case-insensitvely
public boolean contains_whitespace(Object input)
public LocalDate to_date(int year, int month, int dayOfMonth)
Returns the date of given set of values
year
- the yearmonth
- the month (1 for Jan, 12 for Dec)dayOfMonth
- the day of monthpublic ZonedDateTime to_datetime(int year, int month, int dayOfMonth, int hour, int minute, int second)
Creates and returns a date time object of given input. Milliseconds will be set to 0.
year
- the yearmonth
- the month (1 for Jan, 12 for Dec)dayOfMonth
- the day of the monthhour
- the hourminute
- the minutesecond
- the secondpublic ZonedDateTime to_datetime(int year, int month, int dayOfMonth)
Same as to_datetime(int, int, int, int, int, int)
but with hours, minutes and seconds as 0
public boolean ends_with(Object value, Object otherValue)
Checks if given value ends with otherValue. Checking is case-sensitive.
value
- the value to check if it starts with otherValueotherValue
- the otherValuepublic boolean ends_with_ic(Object value, Object otherValue)
Same as ends_with(Object, Object)
but checking is case-insensitive
public Object ensure_prefix(Object value, Object prefix)
Ensures that given value (after converted to string) has the given prefix (case sensitive). If value has the given suffix, then no change is made to the input value else prefix is prepended.
If value or prefix is blank, given value is returned as is.
value
- the value which needs to be checked for given suffixprefix
- the suffixpublic Object ensure_prefix_ic(Object value, Object prefix)
Same as ensure_prefix(Object, Object)
but case insensitive
public Object ensure_suffix(Object value, Object suffix)
Ensures that given value (after converted to string) has the given suffix (case sensitive). If value has the given suffix, then no change is made to the input value else suffix is appended.
If value is blank or suffix is blank, given value is returned as is.
value
- the value which needs to be checked for given suffixsuffix
- the suffixpublic Object ensure_suffix_ic(Object value, Object suffix)
Same as ensure_suffix(Object, Object)
but case insensitive
public boolean equals_to(Object value, Object otherValue)
Compares the given value with other value and returns true
if they are equal.
If they are strings, they are compared case-sensitively. If both are null
, then it returns true
but if one of them is null
then returns false
.
value
- the value to compare tootherValue
- the other value to compare totrue
if they are equal and false
otherwisepublic boolean equals_to_ic(Object value, Object otherValue)
Same as equals_to(Object, Object)
but compares the string case insensitively
public Object extract_digits(Object str)
Same as StringUtils.getDigits(String)
public <T> T first(T... values)
Returns the first value of given array. If array is empty or null
, then returns null
.
values
- the array whose first value needs to be returnednull
public <T> Object first_not_blank(T... values)
Returns the first non-blank value from given array. If array is blank, then returns null
.
values
- the array whose first non-null
needs to be returnednull
public <T> T first_not_null(T... values)
Returns the first non null
value from given array. If array is blank, then returns null
.
values
- the array whose first non-null
needs to be returnednull
value or null
public Double floor(Object value)
Calculates the floor value of given number according to Math.floor(double)
public boolean is_blank(Object value)
Checks if given value is blank. “blank” depends on passed value type.
If value is String, then string has some non-white space chars.
If value is List,Array,Map then that collection has some elements
Otherwise value is not null
value
- the value which needs to be checked for blanktrue
if value is blank otherwise false
public boolean is_not_blank(String value)
Convenient method, which negates is_blank(Object)
public <T> String join(T... values)
Same as StringUtils.join(Object...)
public <T> T last(T... values)
Returns the last value of given array. If array is empty or null
, then returns null
.
values
- the array whose first value needs to be returnednull
public Object left(Object str, int len)
Same as StringUtils.left(String, int)
public Object left_pad(Object str, int len)
Same as StringUtils.leftPad(String, int)
public Object lower_case(Object value)
Same as StringUtils.lowerCase(String)
public Double max(Object... values)
Returns the maximum from given array of values. If array is blank, then returns null
values
- the array from which a maximum needs to be returnednull
public Double min(Object... values)
Returns the minimum from given array of values. If array is blank, then returns null
values
- the array from which a minimum needs to be returnednull
public ZonedDateTime now()
Returns the current time
public long now_millis()
Returns the current unix time, which is number of milliseconds since epoch (1 jan 1970)
public Object null_if_zero(Object value)
If given value is null or zero, then returns null
else returns the Double value
value
- public boolean random_boolean()
Generates and returns a random boolean value
public int random_integer()
Generates a random integer between 0 and Integer.MAX_VALUE
(exclusive).
public int random_integer(int start, int end)
Generates a random integer between start
(inclusive) and end
(exclusive)
start
- start value of random integer (inclusive)end
- end value of random integer (exclusive)public <T> T random_null(T value)
Randomly returns either a null
or specified value
value
- the valuepublic <T> T random_value(List<T> values)
Returns a random value from given set of values. If input is null
, then returns null
.
values
- the list of values of which a random value needs to be returnednull
is list is blankpublic <T> T random_value(T... values)
Returns a random value from given set of values. If input is null
, then returns null
.
values
- the array of which a random value needs to be returnednull
is array is blankpublic Object repeat(Object input, int maxTimes)
Same as StringUtils.repeat(String, int)
public Object replace_first_ic(Object input, Object searchString, Object replaceString)
public Object replace_first_regex(Object input, Object searchStringRegex, Object replaceString)
public Object replace_regex(Object input, Object searchStringRegex, Object replaceString)
public Object right(Object str, int len)
Same as StringUtils.right(String, int)
public Object round(Object input, int precision, String roundingMode)
Same as Precision.round(double, int, int)
public Integer size(Object value)
Calculates the size of given value. The “size” depends on value datatype.
If value isnull
, then size isnull
If value is String, then size is total number of characters If value is List,Array,Map then size is number of elements Otherwise size is -1
value
- the value whose size needs to be calculatednull
public List<Object> split(Object input)
Same as StringUtils.split(String)
but returns list instead of array
public List<Object> split(Object input, Object separator)
Same as StringUtils.split(String, String)
but returns list instead of array
public boolean starts_with(Object value, Object otherValue)
Checks if given value starts with otherValue. Checking is case-sensitive.
value
- the value to check if it starts with otherValueotherValue
- the otherValuepublic boolean starts_with_ic(Object value, Object otherValue)
Same as starts_with(Object, Object)
but check is case-insensitive
public Object strip_to_null(Object input)
Same as StringUtils.stripToNull(String)
public Object substrings_between(Object value, Object begin, Object end)
Same as StringUtils.substringsBetween(String, String, String)
but returns list instead of an array
public Object to_boolean(Object value)
Tries to convert the given object to boolean. If input is null or “falsy”, then false
is returned else true
is returned.
value
- the value to be converted to booleantrue
or false
public Object to_date(Object value)
Parses given value into date using default date formats (shown below). If value is not parsable using any of those formats, then throws type conversion error.
The format string based on DateTimeFormatter
.
Default formats (in this order) are:
yyyy-MM-dd yyyy/MM/dd yyyy-M-d yyyy/M/d
value
- the value to be parsed into datetime.null
if input is null
-
to_date
public Object to_date(Object value,
Object... formats)
Same as to_date(Object)
but uses given format strings.
-
to_datetime
public Object to_datetime(Object value)
Parses given value into Datetime using default datetime formats (shown below). If value is not parsable using any of those formats, then throws type conversion error.
The format string based on DateTimeFormatter
.
Default formats (in this order) are:
yyyy-MM-dd'T'HH:mm:ss[.SSS]X
yyyy-MM-dd'T'HH:mm:ss[.SSS]XXX
yyyy-MM-dd'T'HH:mm:ss
yyyyMMdd'T'HHmmssX
yyyyMMdd'T'HHmmss
yyyyMMddHHmmss
- Parameters:
value
- the value to be parsed into datetime.
- Returns:
- the parsed datetime as ZonedDateTime.
null
if input is null
-
to_datetime
public Object to_datetime(Object value,
Object... formats)
Same as to_datetime(Object)
except that it uses given formats.
-
to_double
public Object to_double(Object value)
Tries to convert the given value to double using US regional settings. If value cannot be converted (for ex., if input has non number or non-decimal separator), then conversion exception will be thrown.
If input is null
, then returns null
.
- Parameters:
value
- the value to be converted to double
- Returns:
- the converted double value or
null
-
to_double
public Object to_double(Object value,
Object... formats)
Parses the given value to double using one of the formats strings. More than one format can be specified and if so, first format which doesn’t thrown any error will be used. If all the formats returns in parsing error, then Type conversion error will be thrown. If the formats are blank, then it is same as to_double(Object)
.
The format string must adhere to Java number format conversion as specified at DecimalFormat
-
to_integer
public Object to_integer(Object value)
Same as to_double(Object)
but instead of double, converts to integer
-
to_integer
public Object to_integer(Object value,
Object... formats)
Same as to_double(Object, Object...)
but instead of double, converts to integer
-
to_long
public Object to_long(Object value)
Same as to_double(Object)
but instead of double, converts to long
-
to_long
public Object to_long(Object value,
Object... formats)
Same as to_double(Object, Object...)
but instead of double, converts to long
-
to_string
public Object to_string(Object value)
Converts the given value is string.
If value is date or datetime, then they formatted as ISO 8601 string. For ex., if date => 2017-01-01 and if datetime => 2017-01-01T10:20:30Z
If value is number, then it is formatted with . as decimal
If null
, returns null
- Parameters:
value
- the value to be converted to string
- Returns:
- string value of the given input
-
to_string
public Object to_string(Object value,
Object format)
Formats the given input using specified format string. If input or format is null, then returns null
.
Formatting is supported only for numbers, dates and datetimes. If it is other than one of those three, then error will be thrown.
This method will redirect to type specified format calls (number or date or datetime)
Formats the datetime. The pattern is either one of the pre-defined values or a valid Java datetime format.
Following predefined patterns are recognized.
iso -> formats the time as ISO8601 format 2017-01-01T10:10:10Z
unix -> formats the time as number of milliseconds since epoch
number -> formats the time as number in the format yyyyMMddhhmmss
If not one of those, then pattern must adhere to pattern as documented at DateTimeFormatter
- Parameters:
input
- the the input to be formatted
pattern
- the pattern string
- Returns:
- the formatting string.
null
if input or format is blank
-
today
public LocalDate today()
Returns today’s date
- Returns:
- the today’s date
-
trim
public Object trim(Object str)
Trims all leading/trailing whitespaces from given string value according to StringUtils.trim(String)
. If value is null
, then null
is returned.
-
unwrap
public Object unwrap(Object input,
Object wrapString)
Same as StringUtils.unwrap(String, char)
-
upper_case
public Object upper_case(Object value)
Same as StringUtils.upperCase(String)
-
random_uuid
public Object random_uuid()
Generates a new random uuid. Sample uuids are shown below.
d02ccd5a-dc79-11e7-9296-cec278b6b50a
dc0cb32e-dc79-11e7-9296-cec278b6b50a
- Returns:
- random uuid string
-
wrap
public Object wrap(Object input,
Object wrapString)
Same as StringUtils.wrap(String, String)
Copyright © 2018. All rights reserved.