if ( !(that instanceof Person) ) return false; Person person = (Person) that; return person.getName().equals(name);
if ( !(that instanceof Address) ) return false; Address address = (Address) that; return address.getType().equals(type) && address.getPerson().getName().equals( person.getName() );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/onetoone/formula/Person.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/onetoone/formula/Address.java
Method name: boolean equals(Object) Method name: boolean equals(Object)
Number of AST nodes: 4 Number of AST nodes: 4
1
if ( !(that instanceof Person) ) return false;
1
if ( !(that instanceof Address) ) return false;
2
		Person person = (Person) that;
2
		
3
		return p
3
Address address = (Address) that;
4
		return address.getType().equals(type) && 
4
erson.getName().equals(name);
5
			address.getPerson().getName().equals( person.getName() );
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are in different classes
Number of node comparisons8
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (!(that instanceof Person))
    1
    if (!(that instanceof Person))
    1
    if (!(that instanceof Address))
    Differences
    Expression1Expression2Difference
    org.hibernate.test.onetoone.formula.Personorg.hibernate.test.onetoone.formula.AddressVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type boolean of variable that instanceof Person does not match with type boolean of variable that instanceof Address
    • Make classes org.hibernate.test.onetoone.formula.Person and org.hibernate.test.onetoone.formula.Address extend a common superclass
    1
    if (!(that instanceof Address))
    2
    return false;
    2
    return false;
                                                                      
    3
    Address address = (Address)that;
    3
    Person person = (Person)that;
                                                                
    4
    return person.getName().equals(name);
    4
    return person.getName().equals(name);
    4
    return address.getType().equals(type) && address.getPerson().getName().equals(person.getName());
    Differences
    Expression1Expression2Difference
    person.getName().equals(name)address.getType().equals(type) && address.getPerson().getName().equals(person.getName())TYPE_COMPATIBLE_REPLACEMENT
    4
    return address.getType().equals(type) && address.getPerson().getName().equals(person.getName());
    Precondition Violations (1)
    Row Violation
    1Type boolean of variable that instanceof Person does not match with type boolean of variable that instanceof Address