Index current = (Index) indexes.get( index.getName() ); if ( current != null ) { throw new MappingException( "Index " + index.getName() + " already exists!" ); } indexes.put( index.getName(), index ); return index;
UniqueKey current = (UniqueKey) uniqueKeys.get( uniqueKey.getName() ); if ( current != null ) { throw new MappingException( "UniqueKey " + uniqueKey.getName() + " already exists!" ); } uniqueKeys.put( uniqueKey.getName(), uniqueKey ); return uniqueKey;
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/mapping/Table.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/mapping/Table.java
Method name: Index addIndex(Index) Method name: UniqueKey addUniqueKey(UniqueKey)
Number of AST nodes: 5 Number of AST nodes: 5
1
Index current = (Index) indexes.get( index.getName() );
1
UniqueKey current = (UniqueKey) uniqueKeys.get( uniqueKey.getName() );
2
		if ( current != null ) {
2
		if ( current != null ) {
3
			throw new MappingException( "Index " + index.getName() + " already exists!" );
3
			throw new MappingException( "UniqueKey " + uniqueKey.getName() + " already exists!" );
4
		}
4
		}
5
		indexes.put( index.getName(), index );
5
		uniqueKeys.put( uniqueKey.getName(), uniqueKey );
6
		return index;
6
		return uniqueKey;
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 declared in the same class
Number of node comparisons13
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                            
    1
    UniqueKey current = (UniqueKey)uniqueKeys.get(uniqueKey.getName());
    1
    Index current = (Index)indexes.get(index.getName());
                                                                                                              
    2
    if (current != null)
    2
    if (current != null)
    2
    if (current != null)
    Differences
    Expression1Expression2Difference
    org.hibernate.mapping.Indexorg.hibernate.mapping.UniqueKeyVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.mapping.Index of variable current does not match with type org.hibernate.mapping.UniqueKey of variable current
    • Make classes org.hibernate.mapping.Index and org.hibernate.mapping.UniqueKey extend a common superclass
    2
    if (current != null)
                                                                                                                                                                                  
    3
    throw new MappingException("UniqueKey " + uniqueKey.getName() + " already exists!");
    Preondition Violations
    Unmatched throw new MappingException("UniqueKey " + uniqueKey.getName() + " already exists!");
    3
    throw new MappingException("UniqueKey " + uniqueKey.getName() + " already exists!");
    3
    throw new MappingException("Index " + index.getName() + " already exists!");
    3
    throw new MappingException("Index " + index.getName() + " already exists!");
    Preondition Violations
    Unmatched throw new MappingException("Index " + index.getName() + " already exists!");
                                                                                                                                                                  
    4
    indexes.put(index.getName(), index);
    4
    indexes.put(index.getName(), index);
    4
    uniqueKeys.put(uniqueKey.getName(), uniqueKey);
    Differences
    Expression1Expression2Difference
    indexuniqueKeyVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Indexorg.hibernate.mapping.UniqueKeyVARIABLE_TYPE_MISMATCH
    indexuniqueKeyVARIABLE_NAME_MISMATCH
    org.hibernate.mapping.Indexorg.hibernate.mapping.UniqueKeyVARIABLE_TYPE_MISMATCH
    indexesuniqueKeysVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type org.hibernate.mapping.Index of variable index does not match with type org.hibernate.mapping.UniqueKey of variable uniqueKey
    • Make classes org.hibernate.mapping.Index and org.hibernate.mapping.UniqueKey extend a common superclass
    Type org.hibernate.mapping.Index of variable index does not match with type org.hibernate.mapping.UniqueKey of variable uniqueKey
    • Make classes org.hibernate.mapping.Index and org.hibernate.mapping.UniqueKey extend a common superclass
    4
    uniqueKeys.put(uniqueKey.getName(), uniqueKey);
                                            
    5
    return uniqueKey;
    Preondition Violations
    Unmatched return uniqueKey;
    5
    return uniqueKey;
    5
    return index;
    5
    return index;
    Preondition Violations
    Unmatched return index;
                                    
    Precondition Violations (7)
    Row Violation
    1Type org.hibernate.mapping.Index of variable current does not match with type org.hibernate.mapping.UniqueKey of variable current
    2Unmatched throw new MappingException("UniqueKey " + uniqueKey.getName() + " already exists!");
    3Unmatched throw new MappingException("Index " + index.getName() + " already exists!");
    4Type org.hibernate.mapping.Index of variable index does not match with type org.hibernate.mapping.UniqueKey of variable uniqueKey
    5Type org.hibernate.mapping.Index of variable index does not match with type org.hibernate.mapping.UniqueKey of variable uniqueKey
    6Unmatched return uniqueKey;
    7Unmatched return index;