in ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java [1110:1304]
public boolean equals( Object o )
{
// Basic equals checks
if ( this == o )
{
return true;
}
if ( o == null )
{
return false;
}
if ( !( o instanceof LdifEntry ) )
{
return false;
}
LdifEntry otherEntry = ( LdifEntry ) o;
// Check the Dn
Dn thisDn = entryDn;
Dn dnEntry = otherEntry.getDn();
if ( !thisDn.equals( dnEntry ) )
{
return false;
}
// Check the changeType
if ( changeType != otherEntry.changeType )
{
return false;
}
// Check each different cases
switch ( changeType )
{
case None:
// Fall through
case Add:
// Checks the attributes
if ( entry.size() != otherEntry.entry.size() )
{
return false;
}
if ( !entry.equals( otherEntry.entry ) )
{
return false;
}
break;
case Delete:
// Nothing to do, if the DNs are equals
break;
case Modify:
// Check the modificationItems list
// First, deal with special cases
if ( modificationList == null )
{
if ( otherEntry.modificationList != null )
{
return false;
}
else
{
break;
}
}
if ( otherEntry.modificationList == null )
{
return false;
}
if ( modificationList.size() != otherEntry.modificationList.size() )
{
return false;
}
// Now, compares the contents
int i = 0;
for ( Modification modification : modificationList )
{
if ( !modification.equals( otherEntry.modificationList.get( i ) ) )
{
return false;
}
i++;
}
break;
case ModDn:
case ModRdn:
// Check the deleteOldRdn flag
if ( deleteOldRdn != otherEntry.deleteOldRdn )
{
return false;
}
// Check the newRdn value
try
{
Rdn thisNewRdn = new Rdn( newRdn );
Rdn entryNewRdn = new Rdn( otherEntry.newRdn );
if ( !thisNewRdn.equals( entryNewRdn ) )
{
return false;
}
}
catch ( LdapInvalidDnException ine )
{
return false;
}
// Check the newSuperior value
try
{
Dn thisNewSuperior = new Dn( newSuperior );
Dn entryNewSuperior = new Dn( otherEntry.newSuperior );
if ( !thisNewSuperior.equals( entryNewSuperior ) )
{
return false;
}
}
catch ( LdapInvalidDnException ine )
{
return false;
}
break;
default:
// do nothing
break;
}
if ( controls != null )
{
Map<String, LdifControl> otherControls = otherEntry.controls;
if ( otherControls == null )
{
return false;
}
if ( controls.size() != otherControls.size() )
{
return false;
}
for ( Map.Entry<String, LdifControl> controlEntry : controls.entrySet() )
{
String controlOid = controlEntry.getKey();
if ( !otherControls.containsKey( controlOid ) )
{
return false;
}
Control thisControl = controlEntry.getValue();
Control otherControl = otherControls.get( controlOid );
if ( thisControl == null )
{
if ( otherControl != null )
{
return false;
}
}
else
{
if ( !thisControl.equals( otherControl ) )
{
return false;
}
}
}
return true;
}
else
{
return otherEntry.controls == null;
}
}