public class Draft extends Descriptor
publish(). They can be saved server-side using save(). Drafts will
not attempt to synchronize themselves, it is the responsibility of the user to either save or publish them, each time
they are modified.| Constructor and Description |
|---|
Draft(long draftID,
String areaID)
Creates a new Draft that points to a server-side Draft.
|
Draft(String areaID)
Creates a new local Draft.
|
| Modifier and Type | Method and Description |
|---|---|
Area |
area()
The area in which is post was published.
|
Optional<User> |
author()
The author of this post.
|
CacheManager |
cacheManager()
The Cache Manager that handles this object.
|
Stream<Comment> |
comments()
The comments on this post.
|
List<Comment> |
commentsList()
The comments on this post, as a List.
|
ZonedDateTime |
created()
The date and time at which this post was created, in the UTC timezone.
|
ZonedDateTime |
createdLocalTime()
The date and time at which this post was created, in the local timezone.
|
void |
delete()
Deletes this object, from both the server and the cache.
|
boolean |
equals(Object o) |
static CacheManager |
getCacheManager()
The cache manager that handles the Drafts.
|
int |
hashCode() |
boolean |
hasSubscribed()
Is the logged-in user subscribed to this post?
|
long |
ID()
The ID of this post.
|
boolean |
isActive()
Is this post active?
|
boolean |
isAnonymous()
Is this post anonymous?
|
boolean |
isAuthorDeleted()
Was the author of this post deleted?
|
Post |
publish()
Converts this Draft to a Post and publishes it.
|
Draft |
save()
Saves this Draft server-side.
|
Draft |
setIsAnonymous(boolean isAnonymous)
Make this object anonymous or not anonymous.
|
Draft |
setText(String newText)
Sets the text of this object.
|
Draft |
subscribe()
Subscribes the logged-in user to this post.
|
String |
text()
The text of this post, in MarkDown.
|
protected com.eclipsesource.json.JsonObject |
toJsonSimple()
Generates the JSON String needed by the server to understand this object.
|
String |
toString() |
Draft |
unsubscribe()
Unsubscribes the logged-in user from this post.
|
void |
update()
Updates this Descriptor.
|
isNew, isValid, isValid, usepublic Draft(String areaID)
The method Area.draft() is essentially the same as this constructor.
areaID - the area it will be in.public Draft(long draftID,
String areaID)
This method is for advanced-users only. If you want to create a Draft, use Draft(String) or
Area.draft().
draftID - the ID of the draftareaID - the ID of the area the draft is inpublic Post publish()
save().
This method will perform the API calls in the current thread.
public Draft save()
This method will perform the API calls in the current thread.
public void delete()
public CacheManager cacheManager()
DescriptorcacheManager in class Descriptorpublic static CacheManager getCacheManager()
public void update()
DescriptorThe update is always executed in the current thread.
update in class Descriptorpublic Draft setIsAnonymous(boolean isAnonymous)
isAnonymous - true to make this object anonymous, false to make it not-anonymous.public Draft subscribe()
public Draft unsubscribe()
public Draft setText(String newText)
newText - the new text of this object.public boolean isAnonymous()
Note that in the case where a not-anonymous post's author is deleted, the post is still not anonymous, but doesn't have an author either.
true if the post is anonymous.Get the author of this message.,
Was the author of this post deleted?public boolean hasSubscribed()
true if the logged-in user subscribed to this post.public boolean isAuthorDeleted()
This method is a simple helper rather than a getter for some server-provided data. It is a shortcut for:
!author().isPresent() && !isAnonymous();
true if the author of this post was deleted.Is this post anonymous?,
The author of this post.public ZonedDateTime created()
In the local timezonepublic ZonedDateTime createdLocalTime()
ZoneId.systemDefault(), if you are searching for an other timezone,
use created() and ZonedDateTime.withZoneSameInstant(ZoneId).In the UTC timezonepublic boolean isActive()
An active post is a post that continues to spread to new users.
true if this post is active.public String text()
public Optional<User> author()
There are two cases where there may not be an author: the author chose this post post to be anonymous, or the original author was deleted since this post's creation.
Is this post anonymous?,
Was the author of this post deleted?public Area area()
public long ID()
This API is crafted so that the end-user doesn't need to use IDs. This method is provided for the rare case where you need the ID for customized handling of the cache.
public List<Comment> commentsList()
The returned list is read-only and provided by Collections.unmodifiableList(List).
We recommend using Streamspublic Stream<Comment> comments()
Get the comments in a List.protected final com.eclipsesource.json.JsonObject toJsonSimple()