/** Fails if the subject does not have the given first element. */ public void hasFirstElement(@NullableDecl Object element) { if (actualAsNavigableSet().isEmpty()) { fail("has first element", element); return; } if (!Objects.equal(actualAsNavigableSet().first(), element)) { if (actualAsNavigableSet().contains(element)) { failWithoutActual( simpleFact( lenientFormat( "Not true that %s has first element <%s>. " + "It does contain this element, but the first element is <%s>", actualAsString(), element, actualAsNavigableSet().first()))); return; } failWithoutActual( simpleFact( lenientFormat( "Not true that %s has first element <%s>. " + "It does not contain this element, and the first element is <%s>", actualAsString(), element, actualAsNavigableSet().first()))); } }
/** Fails if the subject does not have the given last element. */ public void hasLastElement(@NullableDecl Object element) { if (actualAsNavigableSet().isEmpty()) { fail("has last element", element); return; } if (!Objects.equal(actualAsNavigableSet().last(), element)) { if (actualAsNavigableSet().contains(element)) { failWithoutActual( simpleFact( lenientFormat( "Not true that %s has last element <%s>. " + "It does contain this element, but the last element is <%s>", actualAsString(), element, actualAsNavigableSet().last()))); return; } failWithoutActual( simpleFact( lenientFormat( "Not true that %s has last element <%s>. " + "It does not contain this element, and the last element is <%s>", actualAsString(), element, actualAsNavigableSet().last()))); } }