Package com.spotify.github.http
Class ImmutablePagination.Builder
- java.lang.Object
-
- com.spotify.github.http.ImmutablePagination.Builder
-
- Enclosing class:
- ImmutablePagination
@NotThreadSafe public static final class ImmutablePagination.Builder extends Object
Builds instances of typeImmutablePagination
. Initialize attributes and then invoke thebuild()
method to create an immutable instance.Builder
is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutablePagination
build()
Builds a newImmutablePagination
.ImmutablePagination.Builder
current(Integer current)
Initializes the value for thecurrent
attribute.ImmutablePagination.Builder
from(Pagination instance)
Fill a builder with attribute values from the providedPagination
instance.ImmutablePagination.Builder
last(Integer last)
Initializes the value for thelast
attribute.ImmutablePagination.Builder
next(int next)
Initializes the optional valuenext
to next.ImmutablePagination.Builder
next(Optional<Integer> next)
Initializes the optional valuenext
to next.ImmutablePagination.Builder
previous(int previous)
Initializes the optional valueprevious
to previous.ImmutablePagination.Builder
previous(Optional<Integer> previous)
Initializes the optional valueprevious
to previous.
-
-
-
Method Detail
-
from
@CanIgnoreReturnValue public final ImmutablePagination.Builder from(Pagination instance)
Fill a builder with attribute values from the providedPagination
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
current
@CanIgnoreReturnValue public final ImmutablePagination.Builder current(Integer current)
Initializes the value for thecurrent
attribute.- Parameters:
current
- The value for current- Returns:
this
builder for use in a chained invocation
-
last
@CanIgnoreReturnValue public final ImmutablePagination.Builder last(Integer last)
Initializes the value for thelast
attribute.- Parameters:
last
- The value for last- Returns:
this
builder for use in a chained invocation
-
previous
@CanIgnoreReturnValue public final ImmutablePagination.Builder previous(int previous)
Initializes the optional valueprevious
to previous.- Parameters:
previous
- The value for previous- Returns:
this
builder for chained invocation
-
previous
@CanIgnoreReturnValue public final ImmutablePagination.Builder previous(Optional<Integer> previous)
Initializes the optional valueprevious
to previous.- Parameters:
previous
- The value for previous- Returns:
this
builder for use in a chained invocation
-
next
@CanIgnoreReturnValue public final ImmutablePagination.Builder next(int next)
Initializes the optional valuenext
to next.- Parameters:
next
- The value for next- Returns:
this
builder for chained invocation
-
next
@CanIgnoreReturnValue public final ImmutablePagination.Builder next(Optional<Integer> next)
Initializes the optional valuenext
to next.- Parameters:
next
- The value for next- Returns:
this
builder for use in a chained invocation
-
build
public ImmutablePagination build()
Builds a newImmutablePagination
.- Returns:
- An immutable instance of Pagination
- Throws:
IllegalStateException
- if any required attributes are missing
-
-