public boolean equals(Object o) {

        if (!(o instanceof Metadata)) {
            return false;
        }

        Metadata other = (Metadata) o;

        if (other.size() != size()) {
            return false;
        }

        String[] names = names();
        for (String name : names) {
            String[] otherValues = other._getValues(name);
            String[] thisValues = _getValues(name);
            if (otherValues.length != thisValues.length) {
                return false;
            }
            for (int j = 0; j < otherValues.length; j++) {
                if (!otherValues[j].equals(thisValues[j])) {
                    return false;
                }
            }
        }
        return true;
    }
@Test
    public void testEquals() {
        Metadata meta1 = new Metadata();
        meta1.add("key", "value1");
        meta1.add("key", "value2");
        meta1.add("key2", "value12");

        Metadata meta2 = new Metadata();
        meta2.add("key", "value1");
        meta2.add("key", "value2");
        meta2.add("key2", "value12");

        assertEquals(meta1, meta2);
    }