public final class CommonHelper extends Object
Constructor and Description |
---|
CommonHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
addParameter(String url,
String name,
String value)
Add a new parameter to an url.
|
static boolean |
areEquals(String s1,
String s2)
Compare two String to see if they are equals (both null is ok).
|
static boolean |
areEqualsIgnoreCaseAndTrim(String s1,
String s2)
Compare two String to see if they are equals ignoring the case and the blank spaces (both null is ok).
|
static boolean |
areNotEquals(String s1,
String s2)
Compare two String to see if they are not equals.
|
static void |
assertNotBlank(String name,
String value)
Verify that a String is not blank otherwise throw a
TechnicalException . |
static void |
assertNotBlank(String name,
String value,
String msg)
Verify that a String is not blank otherwise throw a
TechnicalException . |
static void |
assertNotNull(String name,
Object obj)
Verify that an Object is not
null otherwise throw a TechnicalException . |
static void |
assertNull(String name,
Object obj)
Verify that an Object is
null otherwise throw a TechnicalException . |
static void |
assertTrue(boolean value,
String message)
Verify that a boolean is true otherwise throw a
TechnicalException . |
static URI |
asURI(String s)
Convert a string into an URI.
|
static boolean |
isBlank(String s)
Return if the String is blank.
|
static boolean |
isEmpty(Collection<?> coll)
Return if a collection is empty.
|
static boolean |
isNotBlank(String s)
Return if the String is not blank.
|
static boolean |
isNotEmpty(Collection<?> coll)
Return if a collection is not empty.
|
static Date |
newDate(Date original)
Copy a date.
|
static String |
randomString(int size)
Return a random string of a certain size.
|
static String |
substringAfter(String str,
String separator) |
static String |
substringBefore(String str,
String separator) |
static String |
substringBetween(String str,
String open,
String close) |
static String |
toString(Class<?> clazz,
Object... args)
Build a normalized "toString" text for an object.
|
static String |
urlEncode(String text)
URL encode a text using UTF-8.
|
public static boolean isNotBlank(String s)
s
- stringpublic static boolean isBlank(String s)
s
- stringpublic static boolean areEquals(String s1, String s2)
s1
- strings2
- stringpublic static boolean areEqualsIgnoreCaseAndTrim(String s1, String s2)
s1
- strings2
- stringpublic static boolean areNotEquals(String s1, String s2)
s1
- strings2
- stringpublic static boolean isEmpty(Collection<?> coll)
coll
- a collectionpublic static boolean isNotEmpty(Collection<?> coll)
coll
- a collectionpublic static void assertTrue(boolean value, String message)
TechnicalException
.value
- the value to be checked for truthmessage
- the message to include in the exception if the value is falsepublic static void assertNotBlank(String name, String value, String msg)
TechnicalException
.name
- name if the stringvalue
- value of the stringmsg
- an expanatory messagepublic static void assertNotBlank(String name, String value)
TechnicalException
.name
- name if the stringvalue
- value of the stringpublic static void assertNotNull(String name, Object obj)
null
otherwise throw a TechnicalException
.name
- name of the objectobj
- objectpublic static void assertNull(String name, Object obj)
null
otherwise throw a TechnicalException
.name
- name of the objectobj
- objectpublic static String addParameter(String url, String name, String value)
url
- urlname
- name of the parametervalue
- value of the parameterpublic static String urlEncode(String text)
text
- text to encodepublic static String toString(Class<?> clazz, Object... args)
clazz
- classargs
- argumentspublic static String randomString(int size)
size
- the sizepublic static Date newDate(Date original)
original
- original datepublic static URI asURI(String s)
s
- the stringCopyright © 2017. All rights reserved.