public final class ObjectUtils extends Object
Modifier and Type | Field and Description |
---|---|
static com.google.gson.Gson |
GSON |
static javax.validation.Validator |
VALIDATOR |
static javax.validation.ValidatorFactory |
VALIDATOR_FACTORY |
Constructor and Description |
---|
ObjectUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
createInstance(Class<T> classOfT,
String className)
Create an instance of the provided class
|
static Set<String> |
csvToSet(String csv)
comma separated string to set
|
static String |
getStringPropertyFromJson(String json,
String key)
retrive the value of a json property
|
static <T> List<String> |
getValidationErrors(Class<T> classOfT,
T object)
return a list of validation errors
|
static <T> boolean |
isValid(Class<T> classOfT,
T object)
check if this instance is valid
|
static Map<String,Object> |
jsonToMap(String json)
Convert a json string to map
|
static void |
populate(Object bean,
Map<String,? extends Object> properties)
Wrapper for BeanUtils.populate, validates that bean has all the properties referenced in
the properties map
|
static void |
populate(Object bean,
Map<String,? extends Object> properties,
boolean validate)
Wrapper for BeanUtils.populate, validates that bean has all the properties referenced in
the properties map
|
public static final com.google.gson.Gson GSON
public static final javax.validation.ValidatorFactory VALIDATOR_FACTORY
public static final javax.validation.Validator VALIDATOR
public static <T> T createInstance(Class<T> classOfT, String className) throws ClassInstantiationException
classOfT
- - the type of the object to returnclassName
- - the full classNameClassInstantiationException
- if the creation of the instance failspublic static void populate(Object bean, Map<String,? extends Object> properties) throws InstancePopulationException
bean
- - the bean to populateproperties
- - a map of key value pairs used to populate beanInstancePopulationException
- if the population of the bean failspublic static void populate(Object bean, Map<String,? extends Object> properties, boolean validate) throws InstancePopulationException
bean
- - the bean to populateproperties
- - a map of key value pairs used to populate beanvalidate
- - validate that all provided properties are in beanInstancePopulationException
- if the population of the bean failspublic static Map<String,Object> jsonToMap(String json)
json
- public static Set<String> csvToSet(String csv)
csv
- public static String getStringPropertyFromJson(String json, String key)
json
- key
- public static <T> boolean isValid(Class<T> classOfT, T object)
classOfT
- - class of the object to validateobject
- - the object to validateCopyright © 2016 iNetria. All rights reserved.