@Override
  public boolean equals( Object obj ) {
    if ( !( obj instanceof LoggingObject ) ) {
      return false;
    }
    if ( obj == this ) {
      return true;
    }

    try {
      LoggingObject loggingObject = (LoggingObject) obj;

      // No carte object id specified on either side OR the same carte object id means: the same family.
      //
      boolean sameCarteFamily =
        ( getContainerObjectId() == null && loggingObject.getContainerObjectId() == null )
          || ( getContainerObjectId() != null && loggingObject.getContainerObjectId() != null && getContainerObjectId()
            .equals( loggingObject.getContainerObjectId() ) );

      // See if we recognize the repository ID, this is an absolute match
      //
      if ( sameCarteFamily
        && loggingObject.getObjectId() != null && loggingObject.getObjectId().equals( getObjectId() ) ) {
        return true;
      }

      // Check if objects have the same parent
      boolean sameParents =
          loggingObject.getParent() == null && this.getParent() == null || loggingObject.getParent() != null
              && this.getParent() != null && loggingObject.getParent().equals( this.getParent() );

      // If the filename is the same and parent is the same, it's the same object...
      if ( sameCarteFamily && !Utils.isEmpty( loggingObject.getFilename() )
          && loggingObject.getFilename().equals( getFilename() ) && sameParents
              && StringUtils.equals( loggingObject.getObjectName(), getObjectName() ) ) {
        return true;
      }

      // See if the carte family, the name & type and parent name & type is the same.
      // This will catch most matches except for the most exceptional use-case.
      //
      if ( !sameCarteFamily
        || ( loggingObject.getObjectName() == null && getObjectName() != null )
        || ( loggingObject.getObjectName() != null && getObjectName() == null ) ) {
        return false;
      }

      if ( sameCarteFamily
        && ( ( loggingObject.getObjectName() == null && getObjectName() == null ) || ( loggingObject
          .getObjectName().equals( getObjectName() ) ) )
        && loggingObject.getObjectType().equals( getObjectType() ) ) {

        // If there are multiple copies of this object, they both need their own channel
        //
        if ( !Utils.isEmpty( getObjectCopy() ) && !getObjectCopy().equals( loggingObject.getObjectCopy() ) ) {
          return false;
        }

        LoggingObjectInterface parent1 = loggingObject.getParent();
        LoggingObjectInterface parent2 = getParent();

        if ( ( parent1 != null && parent2 == null ) || ( parent1 == null && parent2 != null ) ) {
          return false;
        }
        if ( parent1 == null && parent2 == null ) {
          return true;
        }

        // This goes to the parent recursively...
        //
        if ( parent1.equals( parent2 ) ) {
          return true;
        }
      }
    } catch ( Exception e ) {
      e.printStackTrace();
    }

    return false;
  }
@Test
  public void testEquals() throws Exception {
    LoggingObjectInterface parent = new LoggingObject( new SimpleLoggingObject( "parent", LoggingObjectType.JOB, null ) );

    LoggingObject loggingObject1 = new LoggingObject( "test" );
    loggingObject1.setFilename( "fileName" );
    loggingObject1.setParent( parent );
    loggingObject1.setObjectName( "job1" );


    LoggingObject loggingObject2 = new LoggingObject( "test" );
    loggingObject2.setFilename( "fileName" );
    loggingObject2.setParent( parent );
    loggingObject2.setObjectName( "job2" );

    Assert.assertFalse( loggingObject1.equals( loggingObject2 ) );
  }