Package io.datareplication.model
Class Entity<Header extends ToHttpHeaders>
- java.lang.Object
-
- io.datareplication.model.Entity<Header>
-
- Type Parameters:
Header- the type of the entity headers; in practice this will be eitherSnapshotEntityHeaderorFeedEntityHeader
- All Implemented Interfaces:
ToHttpHeaders
public final class Entity<Header extends ToHttpHeaders> extends java.lang.Object implements ToHttpHeaders
TheEntityclass represents a feed or snapshot entity. It consists of entity headers, a body, and an optional piece of user-specified metadata.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull Bodybody()The entity's body.booleanequals(java.lang.Object o)inthashCode()Headerheader()The entity's headers.@NonNull HttpHeaderstoHttpHeaders()Return all headers for this entity.java.lang.StringtoString()@NonNull java.util.Optional<@NonNull java.lang.Object>userData()An optional piece of user-specified metadata.
-
-
-
Constructor Detail
-
Entity
public Entity(@NonNull Header header, @NonNull @NonNull Body body)Create a new entity with emptyuserData.- Parameters:
header- the entity headerbody- the entity body
-
Entity
public Entity(@NonNull Header header, @NonNull @NonNull Body body, @NonNull @NonNull java.util.Optional<@NonNull java.lang.Object> userData)Creates a newEntityinstance.- Parameters:
header- The entity's headers. This does not include Content-Type and Content-Length which are associated withbody().body- The entity's body. This includes the actual bytes as well as the Content-Type and Content-Length.userData- An optional piece of user-specified metadata. The library implementation never touches or interprets it. It exists exclusively to allow library users to carry additional information with an entity as it passes through the library. This means that it is up to the library user how to handle this field at boundaries (e.g. when storing entities in a database): it's not necessary to store and load this field if you don't ever use it.This field is an internal aspect of the library intended for producers: it is not part of the data format and won't be included in a consumable snapshot or feed. When consuming entities from a feed or snapshot, this field will always be empty.
-
-
Method Detail
-
toHttpHeaders
@NonNull public @NonNull HttpHeaders toHttpHeaders()
Return all headers for this entity. This combines the actual entity headers with the Content-Type and Content-Length headers from thebody.- Specified by:
toHttpHeadersin interfaceToHttpHeaders- Returns:
- all headers for this entity
-
header
@NonNull public Header header()
The entity's headers. This does not include Content-Type and Content-Length which are associated withbody().
-
body
@NonNull public @NonNull Body body()
The entity's body. This includes the actual bytes as well as the Content-Type and Content-Length.
-
userData
@NonNull public @NonNull java.util.Optional<@NonNull java.lang.Object> userData()
An optional piece of user-specified metadata. The library implementation never touches or interprets it. It exists exclusively to allow library users to carry additional information with an entity as it passes through the library. This means that it is up to the library user how to handle this field at boundaries (e.g. when storing entities in a database): it's not necessary to store and load this field if you don't ever use it.This field is an internal aspect of the library intended for producers: it is not part of the data format and won't be included in a consumable snapshot or feed. When consuming entities from a feed or snapshot, this field will always be empty.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-