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 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1 |
Clones location | Clones are in different classes |
Number of node comparisons | 13 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 1.4 |
Clone type | Type 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 = entityName.compareTo(action.entityName); |
3 | if (roleComparison != 0) | | 3 | if (roleComparison != 0) |
4 | | | 4 | |
| | | | |
| | | 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 |
1 | Expression action.collectionRole cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression action.entityName cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Clone fragment #1 returns variable action with type org.hibernate.action.CollectionAction , while Clone fragment #2 returns variable action with type org.hibernate.action.EntityAction |