java.lang.Object
us.teaminceptus.novaconomy.api.business.Rating
All Implemented Interfaces:
Comparable<Rating>, ConfigurationSerializable

public final class Rating extends Object implements ConfigurationSerializable, Comparable<Rating>
Represents a Business Rating
  • Constructor Details

    • Rating

      public Rating(@NotNull @NotNull OfflinePlayer owner, @NotNull @NotNull UUID businessId, int level, long timestamp, String comment) throws IllegalArgumentException
      Constructs a Rating.
      Parameters:
      owner - Owner of the Rating
      businessId - ID of the Business that the Rating is for
      level - Level of the Rating
      timestamp - Timestamp of the Rating
      comment - Optional Comment on the rating
      Throws:
      IllegalArgumentException - if owner / business is null
    • Rating

      public Rating(@NotNull @NotNull OfflinePlayer owner, @NotNull @NotNull Business business, int level, long timestamp, String comment) throws IllegalArgumentException
      Constructs a Rating.
      Parameters:
      owner - Owner of the Rating
      business - Business that the Rating is for
      level - Level of the Rating
      timestamp - Timestamp of the Rating
      comment - Optional comment on the Rating
      Throws:
      IllegalArgumentException - if owner / business is null, or level is negative / greater than 5
    • Rating

      public Rating(@NotNull @NotNull OfflinePlayer owner, @NotNull @NotNull UUID businessId, int level, long timestamp) throws IllegalArgumentException
      Constructs a Rating.
      Parameters:
      owner - Owner of the Rating
      businessId - ID of the Business that the Rating is for
      level - Level of the Rating
      timestamp - Timestamp of the Rating
      Throws:
      IllegalArgumentException - if owner / business is null, or level is negative / greater than 5
    • Rating

      public Rating(@NotNull @NotNull OfflinePlayer owner, @NotNull @NotNull Business business, int level, long timestamp) throws IllegalArgumentException
      Constructs a Rating.
      Parameters:
      owner - Owner of the Rating
      business - Business that the Rating is for
      level - Level of the Rating
      timestamp - Timestamp of the Rating
      Throws:
      IllegalArgumentException - if owner / business is null, or level is negative / greater than 5
  • Method Details

    • getOwner

      @NotNull public @NotNull OfflinePlayer getOwner()
      Fetches the owner of this Rating.
      Returns:
      Owner of the Rating
    • isOwner

      public boolean isOwner(@Nullable @Nullable OfflinePlayer p)
      Whether this Player is the owner of this rating.
      Parameters:
      p - Player to check
      Returns:
      true if player is owner, else false
    • getBusinessId

      @NotNull public @NotNull UUID getBusinessId()
      Fetches the Business ID that this Rating is for.
      Returns:
      Business that this rating is targeting
    • getRatingLevel

      public int getRatingLevel()
      Fetches the rating level that this Rating is at.
      Returns:
      Rating level
    • getComment

      @NotNull public @NotNull String getComment()
      Fetches the comment on this Rating.
      Returns:
      Comment on the Rating, may be empty
    • getTimestamp

      public Date getTimestamp()
      Fetches the timestamp of this rating.
      Returns:
      Timestamp of the Rating
    • compareTo

      public int compareTo(@NotNull @NotNull Rating r)
      Specified by:
      compareTo in interface Comparable<Rating>
    • serialize

      public Map<String,Object> serialize()
      Specified by:
      serialize in interface ConfigurationSerializable
    • deserialize

      public static Rating deserialize(@NotNull @NotNull Map<String,Object> serial) throws IllegalArgumentException
      Deserializes a Map into a Rating.
      Parameters:
      serial - Serialization from serialize()
      Returns:
      Deserialized Rating, or null if serial is null
      Throws:
      IllegalArgumentException - if an argument is missing/malformed