/** * Find all the model elements in the configured {@link Profile}s * of the given meta type. * * @param metaType the meta type of the model elements to find * @return a {@link Collection} containing the model elements that * are of the given meta type */ @SuppressWarnings("unchecked") public Collection findByMetaType(Object metaType) { Set elements = new HashSet(); Iterator it = getProfileModels().iterator(); while (it.hasNext()) { Object model = it.next(); elements.addAll(Model.getModelManagementHelper() .getAllModelElementsOfKind(model, metaType)); } return elements; }
public Collection getChildren(Object parent) { Collection col = new ArrayList(); if (parent instanceof Project) { for (Object model : ((Project) parent).getUserDefinedModelList()) { col.addAll(Model.getModelManagementHelper() .getAllModelElementsOfKind(model, Model.getMetaTypes().getCollaboration())); } } return col; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/kernel/ProfileConfiguration.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/ui/explorer/rules/GoProjectToCollaboration.java
Method name: Collection findByMetaType(Object) Method name: Collection getChildren(Object)
Number of AST nodes: 3 Number of AST nodes: 2
1
/**
1
public Collection getChildren(Object parent) {
2
     * Find all the model elements in the configured {@link Profile}s 
2
	Collection col = new ArrayList();
3
     * of the given meta type.
3
        if (parent instanceof Project) {
4
     * 
4
            for (Object model : ((Project) parent).getUserDefinedModelList()) {
5
     * @param metaType the meta type of the model elements to find
5
                col.addAll(Model.getModelManagementHelper()
6
     * @return a {@link Collection} containing the model elements that 
6
                        .getAllModelElementsOfKind(model,
7
     *         are of the given meta type
7
                                Model.getMetaTypes().getCollaboration()));
8
     */
8
            }
9
    @SuppressWarnings("unchecked")
9
        }
10
    public Collection findByMetaType(Object metaType) {
10
	return col;
11
        Set elements = new HashSet();
11
    }
12
13
        Iterator it = getProfileModels().iterator();
14
        while (it.hasNext()) {
15
            Object model = it.next();
16
            elements.addAll(Model.getModelManagementHelper()
17
                    .getAllModelElementsOfKind(model, metaType));
18
        }
19
        return elements;
20
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.750
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    3
    while (it.hasNext())
    3
    while (it.hasNext())
    3
    for (Object model : ((Project)parent).getUserDefinedModelList())
    Differences
    Expression1Expression2Difference
    getProfileModelsgetUserDefinedModelListMETHOD_INVOCATION_NAME_MISMATCH
    ((Project)parent)MISSING_METHOD_INVOCATION_EXPRESSION
    3
    for (Object model : ((Project)parent).getUserDefinedModelList())
                                                                                                                                                                                                                                                      
    4
    col.addAll(Model.getModelManagementHelper().getAllModelElementsOfKind(model, Model.getMetaTypes().getCollaboration()));
    Preondition Violations
    Unmatched statement col.addAll(Model.getModelManagementHelper().getAllModelElementsOfKind(model,Model.getMetaTypes().getCollaboration())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    col.addAll(Model.getModelManagementHelper().getAllModelElementsOfKind(model, Model.getMetaTypes().getCollaboration()));
    4
    Object model = it.next();
                                                        
    5
    elements.addAll(Model.getModelManagementHelper().getAllModelElementsOfKind(model, metaType));
    5
    elements.addAll(Model.getModelManagementHelper().getAllModelElementsOfKind(model, metaType));
    Preondition Violations
    Unmatched statement elements.addAll(Model.getModelManagementHelper().getAllModelElementsOfKind(model,metaType)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                  
    Precondition Violations (2)
    Row Violation
    1Unmatched statement col.addAll(Model.getModelManagementHelper().getAllModelElementsOfKind(model,Model.getMetaTypes().getCollaboration())); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement elements.addAll(Model.getModelManagementHelper().getAllModelElementsOfKind(model,metaType)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted