109-1-3

if (this == another) { return true; } if (isReference()) { return getCheckedRef().equals(another); } if (!(another.getClass().equals(getClass()))) { return false; } URLResource otheru = (URLResource) another; return getURL() == null ? otheru.getURL() == null : getURL().equals(otheru.getURL());
if (this == another) { return true; } if (isReference()) { return getCheckedRef().equals(another); } if (!(another.getClass().equals(getClass()))) { return false; } ArchiveResource r = (ArchiveResource) another; return getArchive().equals(r.getArchive()) && getName().equals(r.getName());

Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/resources/URLResource.java |  | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/types/resources/ArchiveResource.java
Method name: `boolean equals(Object)` |  | Method name: `boolean equals(Object)`
Number of AST nodes: 8 |  | Number of AST nodes: 8

1

    if (this == another) {↵

1

    if (this == another) {↵

2

                return true;↵

2

                return true;↵

3

            }↵

3

            }↵

4

            if (isReference()) {↵

4

            if (isReference()) {↵

5

                return getCheckedRef().equals(another);↵

5

                return getCheckedRef().equals(another);↵

6

            }↵

6

            }↵

7

            if (!(another.getClass().equals(getClass()))) {↵

7

            if (!(another.getClass().equals(getClass()))) {↵

8

                return false;↵

8

                return false;↵

9

            }↵

9

            }↵

10

            URLResource otheru = (URLResource) another;↵

10

            ArchiveResource r = (ArchiveResource) another;↵

11

            return getURL() == null↵

11

            return get↵

12

                ? otheru.getURL() == null↵

12

    Archive().equals(r.getArchive())↵

13

                : getURL().equals(otheru.getURL());

13

                && getName().equals(r.getName());

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.7
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 31

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 7
   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

       if (this == another)

   1

       if (this == another)

   2

       return true;

   2

       return true;

   3

       if (isReference())

   3

       if (isReference())

   4

       return getCheckedRef().equals(another);

   4

       return getCheckedRef().equals(another);

   5

       if (!(another.getClass().equals(getClass())))

   5 | if (!(another.getClass().equals(getClass())))
   5 | if (!(another.getClass().equals(getClass())))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.Class | java.lang.Class | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.Class<> of variable getClass() does not match with type java.lang.Class<> of variable getClass()
   - Make classes java.lang.Class and java.lang.Class extend a common superclass

   5

       if (!(another.getClass().equals(getClass())))

   6

       return false;

   6

       return false;

   7

       URLResource otheru = (URLResource)another;

   7 | URLResource otheru = (URLResource)another;
   7 | ArchiveResource r = (ArchiveResource)another;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.apache.tools.ant.types.resources.URLResource | org.apache.tools.ant.types.resources.ArchiveResource | SUBCLASS_TYPE_MISMATCH
   otheru | r | VARIABLE_NAME_MISMATCH
   org.apache.tools.ant.types.resources.URLResource | org.apache.tools.ant.types.resources.ArchiveResource | SUBCLASS_TYPE_MISMATCH
   org.apache.tools.ant.types.resources.URLResource | org.apache.tools.ant.types.resources.ArchiveResource | SUBCLASS_TYPE_MISMATCH

   7

       ArchiveResource r = (ArchiveResource)another;

   8

       return getArchive().equals(r.getArchive()) && getName().equals(r.getName());

   8

       return getURL() == null ? otheru.getURL() == null : getURL().equals(otheru.getURL());

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Type java.lang.Class<> of variable getClass() does not match with type java.lang.Class<> of variable getClass()
   2 | Clone fragment #1 returns variable otheru with type org.apache.tools.ant.types.resources.URLResource , while Clone fragment #2 returns variable r with type org.apache.tools.ant.types.resources.ArchiveResource