Package com.apgar.common.lib.constraint
Class MandatoryIfOtherFieldEmpty
java.lang.Object
com.apgar.common.lib.constraint.BundledConstraint
com.apgar.common.lib.constraint.MandatoryIfOtherFieldEmpty
- All Implemented Interfaces:
com.orchestranetworks.schema.Constraint<Object>,com.orchestranetworks.schema.ConstraintOnNull,com.orchestranetworks.schema.JavaBeanVersion
public class MandatoryIfOtherFieldEmpty
extends BundledConstraint
implements com.orchestranetworks.schema.Constraint<Object>, com.orchestranetworks.schema.ConstraintOnNull
Constraint that checks if one field is filled, the other field should be empty. Both fields cannot be empty.
The error message and/or information message created in the error.properties and text.properties files respectively will be displayed if the constraint is not verified.
- error.properties to be set: constraint.com.apgar.common.lib.constraint.MandatoryIfOtherFieldEmpty You must either enter field '{0}' or '{1}' but not both
- text.properties to be set: constraint.com.apgar.common.lib.constraint.MandatoryIfOtherFieldEmpty You must either enter field '{0}' or '{1}' but not both
- error.properties to be set: constraint.com.apgar.common.lib.constraint.MandatoryIfOtherFieldEmpty.nullCase Field '{0}' and '{1}' cannot both be empty
- text.properties to be set: constraint.com.apgar.common.lib.constraint.MandatoryIfOtherFieldEmpty.nullCase Field '{0}' and '{1}' cannot both be empty
This constraint is defined in the XSD under the field and takes for argument the path of the second field to be compared to.
<xs:element name="sampleField" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation xml:lang="en-US">
<osd:label>Sample Field</osd:label>
</xs:documentation>
<xs:appinfo>
<osd:otherFacets>
<osd:constraint class="com.apgar.common.lib.constraint.MandatoryIfOtherFieldEmpty">
<otherFieldPath>../otherField</otherFieldPath>
<bothNullEndKeysProperty>nullCase</bothNullEndKeysProperty>
</osd:constraint>
</osd:otherFacets>
</xs:appinfo>
</xs:annotation>
</xs:element>
- Author:
- APGAR Consulting
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckNull(com.orchestranetworks.instance.ValueContextForValidation valueContext) Checks if both fields are null and raise warnings/errors accordinglyvoidcheckOccurrence(Object field, com.orchestranetworks.instance.ValueContextForValidation valueContext) Checks if field is empty and raise warnings/errors accordinglyGets the bothNullEndKeysProperty fieldGets the endKeysProperty fieldGets the other field pathvoidsetBothNullEndKeysProperty(String bothNullEndKeysProperty) Sets the setBothNullEndKeysProperty fieldvoidsetEndKeysProperty(String endKeysProperty) Sets the endKeysPropertyvoidsetOtherFieldPath(String otherFieldPath) Sets the setOtherFieldPath fieldvoidsetup(com.orchestranetworks.schema.ConstraintContext context) toUserDocumentation(Locale locale, com.orchestranetworks.instance.ValueContext valueContext) Returns constraint messageMethods inherited from class com.apgar.common.lib.constraint.BundledConstraint
createErrorUserMessage, createErrorUserMessage, createErrorUserMessage, createErrorUserMessage, createUserDocumentation, createUserDocumentation, createUserDocumentation, createUserDocumentation, getDocumentationBundleBaseName, getErrorBundleBaseName, getPropertiesBaseKeyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.orchestranetworks.schema.JavaBeanVersion
getBeanVersion
-
Constructor Details
-
MandatoryIfOtherFieldEmpty
public MandatoryIfOtherFieldEmpty()
-
-
Method Details
-
checkOccurrence
public void checkOccurrence(Object field, com.orchestranetworks.instance.ValueContextForValidation valueContext) throws com.orchestranetworks.schema.InvalidSchemaException Checks if field is empty and raise warnings/errors accordingly- Specified by:
checkOccurrencein interfacecom.orchestranetworks.schema.Constraint<Object>- Throws:
com.orchestranetworks.schema.InvalidSchemaException
-
checkNull
public void checkNull(com.orchestranetworks.instance.ValueContextForValidation valueContext) throws com.orchestranetworks.schema.InvalidSchemaException Checks if both fields are null and raise warnings/errors accordingly- Specified by:
checkNullin interfacecom.orchestranetworks.schema.ConstraintOnNull- Throws:
com.orchestranetworks.schema.InvalidSchemaException
-
setup
public void setup(com.orchestranetworks.schema.ConstraintContext context) - Specified by:
setupin interfacecom.orchestranetworks.schema.Constraint<Object>
-
toUserDocumentation
public String toUserDocumentation(Locale locale, com.orchestranetworks.instance.ValueContext valueContext) throws com.orchestranetworks.schema.InvalidSchemaException Returns constraint message- Specified by:
toUserDocumentationin interfacecom.orchestranetworks.schema.Constraint<Object>- Throws:
com.orchestranetworks.schema.InvalidSchemaException
-
setOtherFieldPath
Sets the setOtherFieldPath field- Parameters:
otherFieldPath- Other field checked by constraint
-
setBothNullEndKeysProperty
Sets the setBothNullEndKeysProperty field- Parameters:
bothNullEndKeysProperty- property for both fields null
-
setEndKeysProperty
Sets the endKeysProperty- Parameters:
endKeysProperty- endKeysProperty
-
getOtherFieldPath
Gets the other field path- Returns:
- String the other field path
-
getBothNullEndKeysProperty
Gets the bothNullEndKeysProperty field- Returns:
- String bothNullEndKeysProperty field
-
getEndKeysProperty
Gets the endKeysProperty field- Returns:
- String endKeysProperty field
-