-
- All Superinterfaces:
Linkable,Serializable,Votable
- All Known Implementing Classes:
Address,App,Linker,Sysprop,Tag,Translation,User,Vote,Webhook
public interface ParaObject extends Serializable, Linkable, Votable
The core domain interface. All Para objects implement it.- Author:
- Alex Bogdanovski [alex@erudika.com]
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.erudika.para.core.Votable
Votable.VoteValue
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Stringcreate()Stores this object in the data store.voiddelete()Deletes the object permanently by removing it from the data store.booleanexists()Checks if an object is stored in the data store.StringgetAppid()The application name.BooleangetCached()Boolean flag which controls whether this object is cached.StringgetCreatorid()The id of the user who created this.StringgetId()The id of an object.BooleangetIndexed()Boolean flag which controls whether this object is indexed by the search engine.@NotBlank @Size(min=1,max=255) StringgetName()The name of the object.StringgetObjectURI()The URI of this object.StringgetParentid()The id of the parent object.StringgetPlural()The plural name of the object.BooleangetStored()Boolean flag which controls whether this object is stored in the database or not.List<String>getTags()The tags associated with this object.LonggetTimestamp()The time when the object was created, in milliseconds.StringgetType()The name of the object's class.LonggetUpdated()The last time this object was updated.LonggetVersion()Returns the version number for this object.voidsetAppid(String appid)Sets a new app name.voidsetCached(Boolean isCached)Sets the "isCached" flag.voidsetCreatorid(String creatorid)Sets a new creator id.voidsetId(String id)Sets a new id.voidsetIndexed(Boolean isIndexed)Sets the "isIndexed" flag.voidsetName(String name)Sets a new name.voidsetParentid(String parentid)Sets a new parent id.voidsetStored(Boolean isStored)Sets the "isStored" flag.voidsetTags(List<String> tags)Merges the given tags with existing tags.voidsetTimestamp(Long timestamp)Sets the timestamp.voidsetType(String type)Sets a new object type.voidsetUpdated(Long updated)Sets the last updated timestamp.voidsetVersion(Long version)Sets the version of this object.voidupdate()Updates the object permanently.-
Methods inherited from interface com.erudika.para.core.Linkable
countChildren, countLinks, deleteChildren, findChildren, findLinkedObjects, getChildren, getChildren, getLinkedObjects, getLinks, isLinked, isLinked, link, unlink, unlinkAll
-
-
-
-
Method Detail
-
getId
String getId()
The id of an object. Usually an autogenerated unique string of numbers.- Returns:
- the id
-
setId
void setId(String id)
Sets a new id. Must not be null or empty.- Parameters:
id- the new id
-
getName
@NotBlank @Size(min=1, max=255) @NotBlank @Size(min=1,max=255) String getName()The name of the object. Can be anything.- Returns:
- the name. default: [type id]
-
setName
void setName(String name)
Sets a new name. Must not be null or empty.- Parameters:
name- the new name
-
getAppid
String getAppid()
The application name. Added to support multiple separate apps. Every object must belong to an app.- Returns:
- the app id (name). default: para
-
setAppid
void setAppid(String appid)
Sets a new app name. Must not be null or empty.- Parameters:
appid- the new app id (name)
-
getParentid
String getParentid()
The id of the parent object.- Returns:
- the id of the parent or null
-
setParentid
void setParentid(String parentid)
Sets a new parent id. Must not be null or empty.- Parameters:
parentid- a new id
-
getType
String getType()
The name of the object's class. This is equivalent toClass.getSimpleName().toLowerCase()- Returns:
- the simple name of the class
-
setType
void setType(String type)
Sets a new object type. Must not be null or empty.- Parameters:
type- a new type
-
getCreatorid
String getCreatorid()
The id of the user who created this. Should point to aUserid.- Returns:
- the id or null
-
setCreatorid
void setCreatorid(String creatorid)
Sets a new creator id. Must not be null or empty.- Parameters:
creatorid- a new id
-
getPlural
String getPlural()
The plural name of the object. For example: user - users- Returns:
- the plural name
-
getObjectURI
String getObjectURI()
The URI of this object. For example: /users/123- Returns:
- the URI
- See Also:
Utils.getObjectURI(com.erudika.para.core.ParaObject, boolean, boolean)
-
getTimestamp
Long getTimestamp()
The time when the object was created, in milliseconds.- Returns:
- the timestamp of creation
-
setTimestamp
void setTimestamp(Long timestamp)
Sets the timestamp.- Parameters:
timestamp- a new timestamp in milliseconds.
-
getUpdated
Long getUpdated()
The last time this object was updated. Timestamp in ms.- Returns:
- timestamp in milliseconds
-
setUpdated
void setUpdated(Long updated)
Sets the last updated timestamp.- Parameters:
updated- a new timestamp
-
getTags
List<String> getTags()
The tags associated with this object. Tags must not be null or empty.- Returns:
- a set of tags, or an empty set
- See Also:
Tag
-
setTags
void setTags(List<String> tags)
Merges the given tags with existing tags.- Parameters:
tags- the additional tags, or clears all tags if set to null
-
getStored
Boolean getStored()
Boolean flag which controls whether this object is stored in the database or not. Default is true.- Returns:
- true if this object is stored in DB.
-
setStored
void setStored(Boolean isStored)
Sets the "isStored" flag.- Parameters:
isStored- when set to true, object is stored in DB.
-
getIndexed
Boolean getIndexed()
Boolean flag which controls whether this object is indexed by the search engine. Default is true.- Returns:
- true if this object is indexed
-
setIndexed
void setIndexed(Boolean isIndexed)
Sets the "isIndexed" flag.- Parameters:
isIndexed- when set to true, object is indexed.
-
getCached
Boolean getCached()
Boolean flag which controls whether this object is cached. Default is true.- Returns:
- true if this object is cached on update() and create().
-
setCached
void setCached(Boolean isCached)
Sets the "isCached" flag.- Parameters:
isCached- when set to true, object is cached.
-
getVersion
Long getVersion()
Returns the version number for this object. Used primarily for optimistic locking.- Returns:
- a positive number,
0if unused or-1, indicating a failed update.
-
setVersion
void setVersion(Long version)
Sets the version of this object. This value should come from the database.- Parameters:
version- a positive number, different than the current value of the version field
-
create
String create()
Stores this object in the data store.- Returns:
- the id of the object (a new id if object is new)
- See Also:
Stored,DAO.create(com.erudika.para.core.ParaObject)
-
update
void update()
Updates the object permanently. Changes toLockedfields are ignored.
-
delete
void delete()
Deletes the object permanently by removing it from the data store.
-
exists
boolean exists()
Checks if an object is stored in the data store.- Returns:
- true if the object is persisted to the data store.
- See Also:
DAO.read(java.lang.String)
-
-