Package com.apgar.common.lib.constraint
Class MandatoryOnOtherFieldValueOtherwiseEmptyConstraint
java.lang.Object
com.apgar.common.lib.constraint.BundledConstraint
com.apgar.common.lib.constraint.MandatoryOnOtherFieldValueOtherwiseEmptyConstraint
- All Implemented Interfaces:
com.orchestranetworks.schema.Constraint<Object>,com.orchestranetworks.schema.ConstraintOnNull,com.orchestranetworks.schema.JavaBeanVersion
public class MandatoryOnOtherFieldValueOtherwiseEmptyConstraint
extends BundledConstraint
implements com.orchestranetworks.schema.Constraint<Object>, com.orchestranetworks.schema.ConstraintOnNull
Constraint that sets mandatory the field it is defined on if the parameter mandatoringField has the same value as the mandatoringValue parameter, otherwise it should be empty.
Supported types: string, int, integer, decimal, boolean
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.MandatoryOnOtherFieldValueOtherwiseEmptyConstraint Field '{0}' is mandatory when field '{1}' = '{2}', empty otherwise
- text.properties to be set: constraint.com.apgar.common.lib.constraint.MandatoryOnOtherFieldValueOtherwiseEmptyConstraint Field '{0}' is mandatory when field '{1}' = '{2}', empty otherwise
This constraint is defined in the XSD under the field and takes for argument the path of the second mandatoring field and the mandatoring value.
<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.MandatoryOnOtherFieldValueOtherwiseEmptyConstraint">
<mandatoringField>./field</mandatoringField>
<mandatoringValue>value</mandatoringValue>
</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) Performs constraint check in case of both null and raise warning/error accordinglyvoidcheckOccurrence(Object value, com.orchestranetworks.instance.ValueContextForValidation valueContext) Performs constraint check and raise warning/error accordinglycom.orchestranetworks.schema.PathGets the mandatoring field pathGets the mandatoring valuevoidsetMandatoringField(String mandatoringField) Sets the mandatoring fieldvoidsetMandatoringValue(String mandatoringValue) Sets the mandatoring value according to its typevoidsetup(com.orchestranetworks.schema.ConstraintContext context) Preliminary check of parameters and formatting to perform constraint checktoUserDocumentation(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
-
MandatoryOnOtherFieldValueOtherwiseEmptyConstraint
public MandatoryOnOtherFieldValueOtherwiseEmptyConstraint()
-
-
Method Details
-
checkOccurrence
public void checkOccurrence(Object value, com.orchestranetworks.instance.ValueContextForValidation valueContext) throws com.orchestranetworks.schema.InvalidSchemaException Performs constraint check and raise warning/error accordingly- Specified by:
checkOccurrencein interfacecom.orchestranetworks.schema.Constraint<Object>- Throws:
com.orchestranetworks.schema.InvalidSchemaException- See Also:
-
Constraint.checkOccurrence(java.lang.Object, com.orchestranetworks.instance.ValueContextForValidation)
-
setup
public void setup(com.orchestranetworks.schema.ConstraintContext context) Preliminary check of parameters and formatting to perform constraint check- Specified by:
setupin interfacecom.orchestranetworks.schema.Constraint<Object>- See Also:
-
Constraint.setup(com.orchestranetworks.schema.ConstraintContext)
-
checkNull
public void checkNull(com.orchestranetworks.instance.ValueContextForValidation valueContext) throws com.orchestranetworks.schema.InvalidSchemaException Performs constraint check in case of both null and raise warning/error accordingly- Specified by:
checkNullin interfacecom.orchestranetworks.schema.ConstraintOnNull- Throws:
com.orchestranetworks.schema.InvalidSchemaException- See Also:
-
ConstraintOnNull.checkNull(com.orchestranetworks.instance.ValueContextForValidation)
-
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
-
getMandatoringField
public com.orchestranetworks.schema.Path getMandatoringField()Gets the mandatoring field path- Returns:
- the mandatoring field path
-
setMandatoringField
Sets the mandatoring field- Parameters:
mandatoringField- the mandatoringField to set
-
getMandatoringValue
Gets the mandatoring value- Returns:
- the mandatoring value
-
setMandatoringValue
Sets the mandatoring value according to its type- Parameters:
mandatoringValue- mandatoringValue
-