Class Vote
java.lang.Object
com.erudika.para.core.Vote
- All Implemented Interfaces:
Linkable, ParaObject, Votable, Serializable
When a user votes on an object the vote is saved as positive or negative.
The user has a short amount of time to amend that vote and then it's locked.
Votes can expire after X seconds and they get deleted.
This allows the voter to vote again on the same object.
- Author:
- Alex Bogdanovski [[email protected]]
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Votable
Votable.VoteValue -
Constructor Summary
ConstructorsConstructorDescriptionVote()No-args constructor.Vote(String voterid, String voteeid, Votable.VoteValue value) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptioncountChildren(String type) Counts children (always 0).countLinks(String type2) Counts links (always 0).create()Persists the object to the database.voiddelete()Deletes the object from the database.voiddeleteChildren(String type) Deletes children (noop).down()Set the vote negative.booleanCompares objects for equality.booleanexists()Returns true if the object exists in the database.<P extends ParaObject>
List<P> findChildren(String type, String query, Pager... pager) Finds children (empty list).<P extends ParaObject>
List<P> findLinkedObjects(String type, String field, String query, Pager... pager) Finds linked objects (empty list).getAppid()Returns the app identifier.Returns true if the object is cached.<P extends ParaObject>
List<P> getChildren(String type, Pager... pager) Returns children (empty list).<P extends ParaObject>
List<P> getChildren(String type, String field, String term, Pager... pager) Returns children (empty list).Returns the creator ID.Returns the expiration period.final StringgetId()The id of an object.Returns true if the object is indexed.<P extends ParaObject>
List<P> getLinkedObjects(String type, Pager... pager) Returns linked objects (empty list).Returns links (empty list).The period during which a vote can be amended.final StringgetName()Returns the object name.Returns the object URI.Returns the parent ID.Returns the plural form of the object type.Returns true if the object is stored in the database.getTags()Returns the tags.Returns the timestamp.final StringgetType()Returns the object type.Returns the updated timestamp.getValue()Returns the value of the vote.Returns the version of the object.getVotes()Returns the number of votes (always 0).inthashCode()Returns hash code.booleanChecks if vote can still be amended.booleanReturns true if the vote is negative.booleanChecks if expired.booleanisLinked(ParaObject toObj) Is linked (always false).booleanIs linked (always false).booleanisUpvote()Returns true if the vote is positive.Links (noop).voidSets the app identifier.voidSets the cached flag.voidsetCreatorid(String creatorid) Sets the creator ID.voidsetExpiresAfter(Integer expiresAfter) Sets the expiration period.final voidSets the object ID.voidsetIndexed(Boolean indexed) Sets the indexed flag.voidsetLockedAfter(Integer lockedAfter) Sets the lock after period.final voidSets the object name.voidsetParentid(String parentid) Sets the parent ID.voidSets the stored flag.voidSets the tags (noop).voidsetTimestamp(Long timestamp) Sets the timestamp.final voidSets the object type.voidsetUpdated(Long updated) Sets the updated timestamp.voidSets the value of the vote.voidsetVersion(Long version) Sets the version of the object.voidSets the number of votes (noop).toString()Returns JSON string.voidUnlinks (noop).voidUnlinks all (noop).up()Set the vote positive.voidupdate()Updates the object in the database.booleanVotes down (noop).booleanVotes up (noop).
-
Constructor Details
-
Vote
public Vote()No-args constructor. -
Vote
Default constructor.- Parameters:
voterid- the user id of the votervoteeid- the id of the object that will receive the votevalue- up + or down -
-
-
Method Details
-
getId
Description copied from interface:ParaObjectThe id of an object. Usually an autogenerated unique string of numbers.- Specified by:
getIdin interfaceParaObject- Returns:
- the id
-
up
-
down
-
isUpvote
public boolean isUpvote()Returns true if the vote is positive.- Returns:
- true if vote is positive
-
isDownvote
public boolean isDownvote()Returns true if the vote is negative.- Returns:
- true if vote is negative
-
getValue
-
setValue
-
getExpiresAfter
-
setExpiresAfter
Sets the expiration period.- Parameters:
expiresAfter- time in seconds
-
getLockedAfter
The period during which a vote can be amended.- Returns:
- lock after period in seconds
-
setLockedAfter
Sets the lock after period.- Parameters:
lockedAfter- time in seconds
-
isExpired
public boolean isExpired()Checks if expired.- Returns:
- true if expired
-
isAmendable
public boolean isAmendable()Checks if vote can still be amended.- Returns:
- true if vote can still be changed
-
setId
Sets the object ID.- Specified by:
setIdin interfaceParaObject- Parameters:
id- the id
-
getType
Returns the object type.- Specified by:
getTypein interfaceParaObject- Returns:
- the type
-
setType
Sets the object type.- Specified by:
setTypein interfaceParaObject- Parameters:
type- the type
-
getAppid
Returns the app identifier.- Specified by:
getAppidin interfaceParaObject- Returns:
- the appid
-
setAppid
Sets the app identifier.- Specified by:
setAppidin interfaceParaObject- Parameters:
appid- the appid
-
getObjectURI
Returns the object URI.- Specified by:
getObjectURIin interfaceParaObject- Returns:
- the URI
- See Also:
-
getTags
Returns the tags.- Specified by:
getTagsin interfaceParaObject- Returns:
- empty list
- See Also:
-
setTags
Sets the tags (noop).- Specified by:
setTagsin interfaceParaObject- Parameters:
tags- tags
-
getStored
Returns true if the object is stored in the database.- Specified by:
getStoredin interfaceParaObject- Returns:
- true if stored
-
setStored
Sets the stored flag.- Specified by:
setStoredin interfaceParaObject- Parameters:
stored- stored flag
-
getIndexed
Returns true if the object is indexed.- Specified by:
getIndexedin interfaceParaObject- Returns:
- true if indexed
-
setIndexed
Sets the indexed flag.- Specified by:
setIndexedin interfaceParaObject- Parameters:
indexed- indexed flag
-
getCached
Returns true if the object is cached.- Specified by:
getCachedin interfaceParaObject- Returns:
- true if cached
-
setCached
Sets the cached flag.- Specified by:
setCachedin interfaceParaObject- Parameters:
cached- cached flag
-
getTimestamp
Returns the timestamp.- Specified by:
getTimestampin interfaceParaObject- Returns:
- the timestamp
-
setTimestamp
Sets the timestamp.- Specified by:
setTimestampin interfaceParaObject- Parameters:
timestamp- timestamp
-
getCreatorid
Returns the creator ID.- Specified by:
getCreatoridin interfaceParaObject- Returns:
- creatorid
-
setCreatorid
Sets the creator ID.- Specified by:
setCreatoridin interfaceParaObject- Parameters:
creatorid- creatorid
-
getName
Returns the object name.- Specified by:
getNamein interfaceParaObject- Returns:
- the name
-
setName
Sets the object name.- Specified by:
setNamein interfaceParaObject- Parameters:
name- name
-
getPlural
Returns the plural form of the object type.- Specified by:
getPluralin interfaceParaObject- Returns:
- plural name
-
getParentid
Returns the parent ID.- Specified by:
getParentidin interfaceParaObject- Returns:
- parentid
-
setParentid
Sets the parent ID.- Specified by:
setParentidin interfaceParaObject- Parameters:
parentid- parentid
-
getUpdated
Returns the updated timestamp.- Specified by:
getUpdatedin interfaceParaObject- Returns:
- updated timestamp
-
setUpdated
Sets the updated timestamp.- Specified by:
setUpdatedin interfaceParaObject- Parameters:
updated- updated timestamp
-
create
Persists the object to the database.- Specified by:
createin interfaceParaObject- Returns:
- the object ID
- See Also:
-
update
public void update()Updates the object in the database.- Specified by:
updatein interfaceParaObject- See Also:
-
delete
public void delete()Deletes the object from the database.- Specified by:
deletein interfaceParaObject- See Also:
-
exists
public boolean exists()Returns true if the object exists in the database.- Specified by:
existsin interfaceParaObject- Returns:
- true if exists
- See Also:
-
voteUp
-
voteDown
-
getVotes
-
setVotes
-
getVersion
Returns the version of the object.- Specified by:
getVersionin interfaceParaObject- Returns:
- the version
-
setVersion
Sets the version of the object.- Specified by:
setVersionin interfaceParaObject- Parameters:
version- version
-
countLinks
Counts links (always 0).- Specified by:
countLinksin interfaceLinkable- Parameters:
type2- other type- Returns:
- 0
-
getLinks
-
getLinkedObjects
Returns linked objects (empty list).- Specified by:
getLinkedObjectsin interfaceLinkable- Type Parameters:
P- type- Parameters:
type- typepager- pager- Returns:
- empty list
-
findLinkedObjects
public <P extends ParaObject> List<P> findLinkedObjects(String type, String field, String query, Pager... pager) Finds linked objects (empty list).- Specified by:
findLinkedObjectsin interfaceLinkable- Type Parameters:
P- type- Parameters:
type- typefield- fieldquery- querypager- pager- Returns:
- empty list
-
isLinked
-
isLinked
Is linked (always false). -
link
-
unlink
-
unlinkAll
-
countChildren
Counts children (always 0).- Specified by:
countChildrenin interfaceLinkable- Parameters:
type- child type- Returns:
- 0
-
getChildren
Returns children (empty list).- Specified by:
getChildrenin interfaceLinkable- Type Parameters:
P- type- Parameters:
type- typepager- pager- Returns:
- empty list
-
getChildren
public <P extends ParaObject> List<P> getChildren(String type, String field, String term, Pager... pager) Returns children (empty list).- Specified by:
getChildrenin interfaceLinkable- Type Parameters:
P- type- Parameters:
type- typefield- fieldterm- termpager- pager- Returns:
- empty list
-
findChildren
Finds children (empty list).- Specified by:
findChildrenin interfaceLinkable- Type Parameters:
P- type- Parameters:
type- typequery- querypager- pager- Returns:
- empty list
-
deleteChildren
Deletes children (noop).- Specified by:
deleteChildrenin interfaceLinkable- Parameters:
type- child type
-
hashCode
-
equals
-
toString
-