public final class ModelUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
enumEquals(HybrisEnumValue enum1,
Object obj)
Compares enum object with another object.
|
static boolean |
existsField(Class model,
String field)
Returns
true if in the given class model a field by the given fieldname exists. |
static boolean |
existsMethod(Class model,
String method)
Returns
true if in the given class model a method by the given method name exists. |
static Class |
getFieldType(Class model,
String field)
Returns a Class object that identifies the declared type for the given field name of the given model class.
|
static Object |
getFieldValue(Object model,
String field)
Returns the value of the field (given by the field name) from the given model.
|
static boolean |
isPrimitiveField(Class model,
String field)
Returns (per reflection)
true if in the class the field by it's given field name is a primitive type. |
static boolean |
setFieldValue(Object model,
String field,
Object value)
Sets in the given model the given value into the field by the given field name per reflection and returns
true if this was successful. |
public static Object getFieldValue(Object model, String field)
model - the modelfield - the field namenull if not such field at the model exists, otherwise the value object is returnedIllegalStateException - if an unexpected reflection exception occurs.public static boolean setFieldValue(Object model, String field, Object value)
true if this was successful.model - the model where the value should be setfield - the field name at the modelvalue - the value to be setfalse if no such fiel at the model was foundpublic static boolean isPrimitiveField(Class model, String field)
true if in the class the field by it's given field name is a primitive type.model - the class modelfield - the field namefalse if the field is not primitive or the field doesn't exist in the classpublic static Class getFieldType(Class model, String field)
model - the model classfield - the field namenull if no such field was found, otherwise the type class is returnedpublic static boolean existsMethod(Class model, String method)
true if in the given class model a method by the given method name exists. The method can
have any signature.model - the class modelmethod - the method namefalse if no such method exists in the given class modelpublic static boolean existsField(Class model, String field)
true if in the given class model a field by the given fieldname exists. Searches all
superclasses of the given class model.model - the class modelfield - the fieldnamefalse if no such field exists in the given class modelpublic static boolean enumEquals(HybrisEnumValue enum1, Object obj)
enum1 - the first enumobj - the second enum true if both objects are dynamic enum values and have the same type and code; please note
that type and code are case insensitive!Copyright © 2017 SAP SE. All Rights Reserved.