Package io.datareplication.model
Class Page<PageHeader extends ToHttpHeaders,EntityHeader extends ToHttpHeaders>
- java.lang.Object
-
- io.datareplication.model.Page<PageHeader,EntityHeader>
-
- Type Parameters:
PageHeader
- the type of the page header; in practice this will be either *SnapshotPageHeader
or *FeedPageHeader
EntityHeader
- the type of the entity headers; seeEntity
public final class Page<PageHeader extends ToHttpHeaders,EntityHeader extends ToHttpHeaders> extends java.lang.Object
ThePage
class represents a complete feed or snapshot page, both on the producer and consumer side. This class always represents a page that is fully present in memory; it does not handle streaming.
-
-
Constructor Summary
Constructors Constructor Description Page(PageHeader header, @NonNull java.lang.String boundary, @NonNull java.util.List<@NonNull Entity<@NonNull EntityHeader>> entities)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull java.lang.String
boundary()
The boundary string for the page's multipart representation.@NonNull java.util.List<@NonNull Entity<@NonNull EntityHeader>>
entities()
The list of entities for this page.boolean
equals(java.lang.Object o)
int
hashCode()
PageHeader
header()
The page's headers.@NonNull Body
toMultipartBody()
Return the body of this page as a multipart document.java.lang.String
toString()
-
-
-
Constructor Detail
-
Page
public Page(@NonNull PageHeader header, @NonNull @NonNull java.lang.String boundary, @NonNull @NonNull java.util.List<@NonNull Entity<@NonNull EntityHeader>> entities)
-
-
Method Detail
-
toMultipartBody
@NonNull public @NonNull Body toMultipartBody()
Return the body of this page as a multipart document.
This function does not allocate a buffer for the entire page body. Instead, the entities' bodies are directly reused by the returned
Body
to avoid having to keep entity bodies in memory twice.The returned body is designed to serve the page over HTTP. The returned
Body
's headers must also by served as part of the HTTP header for the page to be consumable.- Returns:
- a Body containing the page's entities as a multipart document
-
header
@NonNull public PageHeader header()
The page's headers. This does not include Content-Length and Content-Type which are included in the return value oftoMultipartBody()
.
-
boundary
@NonNull public @NonNull java.lang.String boundary()
The boundary string for the page's multipart representation.
-
entities
@NonNull public @NonNull java.util.List<@NonNull Entity<@NonNull EntityHeader>> entities()
The list of entities for this page.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-