AbstractNode implements MediaNode { @Override @SuppressWarnings("NullableProblems") public int compareTo(final MediaNode o) { if (this.getType() == o.getType()) { return this.name.compareTo(o.getName()); } else if (this.getType() == NodeType.TYPE_FOLDER) { return -1; } else { return 1; } } AbstractNode(final NodeType type, final String id, final String parentId, final String name); @Override String getId(); @Override String getParentId(); @Override String getName(); @Override NodeType getType(); @Override Long getModifiedDate(); @Override void setModifiedDate(final Long modifiedDate); @Override String getIconUrl(); @Override void setIconUrl(final String iconUrl); @Override @SuppressWarnings("NullableProblems") int compareTo(final MediaNode o); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testCompareTo() { AbstractNodeTester node = buildAbstractNodeTester(""); AbstractNodeTester node1 = buildAbstractNodeTester(""); AbstractNodeTester node2 = buildAbstractNodeTester("2"); assertEquals(node.compareTo(node1), 0); assertNotEquals(node.compareTo(node2), 0); assertNotEquals(node.compareTo(buildAbstractNodeTesterFolder("")), 0); }