@Test public void equalsTest() { final CloudnamePath twoA = new CloudnamePath(twoElements); final CloudnamePath twoB = new CloudnamePath(twoElements); final CloudnamePath none = new CloudnamePath(emptyElements); final CloudnamePath entirelyDifferent = new CloudnamePath(new String[] { "foo", "2" }); assertThat("Identical paths are equal", twoA.equals(twoB), is(true)); assertThat("Hash codes for equal objects are the same", twoA.hashCode(), is(twoB.hashCode())); assertThat("Identical paths are equal, ignore order", twoB, is(equalTo(twoA))); assertThat("Paths aren't equal to strings", twoA.equals(""), is(false)); assertThat("Empty path does not equal actual path", twoA, is(not(equalTo(none)))); assertThat("Null elements aren't equal", twoA.equals(null), is(false)); assertThat("Differen is just different", twoA, is(not(equalTo(entirelyDifferent)))); }
@Override public boolean equals(final Object other) { if (other == null || !(other instanceof CloudnamePath)) { return false; } final CloudnamePath otherPath = (CloudnamePath) other; return Arrays.deepEquals(otherPath.pathElements, pathElements); }
CloudnamePath { @Override public boolean equals(final Object other) { if (other == null || !(other instanceof CloudnamePath)) { return false; } final CloudnamePath otherPath = (CloudnamePath) other; return Arrays.deepEquals(otherPath.pathElements, pathElements); } }
CloudnamePath { @Override public boolean equals(final Object other) { if (other == null || !(other instanceof CloudnamePath)) { return false; } final CloudnamePath otherPath = (CloudnamePath) other; return Arrays.deepEquals(otherPath.pathElements, pathElements); } CloudnamePath(final String[] pathElements);  CloudnamePath(final CloudnamePath path, final String additionalElement); }
CloudnamePath { @Override public boolean equals(final Object other) { if (other == null || !(other instanceof CloudnamePath)) { return false; } final CloudnamePath otherPath = (CloudnamePath) other; return Arrays.deepEquals(otherPath.pathElements, pathElements); } CloudnamePath(final String[] pathElements);  CloudnamePath(final CloudnamePath path, final String additionalElement); static boolean isValidPathElementName(final String name); int length(); String join(final char separator); String get(final int index); boolean isSubpathOf(final CloudnamePath other); CloudnamePath getParent(); @Override boolean equals(final Object other); @Override int hashCode(); @Override String toString(); }
CloudnamePath { @Override public boolean equals(final Object other) { if (other == null || !(other instanceof CloudnamePath)) { return false; } final CloudnamePath otherPath = (CloudnamePath) other; return Arrays.deepEquals(otherPath.pathElements, pathElements); } CloudnamePath(final String[] pathElements);  CloudnamePath(final CloudnamePath path, final String additionalElement); static boolean isValidPathElementName(final String name); int length(); String join(final char separator); String get(final int index); boolean isSubpathOf(final CloudnamePath other); CloudnamePath getParent(); @Override boolean equals(final Object other); @Override int hashCode(); @Override String toString();  }