Location implements Serializable { public Optional<Location> getSubLocation() { List<String> subSegments = segments.subList(1, segments.size()); if (subSegments.isEmpty()) { return Optional.empty(); } else { return Optional.of(new Location(subSegments, queryParameters)); } } Location(String location);  Location(String location, QueryParameters queryParameters);  Location(List<String> segments);  Location(List<String> segments, QueryParameters queryParameters); List<String> getSegments(); QueryParameters getQueryParameters(); String getFirstSegment(); Optional<Location> getSubLocation(); String getPath(); String getPathWithQueryParameters(); Location toggleTrailingSlash();  }
@Test public void noSubLocation_emptyOptional() { Location location = new Location("foo"); Optional<Location> maybeSubLocation = location.getSubLocation(); Assert.assertFalse(maybeSubLocation.isPresent()); }