Interface DbObject

  • All Known Implementing Classes:
    AbstractDbObject, Column, ForeignKey, Index, PrimaryKey, Schema, Sequence, Table

    public interface DbObject
    All database objects to be modelled for schema comparisons must implement this interface, examples of which include: schemas, tables, indexes, primary keys, foreign keys, sequences and columns.
    Author:
    Matt Ward
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void accept​(DbObjectVisitor visitor)
      Allows a visitor to be invoked against this DbObject.
      void diff​(DbObject right, DiffContext ctx)
      Generate a report of differences between this object ('left') and another object ('right').
      java.lang.String getName()
      All items can be asked for their name, but it may be null.
      DbObject getParent()
      Get the parent object for which this object is a child.
      java.lang.String getTypeName()
      Type name, e.g.
      java.util.List<DbValidator> getValidators()
      Retrieve the list of validators associated with this database object.
      boolean hasObjectLevelValidator()
      Is there at least one validator that assumes object-level validation that removes the requirement for reporting of differences for this object?
      boolean hasValidators()
      Does the database object have any validators associated with it?
      boolean sameAs​(DbObject other)
      Are the two DbObjects 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.
      void setParent​(DbObject parent)
      Sets the parent object.
      void setValidators​(java.util.List<DbValidator> validators)
      Set/override the validators associated with this database object.
    • Method Detail

      • sameAs

        boolean sameAs​(DbObject other)
        Are the two DbObjects 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. When a.sameAs(b) == true it 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.

        Parameters:
        other - DbObject
        Returns:
        boolean
      • getName

        java.lang.String getName()
        All items can be asked for their name, but it may be null.
        Returns:
        Name if available, null otherwise.
      • diff

        void diff​(DbObject right,
                  DiffContext ctx)
        Generate a report of differences between this object ('left') and another object ('right'). Differences between the left and right objects under inspection are captured in the Results object passed in to this method.
        Parameters:
        right - The object to compare against.
        ctx - The DiffContext
      • accept

        void accept​(DbObjectVisitor visitor)
        Allows a visitor to be invoked against this DbObject. Implementations should ensure that child objects are visited first (by calling accept on them) before invoking the visitor on itself.
        Parameters:
        visitor - DbObjectVisitor
      • getParent

        DbObject getParent()
        Get the parent object for which this object is a child. If this is the root object then null should be returned.
        Returns:
        Parent reference or null
      • setParent

        void setParent​(DbObject parent)
        Sets the parent object.
        Parameters:
        parent - DbObject
        See Also:
        getParent()
      • getValidators

        java.util.List<DbValidator> getValidators()
        Retrieve the list of validators associated with this database object.
        Returns:
        DbValidator List
        See Also:
        DbValidator
      • setValidators

        void setValidators​(java.util.List<DbValidator> validators)
        Set/override the validators associated with this database object.
      • hasValidators

        boolean hasValidators()
        Does the database object have any validators associated with it?
        Returns:
        true if there are one or more validators.
      • hasObjectLevelValidator

        boolean hasObjectLevelValidator()
        Is there at least one validator that assumes object-level validation that removes the requirement for reporting of differences for this object?
        Returns:
        boolean
      • getTypeName

        java.lang.String getTypeName()
        Type name, e.g. "column", "foreign key"
        Returns:
        String