public abstract class DBObjectValidator<T extends DBObject> extends CascadeWorker<T> implements DBObjectValidator<T>
Implementors use this class as a starting point for validation logic as validation of name, schema name (if appropriate) and duplication of name are provided by the base implementation.
 To validate a SchemaObject implementation, subclass
 SchemaObjectValidator
 
 To implement property specific validation, the DBObjectValidator.PropertyValidator
 annotation can be used to mark methods as being the validation for a given
 property or properties. Such methods are automatically called when a call
 to validateObjectProperty(DBObject,DBObject,String) is made. They
 are all called when validateObject(DBObject,DBObject) is called.
 
An example validator template:
 public class MyObjectValidator extends DBObjectValidator<MyObject>
 {
   public MyObjectValidator( DBObjectProvider pro )
   {
     super( pro );
   }
   @PropertyValidator( Property.myProp1 )
   public void validateMyProp1( MyObject original, MyObject update )
   throws ValidationException
   {
     // TODO: validation logic for myProp1 here that will always run
   }
   @PropertyValidator( value = Property.myProp2,
                       level = ValidationLevel.FULL )
   public void validateMyProp2( MyObject original, MyObject update )
   throws ValidationException
   {
     // TODO: validation logic for myProp2 here that only runs if the
     // validation level is FULL
   }
   @PropertyValidator( Property.myProp3 )
   public void validateMyProp3( ValidationContext context )
   throws ValidationException
   {
     // TODO: validation logic for myProp3 here that always runs
     if( context.getLevel() == ValidationLevel.FULL )
     {
       // TODO: validation logic for myProp3 here that only runs if the
       // validation level is FULL
     }
   }
 }
 
 This is now a complete validator implementation for MyObject with its one
 myProp property.| Modifier and Type | Class and Description | 
|---|---|
| static class  | DBObjectValidator.NamespaceTypeTypes of namespace check that can be done when verifying that a given
 object's name is unqiue with the database. | 
| protected static interface  | DBObjectValidator.PropertyDependencyIdentifiers the property that a method that has a PropertyValidator is
 dependent on the value of other properties, and therefore the validation
 is also co-dependent. | 
| protected static interface  | DBObjectValidator.PropertyValidatorMarks a method as being the validation logic for a given property, or
 properties. | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | DBObjectValidator(DBObjectProvider pro) | 
| Modifier and Type | Method and Description | 
|---|---|
| protected boolean | canHaveEmptyName()By default names cannot be empty (or null). | 
| protected boolean | canRename()Default name validation is to allow rename on update. | 
| protected void | checkInterrupt()Checks whether validation has been interrupted or cancelled and throws
 an exception to stop validation. | 
| protected boolean | enforceChildNameUniqueInSchema(DBObject child)Deprecated. 
 replaced by  #getNamespaceType(DBObject). | 
| protected T | findExistingObject(T object)Deprecated. 
 no longer used, will be removed in future. | 
| java.util.Collection<java.lang.String[]> | getDependencies(java.lang.String path) | 
| DBObjectValidator.NamespaceType | getNamespaceType()Gets the type of namespace check that should be done by
  validateNameInUse(T). | 
| boolean | initializeWithDefaultName()Tests whether a newly created object should be initialized with a
 default base name. | 
| protected boolean | isChildOfPendingObject(DBObject obj)Tests whether the given object has a SchemaObject parent that is a pending
 (templated) object. | 
| protected boolean | isPendingObject(SchemaObject obj)Tests whether the given SchemaObject is pending a template expansion. | 
| protected java.util.Collection<java.lang.String> | listAlwaysValidProperties()Lists the properties that are always valid for this object. | 
| protected void | logException(DBException dbe,
            java.util.logging.Level level)Logs the message for the given DBException to an appropriate level. | 
| protected boolean | shouldValidateProperty(ValidationContext<? extends T> context,
                      java.lang.String propertyName)Tests whether validation should be fired for the given context. | 
| void | validate(ValidationContext<? extends T> context)Performs the validation defined by the given context. | 
| void | validateComment(T original,
               T update) | 
