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