Class AbstractDbObject
java.lang.Object
org.alfresco.util.schemacomp.model.AbstractDbObject
- All Implemented Interfaces:
DbObject
- Direct Known Subclasses:
Column,ForeignKey,Index,PrimaryKey,Schema,Sequence,Table
Useful base class for many, if not all the
DbObject implementations.- Author:
- Matt Ward
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDbObject(DbObject parent, String name) Instantiate, giving the object a parent and a name. -
Method Summary
Modifier and TypeMethodDescriptionvoiddiff(DbObject right, DiffContext ctx) Provides an implementation ofDbObject.diff(DbObject, DiffContext).protected voiddoDiff(DbObject right, DiffContext ctx) Override this method to provide subclass specific diffing logic.booleangetName()All items can be asked for their name, but it may be null.Get the parent object for which this object is a child.Type name, e.g.Retrieve the list of validators associated with this database object.inthashCode()booleanIs there at least one validator that assumes object-level validation that removes the requirement for reporting of differences for this object?booleanDoes the database object have any validators associated with it?booleanAre the twoDbObjects logically the same? For example two Index objects may have different names, but are the same index as they both index the same columns for the same table.voidsetComparisonUtils(ComparisonUtils comparisonUtils) If a ComparisonUtils other than the default is required, then this setter can be used.voidvoidSets the parent object.voidsetValidators(List<DbValidator> validators) Set/override the validators associated with this database object.toString()
-
Field Details
-
comparisonUtils
-
-
Constructor Details
-
AbstractDbObject
Instantiate, giving the object a parent and a name.- Parameters:
parent- DbObjectname- String
-
-
Method Details
-
getName
Description copied from interface:DbObjectAll items can be asked for their name, but it may be null. -
setName
- Parameters:
name- the name to set
-
sameAs
Description copied from interface:DbObjectAre the twoDbObjects logically the same? For example two Index objects may have different names, but are the same index as they both index the same columns for the same table.If two objects a and b have the same logical identity, it does not mean that
a.equals(b) == true. The two objects may well have differences and will be flagged as such by the schema comparison tool. Whena.sameAs(b) == trueit makes it easier to show the differences as related, i.e. a and b are different rather than, a is only in the 'left' tree and b is only in the 'right' tree. -
hashCode
public int hashCode() -
equals
-
toString
-
diff
Provides an implementation ofDbObject.diff(DbObject, DiffContext). The template methoddoDiff(DbObject, DiffContext)provides the subclass specific diffing logic, whilst this method handles the workflow required in most cases: set the path's prefix that will be used to explain where differences occur; compare the name fields of the two objects; delegate to the subclass specific diffing (if any); remove the last path addition ready for the next object to perform its diff correctly. -
getParent
Description copied from interface:DbObjectGet the parent object for which this object is a child. If this is the root object then null should be returned. -
setParent
Description copied from interface:DbObjectSets the parent object. -
doDiff
Override this method to provide subclass specific diffing logic.- Parameters:
right- DbObjectctx- DiffContext
-
setComparisonUtils
If a ComparisonUtils other than the default is required, then this setter can be used. Useful for testing, where a mock can be injected.- Parameters:
comparisonUtils- the comparisonUtils to set
-
getValidators
Description copied from interface:DbObjectRetrieve the list of validators associated with this database object.- Specified by:
getValidatorsin interfaceDbObject- Returns:
- DbValidator List
- See Also:
-
setValidators
Description copied from interface:DbObjectSet/override the validators associated with this database object.- Specified by:
setValidatorsin interfaceDbObject- Parameters:
validators- the validators to set
-
hasValidators
public boolean hasValidators()Description copied from interface:DbObjectDoes the database object have any validators associated with it?- Specified by:
hasValidatorsin interfaceDbObject- Returns:
- true if there are one or more validators.
-
hasObjectLevelValidator
public boolean hasObjectLevelValidator()Description copied from interface:DbObjectIs there at least one validator that assumes object-level validation that removes the requirement for reporting of differences for this object?- Specified by:
hasObjectLevelValidatorin interfaceDbObject- Returns:
- boolean
-
getTypeName
Description copied from interface:DbObjectType name, e.g. "column", "foreign key"- Specified by:
getTypeNamein interfaceDbObject- Returns:
- String
-