@Override
    public boolean equals(Object obj) {
        if (obj == null || !(obj instanceof DependencyVersion)) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        final DependencyVersion other = (DependencyVersion) obj;
        final int minVersionMatchLength = Math.min(this.versionParts.size(), other.versionParts.size());
        final int maxVersionMatchLength = Math.max(this.versionParts.size(), other.versionParts.size());

        if (minVersionMatchLength == 1 && maxVersionMatchLength >= 3) {
            return false;
        }

        //TODO steal better version of code from compareTo
        for (int i = 0; i < minVersionMatchLength; i++) {
            final String thisPart = this.versionParts.get(i);
            final String otherPart = other.versionParts.get(i);
            if (!thisPart.equals(otherPart)) {
                return false;
            }
        }
        if (this.versionParts.size() > minVersionMatchLength) {
            for (int i = minVersionMatchLength; i < this.versionParts.size(); i++) {
                if (!"0".equals(this.versionParts.get(i))) {
                    return false;
                }
            }
        }

        if (other.versionParts.size() > minVersionMatchLength) {
            for (int i = minVersionMatchLength; i < other.versionParts.size(); i++) {
                if (!"0".equals(other.versionParts.get(i))) {
                    return false;
                }
            }
        }

        /*
         *  if (this.versionParts != other.versionParts && (this.versionParts == null || !this.versionParts.equals(other.versionParts))) {
         *      return false;
         *  }
         */
        return true;
    }
@Test
    public void testEquals() {
        DependencyVersion obj = new DependencyVersion("1.2.3.r1");
        DependencyVersion instance = new DependencyVersion("1.2.3");
        boolean expResult = false;
        boolean result = instance.equals(obj);
        assertEquals(expResult, result);
        obj = new DependencyVersion("1.2.3");
        expResult = true;
        result = instance.equals(obj);
        assertEquals(expResult, result);
        
        instance = new DependencyVersion("2.0.0");
        obj = new DependencyVersion("2");
        expResult = false;
        result = instance.equals(obj);
        assertEquals(expResult, result);
        
        obj = new DependencyVersion("2.0");
        expResult = true;
        result = instance.equals(obj);
        assertEquals(expResult, result);
        
        
    }