View | Details | Raw Unified | Return to bug 31215
Collapse All | Expand All

(-)D:\ant\apache-ant-1.6.2\src\main/org/apache/tools/ant/AntTypeDefinition.java (-2 / +3 lines)
Lines 355-364 Link Here
355
        return
355
        return
356
            newLoader != null
356
            newLoader != null
357
            && oldLoader != null
357
            && oldLoader != null
358
            && oldLoader instanceof AntClassLoader
358
            && ((oldLoader instanceof AntClassLoader
359
            && newLoader instanceof AntClassLoader
359
            && newLoader instanceof AntClassLoader
360
            && ((AntClassLoader) oldLoader).getClasspath()
360
            && ((AntClassLoader) oldLoader).getClasspath()
361
            .equals(((AntClassLoader) newLoader).getClasspath());
361
            .equals(((AntClassLoader) newLoader).getClasspath())) ||
362
            (newLoader == oldLoader));
362
    }
363
    }
363
364
364
    private String extractClassname(Class c) {
365
    private String extractClassname(Class c) {
(-)D:\ant\apache-ant-1.6.2\src\main/org/apache/tools/ant/taskdefs/MacroDef.java (-3 / +56 lines)
Lines 359-364 Link Here
359
         * @return a <code>boolean</code> value
359
         * @return a <code>boolean</code> value
360
         */
360
         */
361
        public boolean equals(Object obj) {
361
        public boolean equals(Object obj) {
362
            if (!similar(obj)) {
363
                return false;
364
            }
365
            Attribute other = (Attribute) obj;
366
            if (defaultValue == null) {
367
                if (other.defaultValue != null) {
368
                    return false;
369
                }
370
            } else if (!defaultValue.equals(other.defaultValue)) {
371
                return false;
372
            }
373
            return true;
374
        }
375
        
376
        /**
377
         * Check attributes similarity. Only difference from {@link #equals}
378
         * method is that default value of the attribute is ignored and is
379
         * tested only for presence.
380
         */
381
        public boolean similar(Object obj) {
362
            if (obj == null) {
382
            if (obj == null) {
363
                return false;
383
                return false;
364
            }
384
            }
Lines 377-383 Link Here
377
                if (other.defaultValue != null) {
397
                if (other.defaultValue != null) {
378
                    return false;
398
                    return false;
379
                }
399
                }
380
            } else if (!defaultValue.equals(other.defaultValue)) {
400
            } else if (other.defaultValue == null) {
381
                return false;
401
                return false;
382
            }
402
            }
383
            return true;
403
            return true;
Lines 628-633 Link Here
628
     * @param obj an <code>Object</code> value
648
     * @param obj an <code>Object</code> value
629
     * @return a <code>boolean</code> value
649
     * @return a <code>boolean</code> value
630
     */
650
     */
651
    public boolean same(Object obj) {
652
        if (!similar(obj)) {
653
            return false;
654
        }
655
        MacroDef other = (MacroDef) obj;
656
        if (!attributes.equals(other.attributes)) {
657
            return false;
658
        }
659
        return true;
660
    }
661
    
631
    public boolean similar(Object obj) {
662
    public boolean similar(Object obj) {
632
        if (obj == this) {
663
        if (obj == this) {
633
            return true;
664
            return true;
Lines 670-676 Link Here
670
        if (!nestedSequential.similar(other.nestedSequential)) {
701
        if (!nestedSequential.similar(other.nestedSequential)) {
671
            return false;
702
            return false;
672
        }
703
        }
673
        if (!attributes.equals(other.attributes)) {
704
        if (!areAttributesSimilar(other.attributes)) {
674
            return false;
705
            return false;
675
        }
706
        }
676
        if (!elements.equals(other.elements)) {
707
        if (!elements.equals(other.elements)) {
Lines 678-683 Link Here
678
        }
709
        }
679
        return true;
710
        return true;
680
    }
711
    }
712
    
713
    private boolean areAttributesSimilar(List otherAttributes) {
714
        if (attributes == otherAttributes) {
715
            return true;
716
        }
717
        
718
        Iterator e1 = attributes.iterator();
719
        Iterator e2 = otherAttributes.iterator();
720
        while(e1.hasNext() && e2.hasNext()) {
721
            Object o1 = e1.next();
722
            Object o2 = e2.next();
723
            if (!(o1 instanceof Attribute) || !(o2 instanceof Attribute)) {
724
                return false;
725
            }
726
            Attribute a1 = (Attribute)o1;
727
            Attribute a2 = (Attribute)o2;
728
            if (!a1.similar(a2)) {
729
                return false;
730
            }
731
        }
732
        return !(e1.hasNext() || e2.hasNext());
733
    }
681
734
682
    /**
735
    /**
683
     * extends AntTypeDefinition, on create
736
     * extends AntTypeDefinition, on create
Lines 723-729 Link Here
723
                return false;
776
                return false;
724
            }
777
            }
725
            MyAntTypeDefinition otherDef = (MyAntTypeDefinition) other;
778
            MyAntTypeDefinition otherDef = (MyAntTypeDefinition) other;
726
            return macroDef.similar(otherDef.macroDef);
779
            return macroDef.same(otherDef.macroDef);
727
        }
780
        }
728
781
729
        /**
782
        /**

Return to bug 31215