| protected void | validateMissingPath(T original,
                   T updated,
                   java.lang.String property)When a path is validated, and the start of that path is missing the
 root object, this method is called to allow subclasses to customise
 validation for mandatory child properties when their parent is missing. | 
| void | validateName(java.lang.String type,
            java.lang.String externalName)Validates that the given name is a valid identifier for the given
 object type. | 
| protected void | validateName(T obj)Validates the given object's name to see if it is a legal identifier. | 
| void | validateName(T original,
            T updated)Validates that the name for the object is a valid identifier. | 
| protected void | validateNameInUse(T object)Validates whether the given name is already in use. | 
| protected void | validateNameInUse(T object,
                 DBObjectValidator.NamespaceType nsType)Validates whether the given name is already in use. | 
| protected void | validateNonNullableProperty(DBObject original,
                           DBObject updated,
                           java.lang.String propName)Validate that the property has not been updated from not null to null in
 an online database. | 
| void | validateObject(T object)Deprecated. 
 replaced by  validate(ValidationContext) | 
| void | validateObject(T original,
              T updated)Deprecated. 
 replaced by  validate(ValidationContext).
 Overriding this method disables all ValidationLevel awareness. | 
| void | validateObjectProperty(T object,
                      java.lang.String property)Deprecated. 
 replaced by  validate(ValidationContext) | 
| void | validateObjectProperty(T original,
                      T updated,
                      java.lang.String property)Deprecated. 
 replaced by  validate(ValidationContext).
 Overriding this method disables all ValidationLevel awareness. | 
| protected void | validateOwnedObjects(DBObject... children)Deprecated. 
 | 
| protected void | validateOwnedObjects(ValidationLevel level,
                    DBObject... children)Convenience method to call validateObject on the provider for any owned
 objects. | 
| void | validateType(T original,
            T updated)If original is not null, this validates that the objects are of the
 same type. | 
| static void | validateUniqueNames(DBObject[] objs)Deprecated. 
 with no replacement. Unique name validation is done by
 validateNameInUse. | 
cascadeDelete, cascadeDelete, cascadePropertyChange, cascadeUpdate, getCascadeProperties, getLogger, getProvider, removeReferenceprotected DBObjectValidator(DBObjectProvider pro)
protected void checkInterrupt()
                       throws ValidationCancelledException
ValidationCancelledException - if validation should stopprotected void logException(DBException dbe, java.util.logging.Level level) throws ValidationCancelledException
Use this method to log non-fatal exceptions ( e.g. resolveID() ) during validation so that a cancel/interrupt is not missed.
dbe - the exception to loglevel - the level to log the exception's message at.ValidationCancelledException - if the DBException is a
 CancelledException.@Deprecated public final void validateObject(T object) throws ValidationException
validate(ValidationContext)validateObject in interface DBObjectValidator<T extends DBObject>ValidationException@Deprecated public final void validateObjectProperty(T object, java.lang.String property) throws ValidationException
validate(ValidationContext)validateObjectProperty in interface DBObjectValidator<T extends DBObject>ValidationExceptionprotected boolean shouldValidateProperty(ValidationContext<? extends T> context, java.lang.String propertyName)
context - the overall context for the validation being performedpropertyName - the specific property that is about to be validated
 from the context@PropertyValidator(propertyName)
 called).public void validateObject(T original, T updated) throws ValidationException
validate(ValidationContext).
 Overriding this method disables all ValidationLevel awareness.validateObject in interface DBObjectValidator<T extends DBObject>ValidationException@Deprecated public void validateObjectProperty(T original, T updated, java.lang.String property) throws ValidationException
validate(ValidationContext).
 Overriding this method disables all ValidationLevel awareness.validateObjectProperty in interface DBObjectValidator<T extends DBObject>ValidationExceptionpublic final void validate(ValidationContext<? extends T> context) throws ValidationException
If the context does not contain an original object, any name validation will include a check to see whether the name is already in use. The original object is also required for any validation logic specifically checking whether a property can be changed.
context - the validation context defining the required validationValidationException - if the validation finds any errors with the
 objects being validated. ValidationExceptions can be be chained, so
 multiple errors can be reported.protected void validateMissingPath(T original, T updated, java.lang.String property) throws ValidationException
