EntityAction action = ( EntityAction ) other; //sort first by entity name int roleComparison = entityName.compareTo( action.entityName ); if ( roleComparison != 0 ) { return roleComparison; } else { //then by id return persister.getIdentifierType().compare( id, action.id, session.getEntityMode() ); }
CollectionAction action = ( CollectionAction ) other; //sort first by role name int roleComparison = collectionRole.compareTo( action.collectionRole ); if ( roleComparison != 0 ) { return roleComparison; } else { //then by fk return persister.getKeyType() .compare( key, action.key, session.getEntityMode() ); }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/EntityAction.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/action/CollectionAction.java
Method name: int compareTo(Object) Method name: int compareTo(Object)
Number of AST nodes: 5 Number of AST nodes: 5
1
EntityAction action = ( EntityAction ) other;
1
CollectionAction action = ( CollectionAction ) other;
2
		//sort first by entity name
2
		//sort first by role name
3
		int roleComparison = entityName.compareTo( action.entityName );
3
		int roleComparison = collectionRole.compareTo( action.collectionRole );
4
		if ( roleComparison != 0 ) {
4
		if ( roleComparison != 0 ) {
5
			return roleComparison;
5
			return roleComparison;
6
		}
6
		}
7
		else {
7
		else {
8
			//then by id
8
			//then by fk
9
			return persister.getIdentifierType()
9
			return persister.getKeyType()
10
.compare( id, action.id, session.getEntityMode() );
10
					.compare( key, action.key, session.getEntityMode() );
11
		}
11
		}
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 comparisons13
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    EntityAction action = (EntityAction)other;
    1
    CollectionAction action = (CollectionAction)other;
    2
    int roleComparison = entityName.compareTo(action.entityName);
    2
    int roleComparison = entityName.compareTo(action.entityName);
    2
    int roleComparison = collectionRole.compareTo(action.collectionRole);
    Differences
    Expression1Expression2Difference
    entityNamecollectionRoleVARIABLE_NAME_MISMATCH
    entityNamecollectionRoleVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression action.entityName cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression action.collectionRole cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2
    int roleComparison = collectionRole.compareTo(action.collectionRole);
    3
    if (roleComparison != 0)
    3
    if (roleComparison != 0)
    4
    return roleComparison;
    4
    return roleComparison;
    else
            
                                                                                                                                                                      
    5
    return persister.getKeyType().compare(key, action.key, session.getEntityMode());
    5
    return persister.getIdentifierType().compare(id, action.id, session.getEntityMode());
                                                                                                                                                                                
    Precondition Violations (3)
    Row Violation
    1Expression action.entityName cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression action.collectionRole cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variable action with type org.hibernate.action.EntityAction , while Clone fragment #2 returns variable action with type org.hibernate.action.CollectionAction