Package: org.codehaus.groovy.grails.validation

## [Java] Class GrailsDomainClassValidator

- org.codehaus.groovy.grails.validation.GrailsDomainClassValidator

- All Implemented Interfaces and Traits:
    CascadingValidator, GrailsApplicationAware

      public class GrailsDomainClassValidator
      extends java.lang.Object

  A specialised Spring validator that validates a domain class instance using the constraints defined in the static constraints closure.

  Authors:
    Graeme Rocher
  Since:
    0.1

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected GrailsDomainClass` | `domainClass` |
    `protected GrailsApplication` | `grailsApplication` |
    `protected org.springframework.context.MessageSource` | `messageSource` |
    `protected java.lang.Class<?>` | `targetClass` |

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `protected void` | `cascadeToAssociativeProperty(org.springframework.validation.Errors errors, org.springframework.beans.BeanWrapper bean, GrailsDomainClassProperty persistentProperty)` Cascades validation onto an associative property maybe a one-to-many, one-to-one or many-to-one relationship.
    `protected void` | `cascadeValidationToMany(org.springframework.validation.Errors errors, org.springframework.beans.BeanWrapper bean, GrailsDomainClassProperty persistentProperty, java.lang.String propertyName)` Cascades validation to a one-to-many type relationship.
    `protected void` | `cascadeValidationToOne(org.springframework.validation.Errors errors, org.springframework.beans.BeanWrapper bean, java.lang.Object associatedObject, GrailsDomainClassProperty persistentProperty, java.lang.String propertyName, java.lang.Object indexOrKey)` Cascades validation to a one-to-one or many-to-one property.
    `protected GrailsDomainClass` | `getAssociatedDomainClassFromApplication(java.lang.Object associatedObject)`
    `GrailsDomainClass` | `getDomainClass()`
    `protected void` | `postValidate(java.lang.Object obj, org.springframework.validation.Errors errors)` Subclasses can overrite to provide custom handling of the errors object post validation.
    `void` | `setDomainClass(GrailsDomainClass domainClass)` @param domainClass The domainClass to set.
    `void` | `setGrailsApplication(GrailsApplication grailsApplication)`
    `void` | `setMessageSource(org.springframework.context.MessageSource messageSource)` @param messageSource The messageSource to set.
    `boolean` | `supports(java.lang.Class clazz)`
    `void` | `validate(java.lang.Object obj, org.springframework.validation.Errors errors, boolean cascade)` @see org.codehaus.groovy.grails.validation.CascadingValidator#validate(Object, org.springframework.validation.Errors, boolean)
    `void` | `validate(java.lang.Object obj, org.springframework.validation.Errors errors)` @see org.springframework.validation.Validator#validate(Object, org.springframework.validation.Errors)

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### protected GrailsDomainClass domainClass

    - #### protected GrailsApplication grailsApplication

    - #### protected org.springframework.context.MessageSource messageSource

    - #### protected java.lang.Class<?> targetClass

  - ### Method Detail

    - #### protected void cascadeToAssociativeProperty(org.springframework.validation.Errors errors, org.springframework.beans.BeanWrapper bean, GrailsDomainClassProperty persistentProperty)

      Cascades validation onto an associative property maybe a one-to-many, one-to-one or many-to-one relationship.

      Parameters:
        `errors` - The Errors instnace
        `bean` - The original bean
        `persistentProperty` - The associative property

    - #### @java.lang.SuppressWarnings("rawtypes") protected void cascadeValidationToMany(org.springframework.validation.Errors errors, org.springframework.beans.BeanWrapper bean, GrailsDomainClassProperty persistentProperty, java.lang.String propertyName)

      Cascades validation to a one-to-many type relationship. Normally a collection such as a List or Set each element in the association will also be validated.

      Parameters:
        `errors` - The Errors instance
        `bean` - The original BeanWrapper
        `persistentProperty` - An association whose isOneToMeny() method returns true
        `propertyName` - The name of the property

    - #### @java.lang.SuppressWarnings("rawtypes") protected void cascadeValidationToOne(org.springframework.validation.Errors errors, org.springframework.beans.BeanWrapper bean, java.lang.Object associatedObject, GrailsDomainClassProperty persistentProperty, java.lang.String propertyName, java.lang.Object indexOrKey)

      Cascades validation to a one-to-one or many-to-one property.

      Parameters:
        `errors` - The Errors instance
        `bean` - The original BeanWrapper
        `associatedObject` - The associated object's current value
        `persistentProperty` - The GrailsDomainClassProperty instance
        `propertyName` - The name of the property
        indexOrKey

    - #### protected GrailsDomainClass getAssociatedDomainClassFromApplication(java.lang.Object associatedObject)

    - #### public GrailsDomainClass getDomainClass()

    - #### protected void postValidate(java.lang.Object obj, org.springframework.validation.Errors errors)

      Subclasses can overrite to provide custom handling of the errors object post validation.

      Parameters:
        `obj` - The object to validate
        `errors` - The Errors object

    - #### public void setDomainClass(GrailsDomainClass domainClass)

      Parameters:
        `domainClass` - The domainClass to set.

    - #### public void setGrailsApplication(GrailsApplication grailsApplication)

    - #### public void setMessageSource(org.springframework.context.MessageSource messageSource)

      Parameters:
        `messageSource` - The messageSource to set.

    - #### @java.lang.SuppressWarnings("rawtypes") public boolean supports(java.lang.Class clazz)

    - #### @java.lang.SuppressWarnings({ "unchecked", "rawtypes" }) public void validate(java.lang.Object obj, org.springframework.validation.Errors errors, boolean cascade)

      See Also:
        CascadingValidator.validate

    - #### public void validate(java.lang.Object obj, org.springframework.validation.Errors errors)

      See Also:
        org.springframework.validation.Validator#validate(Object, org.springframework.validation.Errors)