Class Address

java.lang.Object
com.erudika.para.core.Address
All Implemented Interfaces:
Linkable, ParaObject, Votable, Serializable

public class Address extends Object implements ParaObject
This class represents an address. It enables location based search queries. It can be attached to any object by creating a Linker between the two.
Author:
Alex Bogdanovski [[email protected]]
See Also:
  • Constructor Details

    • Address

      public Address()
      No-args constructor. Same as Address(null)
    • Address

      public Address(String id)
      Default constructor.
      Parameters:
      id - the id
  • Method Details

    • getCity

      public String getCity()
      The name of the city. Optional.
      Returns:
      the city
    • setCity

      public void setCity(String city)
      Sets the city.
      Parameters:
      city - city name
    • getLatlng

      public String getLatlng()
      The Latitude and Longitude points of this address. Must not be null or empty.
      Returns:
      "lat,lng" as a string
    • setLatlng

      public void setLatlng(String latlng)
      Sets the coordinates in the form "LAT,LNG".
      Parameters:
      latlng - the coords
    • getPhone

      public String getPhone()
      The phone number. Multiple phones separated by comma are allowed.
      Returns:
      the phone number
    • setPhone

      public void setPhone(String phone)
      Sets a new phone number.
      Parameters:
      phone - the number as a string
    • getCountry

      public String getCountry()
      The country in which the address is located. Must not be null or empty.
      Returns:
      the full country name
    • setCountry

      public void setCountry(String country)
      Sets a new country name.
      Parameters:
      country - the name of the country
    • getAddress

      public String getAddress()
      The street address and other address info.
      Returns:
      the street address
    • setAddress

      public void setAddress(String address)
      Sets new street address. Must not be null or empty.
      Parameters:
      address - the address info
    • getId

      public final String getId()
      Returns the address ID.
      Specified by:
      getId in interface ParaObject
      Returns:
      the id
    • setId

      public final void setId(String id)
      Sets the address ID.
      Specified by:
      setId in interface ParaObject
      Parameters:
      id - the id
    • getType

      public final String getType()
      Returns the object type.
      Specified by:
      getType in interface ParaObject
      Returns:
      the type
    • setType

      public final void setType(String type)
      Sets the object type.
      Specified by:
      setType in interface ParaObject
      Parameters:
      type - the type
    • getAppid

      public String getAppid()
      Returns the app identifier.
      Specified by:
      getAppid in interface ParaObject
      Returns:
      the appid
    • setAppid

      public void setAppid(String appid)
      Sets the app identifier.
      Specified by:
      setAppid in interface ParaObject
      Parameters:
      appid - the appid
    • getObjectURI

      public String getObjectURI()
      Returns the object URI.
      Specified by:
      getObjectURI in interface ParaObject
      Returns:
      the URI
      See Also:
    • getTags

      public List<String> getTags()
      Returns the tags.
      Specified by:
      getTags in interface ParaObject
      Returns:
      the tags
      See Also:
    • getStored

      public Boolean getStored()
      Returns true if the object is stored in the database.
      Specified by:
      getStored in interface ParaObject
      Returns:
      true if stored
    • setStored

      public void setStored(Boolean stored)
      Sets the stored flag.
      Specified by:
      setStored in interface ParaObject
      Parameters:
      stored - the stored flag
    • getIndexed

      public Boolean getIndexed()
      Returns true if the object is indexed.
      Specified by:
      getIndexed in interface ParaObject
      Returns:
      true if indexed
    • setIndexed

      public void setIndexed(Boolean indexed)
      Sets the indexed flag.
      Specified by:
      setIndexed in interface ParaObject
      Parameters:
      indexed - the indexed flag
    • getCached

      public Boolean getCached()
      Returns true if the object is cached.
      Specified by:
      getCached in interface ParaObject
      Returns:
      true if cached
    • setCached

      public void setCached(Boolean cached)
      Sets the cached flag.
      Specified by:
      setCached in interface ParaObject
      Parameters:
      cached - the cached flag
    • setTags

      public void setTags(List<String> tags)
      Sets the tags.
      Specified by:
      setTags in interface ParaObject
      Parameters:
      tags - the tags
    • getTimestamp

      public Long getTimestamp()
      Returns the timestamp.
      Specified by:
      getTimestamp in interface ParaObject
      Returns:
      the timestamp
    • setTimestamp

      public void setTimestamp(Long timestamp)
      Sets the timestamp.
      Specified by:
      setTimestamp in interface ParaObject
      Parameters:
      timestamp - the timestamp
    • getCreatorid

      public String getCreatorid()
      Returns the creator ID.
      Specified by:
      getCreatorid in interface ParaObject
      Returns:
      the creatorid
    • setCreatorid

      public void setCreatorid(String creatorid)
      Sets the creator ID.
      Specified by:
      setCreatorid in interface ParaObject
      Parameters:
      creatorid - the creatorid
    • getName

      public final String getName()
      Returns the object name.
      Specified by:
      getName in interface ParaObject
      Returns:
      the name
    • setName

      public final void setName(String name)
      Sets the object name.
      Specified by:
      setName in interface ParaObject
      Parameters:
      name - the name
    • getPlural

      public String getPlural()
      Returns the plural form of the object type.
      Specified by:
      getPlural in interface ParaObject
      Returns:
      the plural name
    • getParentid

      public String getParentid()
      Returns the parent ID.
      Specified by:
      getParentid in interface ParaObject
      Returns:
      the parentid
    • setParentid

      public void setParentid(String parentid)
      Sets the parent ID.
      Specified by:
      setParentid in interface ParaObject
      Parameters:
      parentid - the parentid
    • getUpdated

      public Long getUpdated()
      Returns the updated timestamp.
      Specified by:
      getUpdated in interface ParaObject
      Returns:
      the updated timestamp
    • setUpdated

      public void setUpdated(Long updated)
      Sets the updated timestamp.
      Specified by:
      setUpdated in interface ParaObject
      Parameters:
      updated - the updated timestamp
    • create

      public String create()
      Persists the object to the database.
      Specified by:
      create in interface ParaObject
      Returns:
      the object ID
      See Also:
    • update

      public void update()
      Updates the object in the database.
      Specified by:
      update in interface ParaObject
      See Also:
    • delete

      public void delete()
      Deletes the object from the database.
      Specified by:
      delete in interface ParaObject
      See Also:
    • exists

      public boolean exists()
      Returns true if the object exists in the database.
      Specified by:
      exists in interface ParaObject
      Returns:
      true if exists
      See Also:
    • voteUp

      public boolean voteUp(String userid)
      Votes up for the object.
      Specified by:
      voteUp in interface Votable
      Parameters:
      userid - the voter ID
      Returns:
      true if successful
    • voteDown

      public boolean voteDown(String userid)
      Votes down for the object.
      Specified by:
      voteDown in interface Votable
      Parameters:
      userid - the voter ID
      Returns:
      true if successful
    • getVotes

      public Integer getVotes()
      Returns the number of votes.
      Specified by:
      getVotes in interface Votable
      Returns:
      the votes
    • setVotes

      public void setVotes(Integer votes)
      Sets the number of votes.
      Specified by:
      setVotes in interface Votable
      Parameters:
      votes - the votes
    • getVersion

      public Long getVersion()
      Returns the version of the object.
      Specified by:
      getVersion in interface ParaObject
      Returns:
      the version
    • setVersion

      public void setVersion(Long version)
      Sets the version of the object.
      Specified by:
      setVersion in interface ParaObject
      Parameters:
      version - the version
    • countLinks

      public Long countLinks(String type2)
      Counts the number of links to other objects of a certain type.
      Specified by:
      countLinks in interface Linkable
      Parameters:
      type2 - the other type
      Returns:
      the number of links
    • getLinks

      public List<Linker> getLinks(String type2, Pager... pager)
      Returns a list of links to other objects of a certain type.
      Specified by:
      getLinks in interface Linkable
      Parameters:
      type2 - the other type
      pager - a pager
      Returns:
      a list of links
    • getLinkedObjects

      public <P extends ParaObject> List<P> getLinkedObjects(String type, Pager... pager)
      Returns a list of linked objects of a certain type.
      Specified by:
      getLinkedObjects in interface Linkable
      Type Parameters:
      P - the type of linked objects
      Parameters:
      type - the other type
      pager - a pager
      Returns:
      a list of linked objects
    • findLinkedObjects

      public <P extends ParaObject> List<P> findLinkedObjects(String type, String field, String query, Pager... pager)
      Finds linked objects of a certain type that match a specific field and query.
      Specified by:
      findLinkedObjects in interface Linkable
      Type Parameters:
      P - the type of linked objects
      Parameters:
      type - the other type
      field - the field to search in
      query - the search query
      pager - a pager
      Returns:
      a list of linked objects
    • isLinked

      public boolean isLinked(String type2, String id2)
      Returns true if the object is linked to another object of a certain type and ID.
      Specified by:
      isLinked in interface Linkable
      Parameters:
      type2 - the other type
      id2 - the other ID
      Returns:
      true if linked
    • isLinked

      public boolean isLinked(ParaObject toObj)
      Returns true if the object is linked to another object.
      Specified by:
      isLinked in interface Linkable
      Parameters:
      toObj - the other object
      Returns:
      true if linked
    • link

      public String link(String id2)
      Links the object to another object of a certain type and ID.
      Specified by:
      link in interface Linkable
      Parameters:
      id2 - the other ID
      Returns:
      the link ID
    • unlink

      public void unlink(String type, String id2)
      Unlinks the object from another object of a certain type and ID.
      Specified by:
      unlink in interface Linkable
      Parameters:
      type - the other type
      id2 - the other ID
    • unlinkAll

      public void unlinkAll()
      Unlinks the object from all other objects.
      Specified by:
      unlinkAll in interface Linkable
    • countChildren

      public Long countChildren(String type)
      Counts the number of children of a certain type.
      Specified by:
      countChildren in interface Linkable
      Parameters:
      type - the child type
      Returns:
      the number of children
    • getChildren

      public <P extends ParaObject> List<P> getChildren(String type, Pager... pager)
      Returns a list of children of a certain type.
      Specified by:
      getChildren in interface Linkable
      Type Parameters:
      P - the type of children
      Parameters:
      type - the child type
      pager - a pager
      Returns:
      a list of children
    • getChildren

      public <P extends ParaObject> List<P> getChildren(String type, String field, String term, Pager... pager)
      Returns a list of children of a certain type that match a specific field and term.
      Specified by:
      getChildren in interface Linkable
      Type Parameters:
      P - the type of children
      Parameters:
      type - the child type
      field - the field to search in
      term - the search term
      pager - a pager
      Returns:
      a list of children
    • findChildren

      public <P extends ParaObject> List<P> findChildren(String type, String query, Pager... pager)
      Finds children of a certain type that match a specific query.
      Specified by:
      findChildren in interface Linkable
      Type Parameters:
      P - the type of children
      Parameters:
      type - the child type
      query - the search query
      pager - a pager
      Returns:
      a list of children
    • deleteChildren

      public void deleteChildren(String type)
      Deletes all children of a certain type.
      Specified by:
      deleteChildren in interface Linkable
      Parameters:
      type - the child type
    • hashCode

      public int hashCode()
      Returns the hash code for this object.
      Overrides:
      hashCode in class Object
      Returns:
      hash code
    • equals

      public boolean equals(Object obj)
      Returns true if this object is equal to another.
      Overrides:
      equals in class Object
      Parameters:
      obj - the other object
      Returns:
      true if equal
    • toString

      public String toString()
      Returns a JSON string representation of this object.
      Overrides:
      toString in class Object
      Returns:
      JSON string