super.removeChild( child );
// only remove the parent from the child's set if child is no longer in the collection
if ( ! getChildren().contains( child ) ) {
( ( ChildWithBidirectionalManyToMany ) child ).removeParent( this );
}
super.removeChild( child );
// only set the parent to null if child is no longer in the bag
if ( ! getChildren().contains( child ) ) {
( ( ChildWithManyToOne ) child ).setParent( null );
}
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/event/collection/association/bidirectional/manytomany/ParentWithBidirectionalManyToMany.java
|
|
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/event/collection/association/bidirectional/onetomany/ParentWithBidirectionalOneToMany.java
|
Method name: void removeChild(Child)
|
|
Method name: void removeChild(Child)
|
Number of AST nodes: 3
|
|
Number of AST nodes: 3
|
|
1 | super.removeChild( child );↵ | | 1 | super.removeChild( child );↵
|
2 | // only remove the parent from the child's set if child is no longer in the collection↵ | | 2 | // only set the parent to null if child is no longer in the bag↵
|
3 | if ( ! getChildren().contains( child ) ) {↵ | | 3 | if ( ! getChildren().contains( child ) ) {↵
|
4 | ( ( ChildWithBidirectionalManyToMany ) child ).removeParent( this );↵ | | 4 | ( ( ChildWithManyToOne ) child ).setParent( null );↵
|
5 | } | | 5 | }
|
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 having the same super class |
Number of node comparisons | 5 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 0.6 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | super.removeChild(child); | | 1 | super.removeChild(child); |
2 | if (!getChildren().contains(child)) | | 2 | if (!getChildren().contains(child)) |
3 | ((ChildWithBidirectionalManyToMany)child).removeParent(this); | | 3 | ((ChildWithManyToOne)child).setParent(null); |
Precondition Violations (2)
Row |
Violation |
1 | Expression ((ChildWithBidirectionalManyToMany)child).removeParent(this) is a void method call, and thus it cannot be parameterized |
2 | Expression ((ChildWithManyToOne)child).setParent(null) is a void method call, and thus it cannot be parameterized |