public abstract class ElementValidationHelper extends Object
XProcessingElement
entity being validated, along with the
FlowValidationResultFactory
used for validation, the input parameter map and the destination list of
FlowValidationResult
s, and populates the said list with results of different validation invocations.Modifier and Type | Field and Description |
---|---|
(package private) XProcessingElement |
element |
(package private) FlowValidationResultFactory |
factory |
(package private) Map<String,Object> |
params
cache for parameters extracted from the element being validated
|
(package private) List<FlowValidationResult> |
results |
Constructor and Description |
---|
ElementValidationHelper(XProcessingElement element,
List<FlowValidationResult> results,
FlowValidationResultFactory factory)
Creates a new helper (wrapper) for validating a given element
|
Modifier and Type | Method and Description |
---|---|
protected abstract Map<String,Object> |
extractParameters()
Helpers should implement this method to return parameters extracted from the entity being validated
|
String |
getField(String fieldName)
Returns the string value of a given field
|
<T> T |
getField(String fieldName,
Class<T> type)
Returns value of a given field under an expected type
|
boolean |
validateBoolean(String fieldName,
boolean required,
String displayName)
Validates a field that expects a boolean value
|
boolean |
validateBoolean(String fieldName,
String displayName)
Validates a required field that expects a boolean value
|
boolean |
validateEmailAddress(String fieldName,
boolean required,
String displayName)
Validates a field expecting an email addresses
|
boolean |
validateEmailList(String fieldName,
boolean required,
String displayName)
Validates a field expecting a list of comma-separated email addresses
|
<T> boolean |
validateEnum(String fieldName,
Class<T> enumType,
String displayName)
Validates a field that expects an enum value
|
boolean |
validateNonEmptyString(String fieldName,
boolean required,
String displayName)
Validates a field expecting a non-empty string
|
boolean |
validateNonEmptyString(String fieldName,
String displayName)
Validates a required field expecting a non-empty string
|
boolean |
validateNonNegativeInteger(String fieldName,
boolean required,
String displayName)
Validates a field that expects a non-negative integer
|
boolean |
validateNonNegativeInteger(String fieldName,
String displayName)
Validates a required field that expects a non-negative integer
|
boolean |
validatePositiveInteger(String fieldName,
boolean required,
String displayName)
Validates a field that expects a positive integer
|
boolean |
validatePositiveInteger(String fieldName,
String displayName)
Validates a required field that expects a positive integer
|
boolean |
validatePositiveLong(String fieldName,
boolean required,
String displayName)
Validates a field that expects a positive long value
|
boolean |
validatePositiveLong(String fieldName,
String displayName)
Validates a required field that expects a positive long value
|
final XProcessingElement element
final List<FlowValidationResult> results
final FlowValidationResultFactory factory
public ElementValidationHelper(XProcessingElement element, List<FlowValidationResult> results, FlowValidationResultFactory factory)
element
- the XProcessingElement
to be validatedresults
- the List
of FlowValidationResult
s where validation results should be storedfactory
- the FlowValidationResultFactory
for generating FlowValidationResult
entitiespublic boolean validateBoolean(String fieldName, String displayName)
fieldName
- name of the fielddisplayName
- name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validateBoolean(String fieldName, boolean required, String displayName)
fieldName
- name of the fieldrequired
- true
if the field is a required one, false
otherwisedisplayName
- name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic <T> boolean validateEnum(String fieldName, Class<T> enumType, String displayName)
T
- the type of the enumfieldName
- name of the fieldenumType
- expected type of the assigned enum valuedisplayName
- name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validateNonNegativeInteger(String fieldName, String displayName)
fieldName
- name of the fielddisplayName
- name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validateNonNegativeInteger(String fieldName, boolean required, String displayName)
fieldName
- name of the fieldrequired
- true
if the field is a required one, false
otherwisedisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validatePositiveInteger(String fieldName, String displayName)
fieldName
- name of the fielddisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validatePositiveInteger(String fieldName, boolean required, String displayName)
fieldName
- name of the fieldrequired
- true
if the field is a required one, false
otherwisedisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validatePositiveLong(String fieldName, String displayName)
fieldName
- name of the fielddisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validatePositiveLong(String fieldName, boolean required, String displayName)
fieldName
- name of the fieldrequired
- true
if the field is a required one, false
otherwisedisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validateEmailList(String fieldName, boolean required, String displayName)
fieldName
- name of the fieldrequired
- true
if the field is a required one, false
otherwisedisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validateEmailAddress(String fieldName, boolean required, String displayName)
fieldName
- name of the fieldrequired
- true
if the field is a required one, false
otherwisedisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validateNonEmptyString(String fieldName, String displayName)
fieldName
- name of the fielddisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic boolean validateNonEmptyString(String fieldName, boolean required, String displayName)
fieldName
- name of the fieldrequired
- true
if the field is a required one, false
otherwisedisplayName
- the name to be displayed in the validation resulttrue
if the field value exists and is valid, false
otherwisepublic <T> T getField(String fieldName, Class<T> type)
T
- type of the expected return valuefieldName
- name of the fieldtype
- Class
of the expected typefieldName
as an instance of type
ClassCastException
- if the type conversion failspublic String getField(String fieldName)
fieldName
- name of the fieldfieldName
as a stringClassCastException
- if the field is not of String
typeCopyright © 2016–2019 AdroitLogic. All rights reserved.