Package com.spotify.github.http
Class ImmutablePagination
- java.lang.Object
-
- com.spotify.github.http.ImmutablePagination
-
- All Implemented Interfaces:
Pagination
@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutablePagination extends Object implements Pagination
Immutable implementation ofPagination
.Use the builder to create immutable instances:
ImmutablePagination.builder()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImmutablePagination.Builder
Builds instances of typeImmutablePagination
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutablePagination.Builder
builder()
Creates a builder forImmutablePagination
.static ImmutablePagination
copyOf(Pagination instance)
Creates an immutable copy of aPagination
value.Integer
current()
Current page number.boolean
equals(Object another)
This instance is equal to all instances ofImmutablePagination
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:current
,last
,previous
,next
.Integer
last()
Last page number.Optional<Integer>
next()
Next page number.Optional<Integer>
previous()
Previous page number.String
toString()
Prints the immutable valuePagination
with attribute values.ImmutablePagination
withCurrent(Integer value)
Copy the current immutable object by setting a value for thecurrent
attribute.ImmutablePagination
withLast(Integer value)
Copy the current immutable object by setting a value for thelast
attribute.ImmutablePagination
withNext(int value)
Copy the current immutable object by setting a present value for the optionalnext
attribute.ImmutablePagination
withNext(Optional<Integer> optional)
Copy the current immutable object by setting an optional value for thenext
attribute.ImmutablePagination
withPrevious(int value)
Copy the current immutable object by setting a present value for the optionalprevious
attribute.ImmutablePagination
withPrevious(Optional<Integer> optional)
Copy the current immutable object by setting an optional value for theprevious
attribute.
-
-
-
Method Detail
-
current
public Integer current()
Current page number.- Specified by:
current
in interfacePagination
- Returns:
- page number
-
last
public Integer last()
Last page number.- Specified by:
last
in interfacePagination
- Returns:
- page number
-
previous
public Optional<Integer> previous()
Previous page number.- Specified by:
previous
in interfacePagination
- Returns:
- page number
-
next
public Optional<Integer> next()
Next page number.- Specified by:
next
in interfacePagination
- Returns:
- page number
-
withCurrent
public final ImmutablePagination withCurrent(Integer value)
Copy the current immutable object by setting a value for thecurrent
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for current- Returns:
- A modified copy of the
this
object
-
withLast
public final ImmutablePagination withLast(Integer value)
Copy the current immutable object by setting a value for thelast
attribute. An equals check used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for last- Returns:
- A modified copy of the
this
object
-
withPrevious
public final ImmutablePagination withPrevious(int value)
Copy the current immutable object by setting a present value for the optionalprevious
attribute.- Parameters:
value
- The value for previous- Returns:
- A modified copy of
this
object
-
withPrevious
public final ImmutablePagination withPrevious(Optional<Integer> optional)
Copy the current immutable object by setting an optional value for theprevious
attribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for previous- Returns:
- A modified copy of
this
object
-
withNext
public final ImmutablePagination withNext(int value)
Copy the current immutable object by setting a present value for the optionalnext
attribute.- Parameters:
value
- The value for next- Returns:
- A modified copy of
this
object
-
withNext
public final ImmutablePagination withNext(Optional<Integer> optional)
Copy the current immutable object by setting an optional value for thenext
attribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis
.- Parameters:
optional
- A value for next- Returns:
- A modified copy of
this
object
-
equals
public boolean equals(@Nullable Object another)
This instance is equal to all instances ofImmutablePagination
that have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:current
,last
,previous
,next
.
-
toString
public String toString()
Prints the immutable valuePagination
with attribute values.
-
copyOf
public static ImmutablePagination copyOf(Pagination instance)
Creates an immutable copy of aPagination
value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance
- The instance to copy- Returns:
- A copied immutable Pagination instance
-
builder
public static ImmutablePagination.Builder builder()
Creates a builder forImmutablePagination
.ImmutablePagination.builder() .current(Integer) // required
current
.last(Integer) // requiredlast
.previous(Integer) // optionalprevious
.next(Integer) // optionalnext
.build();- Returns:
- A new ImmutablePagination builder
-
-