public final class CommonHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CLASSPATH_PREFIX |
static String |
INVALID_PATH_MESSAGE |
static String |
RESOURCE_PREFIX |
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 |
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 |
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 InputStream |
getInputStreamFromName(String name)
Returns an
InputStream from given name depending on its format:
- loads from the classloader if name starts with "resource:"
- loads as FileInputStream otherwise
Caller is responsible for closing inputstream |
static Resource |
getResource(String filePath) |
static boolean |
isBlank(String s)
Return if the String is blank.
|
static boolean |
isNotBlank(String s)
Return if the String is not blank.
|
static String |
toString(Class<?> clazz,
Object... args)
Build a normalized "toString" text for an object.
|
public static final String RESOURCE_PREFIX
public static final String CLASSPATH_PREFIX
public static final String INVALID_PATH_MESSAGE
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 areNotEquals(String s1, String s2)
s1
- strings2
- stringpublic 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)
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 toString(Class<?> clazz, Object... args)
clazz
- classargs
- argumentspublic static InputStream getInputStreamFromName(String name)
InputStream
from given name depending on its format:
- loads from the classloader if name starts with "resource:"
- loads as FileInputStream
otherwise
Caller is responsible for closing inputstreamname
- name of the resourceCopyright © 2016. All rights reserved.