Boolean exists = isPutQueueEnabled() ? readElementExistence(value) : null; if ( exists == null ) { initialize( true ); if ( list.remove( value ) ) { dirty(); return true; } else { return false; } } else if ( exists.booleanValue() ) { queueOperation( new SimpleRemove(value) ); return true; } else { return false; }
Boolean exists = isOperationQueueEnabled() ? readElementExistence( value ) : null; if ( exists == null ) { initialize( true ); if ( set.add( value ) ) { dirty(); return true; } else { return false; } } else if ( exists.booleanValue() ) { return false; } else { queueOperation( new SimpleAdd(value) ); return true; }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/collection/PersistentList.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/collection/PersistentSet.java
Method name: boolean remove(Object) Method name: boolean add(Object)
Number of AST nodes: 11 Number of AST nodes: 11
1
Boolean exists = isPutQueueEnabled() ? readElementExistence(value) : null;
1
Boolean exists = isOperationQueueEnabled() ? readElementExistence( value ) : null;
2
		if ( exists == null ) {
2
		if ( exists == null ) {
3
			initialize( true );
3
			initialize( true );
4
			if ( list.remove( value ) ) {
4
			if ( set.add( value ) ) {
5
				dirty();
5
				dirty();
6
				return true;
6
				return true;
7
			}
7
			}
8
			else {
8
			else {
9
				return false;
9
				return false;
10
			}
10
			}
11
		}
11
		}
12
		else if ( exists.booleanValue() ) {
12
		else if ( exists.booleanValue() ) {
13
			
13
			return false;
14
		}
15
		else {
14
queueOperation( new SimpleRemove(value) );
16
			queueOperation( new SimpleAdd(value) );
15
			return true;
17
			return true;
16
		}
18
		}
17
		else {
18
			return false;
19
		}
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.5
Clones locationClones are in different classes having the same super class
Number of node comparisons37
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)20.7
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Boolean exists = isPutQueueEnabled() ? readElementExistence(value) : null;
    1
    Boolean exists = isPutQueueEnabled() ? readElementExistence(value) : null;
    1
    Boolean exists = isOperationQueueEnabled() ? readElementExistence(value) : null;
    Differences
    Expression1Expression2Difference
    isPutQueueEnabledisOperationQueueEnabledMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression isPutQueueEnabled() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression isOperationQueueEnabled() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    1
    Boolean exists = isOperationQueueEnabled() ? readElementExistence(value) : null;
    2
    if (exists == null)
    2
    if (exists == null)
    3
    initialize(true);
    3
    initialize(true);
    4
    if (list.remove(value))
    4
    if (list.remove(value))
    4
    if (set.add(value))
    Differences
    Expression1Expression2Difference
    removeaddMETHOD_INVOCATION_NAME_MISMATCH
    listsetVARIABLE_NAME_MISMATCH
    java.util.Listjava.util.SetSUBCLASS_TYPE_MISMATCH
    4
    if (set.add(value))
    5
    dirty();
    5
    dirty();
    6
    return true;
    6
    return true;
    else
    else
    7
    return false;
    7
    return false;
    8
    else if (exists.booleanValue())
    8
    else if (exists.booleanValue())
    9
    queueOperation(new SimpleRemove(value));
    9
    queueOperation(new SimpleRemove(value));
    Preondition Violations
    Unmatched statement queueOperation(new SimpleRemove(value)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                          
    10
    return true;
    10
    return true;
    9
    return false;
    Differences
    Expression1Expression2Difference
    truefalseLITERAL_VALUE_MISMATCH
    9
    return false;
    else
    else
                                                                                      
    10
    queueOperation(new SimpleAdd(value));
    Preondition Violations
    Unmatched statement queueOperation(new SimpleAdd(value)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10
    queueOperation(new SimpleAdd(value));
    11
    return false;
    11
    return false;
    11
    return true;
    Differences
    Expression1Expression2Difference
    falsetrueLITERAL_VALUE_MISMATCH
    11
    return true;
    Precondition Violations (4)
    Row Violation
    1Expression isPutQueueEnabled() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression isOperationQueueEnabled() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement queueOperation(new SimpleRemove(value)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement queueOperation(new SimpleAdd(value)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted