/** * Builds a new {@link ListResult ListResult}. * @return An immutable instance of ListResult * @throws java.lang.IllegalStateException if any required attributes are missing */ public ListResult<T> build() { return ImmutableListResult.validate(new ImmutableListResult<T>(this)); }
/** * Copy the current immutable object by setting a value for the {@link ListResult#getTotalCount() totalCount} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for totalCount * @return A modified copy of the {@code this} object */ public final ImmutableListResult<T> withTotalCount(int value) { if (this.totalCount == value) return this; return validate(new ImmutableListResult<T>(this, value, this.items)); }
/** * Construct a new immutable {@code ListResult} instance. * @param totalCount The value for the {@code totalCount} attribute * @param items The value for the {@code items} attribute * @return An immutable ListResult instance */ public static <T> ListResult<T> of(int totalCount, Iterable<? extends T> items) { return validate(new ImmutableListResult<T>(totalCount, items)); }
/** * Copy the current immutable object with elements that replace the content of {@link ListResult#getItems() items}. * @param elements The elements to set * @return A modified copy of {@code this} object */ @SafeVarargs public final ImmutableListResult<T> withItems(T... elements) { List<T> newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableListResult<T>(this, this.totalCount, newValue)); }
/** * Copy the current immutable object with elements that replace the content of {@link ListResult#getItems() items}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of items elements to set * @return A modified copy of {@code this} object */ public final ImmutableListResult<T> withItems(Iterable<? extends T> elements) { if (this.items == elements) return this; List<T> newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableListResult<T>(this, this.totalCount, newValue)); }