@Override public int compareTo(final FileSystemKey o) { @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable to themselves final Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>) key; final int ret = comparable.compareTo(o.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(o.fileSystemOptions); }
@Override public int compareTo(final FileSystemKey o) { @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable to themselves final Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>) key; final int ret = comparable.compareTo(o.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(o.fileSystemOptions); }
@Override public int compareTo(final FileSystemKey o) { @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable to themselves final Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>) key; final int ret = comparable.compareTo(o.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(o.fileSystemOptions); }
@Override public int compareTo(final FileSystemKey o) { @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable to themselves final Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>) key; final int ret = comparable.compareTo(o.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(o.fileSystemOptions); } }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final FileSystemOptions other = (FileSystemOptions) obj; return compareTo(other) == 0; }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final FileSystemOptions other = (FileSystemOptions) obj; return compareTo(other) == 0; }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final FileSystemOptions other = (FileSystemOptions) obj; return compareTo(other) == 0; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } FileSystemOptions other = (FileSystemOptions)obj; return compareTo(other) == 0; }
@Test public void testEqualsHashCodeAndCompareTo() { final JUnitConfigBuilder builder = JUnitConfigBuilder.getInstance(); final FileSystemOptions expected = new FileSystemOptions(); builder.setId(expected, "Test"); final FileSystemOptions actual = new FileSystemOptions(); builder.setId(actual, "Test"); Assert.assertEquals(expected, actual); Assert.assertEquals(0, actual.compareTo(expected)); Assert.assertEquals(expected.hashCode(), actual.hashCode()); builder.setNames(expected, new String[] { "A", "B", "C" }); Assert.assertNotEquals(expected, actual); Assert.assertEquals(-1, actual.compareTo(expected)); Assert.assertNotEquals(expected.hashCode(), actual.hashCode()); builder.setNames(actual, new String[] { "A", "B", "C" }); Assert.assertEquals(expected, actual); Assert.assertEquals(0, actual.compareTo(expected)); Assert.assertEquals(expected.hashCode(), actual.hashCode()); }
@Test public void testEqualsHashCodeAndCompareTo() { final JUnitConfigBuilder builder = JUnitConfigBuilder.getInstance(); final FileSystemOptions expected = new FileSystemOptions(); builder.setId(expected, "Test"); final FileSystemOptions actual = new FileSystemOptions(); builder.setId(actual, "Test"); Assert.assertEquals(expected, actual); Assert.assertEquals(0, actual.compareTo(expected)); Assert.assertEquals(expected.hashCode(), actual.hashCode()); builder.setNames(expected, new String[] { "A", "B", "C" }); Assert.assertNotEquals(expected, actual); Assert.assertEquals(-1, actual.compareTo(expected)); Assert.assertNotEquals(expected.hashCode(), actual.hashCode()); builder.setNames(actual, new String[] { "A", "B", "C" }); Assert.assertEquals(expected, actual); Assert.assertEquals(0, actual.compareTo(expected)); Assert.assertEquals(expected.hashCode(), actual.hashCode()); }