original - the original objectupdated - the updated objectproperty - the property path whose first property is null on the
 updated object.ValidationExceptionprotected java.util.Collection<java.lang.String> listAlwaysValidProperties()
This should not be used to simply suppress warnings for properties that genuinely require validation. Add a validation method instead.
This will be checked after an annotated validation method cannot be found, so that if you subclass another validator that lists a property as "always valid" and you wish to add validation for it, your annotated validation method will still be called regardless of the contents of this collection.
In order to support heirarchical listing subclasses are expected to add to the super's return value. For example:
   protected Collection<String> listAlwaysValidProperties()
   {
     final Collection<String> retval = super.listAlwaysValidProperties();
     retval.add( Property.myValidProperty );
     return retval;
   }
 public final void validateType(T original, T updated) throws ValidationException
original - the original objectupdated - the updated objectValidationException - if original is not null and updated has a
 different type.public final void validateName(T original, T updated) throws ValidationException
original is null, or the name has changed on updated
 this also checks that the name is unique within the appropriate
 namespace.original - the original objectupdated - the updated objectValidationException - if the name if invalidcanRename(), 
validateName(DBObject), 
validateNameInUse(DBObject)protected final boolean isChildOfPendingObject(DBObject obj)
protected final boolean isPendingObject(SchemaObject obj)
protected void validateName(T obj) throws InvalidNameException
 This method should only be overridden to provide logic specific to
 an actual object. For generic name validation subclasses must override
 validateName(String,String), as that is also called by
 DBObjectProvider.validateName(String,String).
obj - the object whose name requires validationInvalidNameExceptionvalidateNameInUse(DBObject)public void validateName(java.lang.String type,
                         java.lang.String externalName)
                  throws InvalidNameException
type will be an object type that this validator
 is registered against in a provider.
 
 The default implementation just calls
 DatabaseDescriptor.validateName(String,String) to validate
 invalid characters and reserved words. Override to include custom
 logic.
type - the object typeexternalName - the name to validateInvalidNameExceptionprotected final void validateNonNullableProperty(DBObject original, DBObject updated, java.lang.String propName) throws ValidationException
original - the orginal object owning the propertyupdated - the updated objectpropName - the name of the propertyValidationException - if the property value has been updated from
 a non-null value to null and the context provider is an online database.protected boolean canHaveEmptyName()
DBObjectValidator.NamespaceType.NONE
 to indicate no name validation. To allow null names but also validate
 their uniqueness override both methods.protected boolean canRename()
protected void validateNameInUse(T object) throws NameInUseException
NameInUseExceptionprotected final void validateNameInUse(T object, DBObjectValidator.NamespaceType nsType) throws NameInUseException
object - the object whose name should be checkednsType - the namespace to check for uniquenessNameInUseException@Deprecated protected T findExistingObject(T object) throws ValidationException
ValidationExceptionpublic DBObjectValidator.NamespaceType getNamespaceType()
validateNameInUse(T). By default this will return TYPE unless
 canHaveEmptyName() returns true, then it will return NONE.
 Override as appropriate.public boolean initializeWithDefaultName()
canHaveEmptyName() and getNamespaceType().@Deprecated protected boolean enforceChildNameUniqueInSchema(DBObject child)
#getNamespaceType(DBObject).public void validateComment(T original, T update) throws ValidationException
ValidationExceptionpublic java.util.Collection<java.lang.String[]> getDependencies(java.lang.String path)
@Deprecated protected final void validateOwnedObjects(DBObject... children) throws ValidationException
validateOwnedObjects(ValidationLevel,DBObject[]).ValidationExceptionprotected final void validateOwnedObjects(ValidationLevel level, DBObject... children) throws ValidationException
level - the validation level to validate tochildren - the children to validateuniqueNames - whether to validate that the name of each child in
 the array is uniqueValidationException - if any of the children is invalid@Deprecated public static void validateUniqueNames(DBObject[] objs) throws ValidationException
ValidationException