public enum FieldSupport extends Enum<FieldSupport>
| Enum Constant and Description |
|---|
COMPARISON |
EXTRACTION |
EXTRACTION_OF_PUBLIC_FIELD_ONLY |
| Modifier and Type | Method and Description |
|---|---|
static FieldSupport |
comparison()
Returns the instance dedicated to comparison of fields.
|
static FieldSupport |
extraction()
Returns the instance dedicated to extraction of fields.
|
<T> T |
fieldValue(String fieldName,
Class<T> fieldClass,
Object target)
Return the value of field from a target object.
|
<T> List<T> |
fieldValues(String fieldName,
Class<T> fieldClass,
Iterable<?> target)
|
<T> List<T> |
fieldValues(String fieldName,
Class<T> fieldClass,
Object[] target)
|
List<Object> |
fieldValues(String fieldName,
Iterable<?> target) |
boolean |
isAllowedToRead(Field field) |
boolean |
isAllowedToUsePrivateFields() |
void |
setAllowUsingPrivateFields(boolean allowUsingPrivateFields)
Sets whether the use of private fields is allowed.
|
static FieldSupport |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static FieldSupport[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final FieldSupport EXTRACTION
public static final FieldSupport EXTRACTION_OF_PUBLIC_FIELD_ONLY
public static final FieldSupport COMPARISON
public static FieldSupport[] values()
for (FieldSupport c : FieldSupport.values()) System.out.println(c);
public static FieldSupport valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant
with the specified nameNullPointerException - if the argument is nullpublic static FieldSupport extraction()
public static FieldSupport comparison()
public boolean isAllowedToUsePrivateFields()
public void setAllowUsingPrivateFields(boolean allowUsingPrivateFields)
allowUsingPrivateFields - allow private fields extraction and comparison. Default true.public <T> List<T> fieldValues(String fieldName, Class<T> fieldClass, Iterable<?> target)
List containing the values of the given field name, from the elements of the given
Iterable. If the given Iterable is empty or null, this method will return an
empty List. This method supports nested fields (e.g. "address.street.number").fieldName - the name of the field. It may be a nested field. It is left to the clients to validate for
null or empty.fieldClass - the expected type of the given field.target - the given Iterable.Iterable containing the values of the given field name, from the elements of the given
Iterable.IntrospectionError - if an element in the given Iterable does not have a field with a matching name.public <T> List<T> fieldValues(String fieldName, Class<T> fieldClass, Object[] target)
List containing the values of the given field name, from the elements of the given
Iterable. If the given Iterable is empty or null, this method will return an
empty List. This method supports nested fields (e.g. "address.street.number").fieldName - the name of the field. It may be a nested field. It is left to the clients to validate for
null or empty.fieldClass - the expected type of the given field.target - the given Iterable.Iterable containing the values of the given field name, from the elements of the given
Iterable.IntrospectionError - if an element in the given Iterable does not have a field with a matching name.public <T> T fieldValue(String fieldName, Class<T> fieldClass, Object target)
Return null if field is nested and one of the nested value is null, ex :
fieldValue(race.name, String.class, frodo) will return null if frodo.race is null
fieldName - the name of the field. It may be a nested field. It is left to the clients to validate for
null or empty.target - the given objectfieldClass - type of fieldIntrospectionError - if the given target does not have a field with a matching name.public boolean isAllowedToRead(Field field)
Copyright © 2013-2015 AssertJ. All Rights Reserved.