ImmutableSearchResultBuilder implements SearchResultBuilder { public static SearchResultBuilder of(final SearchResult searchResult) { checkNotNull(searchResult, "search result"); final JsonArrayBuilder jsonArrayBuilder = JsonFactory.newArrayBuilder(searchResult.getItems()); final Long nextPageOffset = searchResult.getNextPageOffset().orElse(null); final String cursor = searchResult.getCursor().orElse(null); return new ImmutableSearchResultBuilder(jsonArrayBuilder).nextPageOffset(nextPageOffset).cursor(cursor); } private  ImmutableSearchResultBuilder(final JsonArrayBuilder theJsonArrayBuilder); static SearchResultBuilder newInstance(); static SearchResultBuilder of(final SearchResult searchResult); @Override SearchResultBuilder nextPageOffset(@Nullable final Long nextPageOffset); @Override SearchResultBuilder cursor(@Nullable final String cursor); @Override SearchResultBuilder add(final JsonValue value, final JsonValue... furtherValues); @Override SearchResultBuilder addAll(final Iterable<? extends JsonValue> values); @Override SearchResultBuilder remove(final JsonValue value); @Override SearchResult build();  }
@Test(expected = NullPointerException.class) public void tryToCreateNewInstanceWithNullSearchResult() { ImmutableSearchResultBuilder.of(null); }