Package com.apgar.common.lib.constraint
Class NotMandatoryOnOtherFieldValueConstraint
java.lang.Object
com.apgar.common.lib.constraint.BundledConstraint
com.apgar.common.lib.constraint.NotMandatoryOnOtherFieldValueConstraint
- All Implemented Interfaces:
com.orchestranetworks.schema.Constraint<Object>,com.orchestranetworks.schema.ConstraintOnNull,com.orchestranetworks.schema.JavaBeanVersion
public class NotMandatoryOnOtherFieldValueConstraint
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 field has a different value than the mandatoringValue parameter.
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: constraint.com.apgar.common.lib.constraint.NotMandatoryOnOtherFieldValueConstraint Field '{0}' is mandatory when field '{1}' does not equal '{2}'
- text.properties: constraint.com.apgar.common.lib.constraint.NotMandatoryOnOtherFieldValueConstraint Field '{0}' is mandatory when field '{0}' does not equal '{1}'
Supported types: string, int, integer, decimal, boolean
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.NotMandatoryOnOtherFieldValueConstraint">
<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) Checks if fields are null and raise error/warning accordinglyvoidcheckOccurrence(Object value, com.orchestranetworks.instance.ValueContextForValidation valueContext) Performs constraint checkcom.orchestranetworks.schema.PathGets the mandatoring field pathGet the mandatoring valuevoidsetMandatoringField(String mandatoringField) Sets the mandatoring field pathvoidsetMandatoringValue(String mandatoringValue) Sets the mandatoring value according to its typevoidsetup(com.orchestranetworks.schema.ConstraintContext context) Prepares nodes for 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
-
NotMandatoryOnOtherFieldValueConstraint
public NotMandatoryOnOtherFieldValueConstraint()
-
-
Method Details
-
checkOccurrence
public void checkOccurrence(Object value, com.orchestranetworks.instance.ValueContextForValidation valueContext) throws com.orchestranetworks.schema.InvalidSchemaException Performs constraint check- 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) Prepares nodes for 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 Checks if fields are null and raise error/warning 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 path- Parameters:
mandatoringField- the mandatoringField to set
-
getMandatoringValue
Get the mandatoring value- Returns:
- the mandatoring value
-
setMandatoringValue
Sets the mandatoring value according to its type- Parameters:
mandatoringValue- mandatoringValue
-