org.klomp.snark.comments

## Class Comment

- java.lang.Object
- - org.klomp.snark.comments.Comment

- All Implemented Interfaces:
    Comparable<Comment>

      public class Comment
      extends Object
      implements Comparable<Comment>

  Store a single comment and/or rating. Unmodifiable except for marking as hidden. Stores a one-second timestamp but designed so identical comments within a certain time frame (bucket) are equal. Don't store in a plain set - see equals().

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MAX_NAME_LEN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Comment(String text, String name, int rating)` My comment, now
    `Comment(String text, String name, int rating, long time, boolean isMine)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(Comment c)` reverse
    `boolean` | `equals(Object o)` Comments within 10 minutes (not necessarily in same bucket) and otherwise equal are considered equal.
    `boolean` | `equalsIgnoreTimestamp(Comment c)` Ignores timestamp
    `static Comment` | `fromPersistentString(String s)`
    `int` | `getID()` A unique ID that may be used to delete this comment from the CommentSet via remove(int).
    `String` | `getName()`
    `int` | `getRating()`
    `String` | `getText()`
    `long` | `getTime()` java time (ms)
    `int` | `hashCode()`
    `boolean` | `isHidden()`
    `boolean` | `isMine()`
    `(package private) void` | `setHidden()`
    `String` | `toPersistentString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MAX_NAME_LEN

          public static final int MAX_NAME_LEN

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Comment

          public Comment(String text,
                         String name,
                         int rating)

      My comment, now
      Parameters:
        `text` - may be null, will be truncated to max length, newlines replaced with spaces
        `name` - may be null, will be truncated to max length, newlines and commas removed
        `rating` - 0-5

    - #### Comment

          public Comment(String text,
                         String name,
                         int rating,
                         long time,
                         boolean isMine)

      Parameters:
        `text` - may be null, will be truncated to max length, newlines replaced with spaces
        `name` - may be null, will be truncated to max length, newlines and commas removed
        `time` - java time (ms)
        `rating` - 0-5

  - ### Method Detail

    - #### compareTo

          public int compareTo(Comment c)

      reverse
      Specified by:
        `compareTo` in interface `Comparable<Comment>`

    - #### equals

          public boolean equals(Object o)

      Comments within 10 minutes (not necessarily in same bucket) and otherwise equal are considered equal. Violates contract, as equal objects may have different hashcodes and be in adjacent buckets.
      Overrides:
        `equals` in class `Object`

    - #### equalsIgnoreTimestamp

          public boolean equalsIgnoreTimestamp(Comment c)

      Ignores timestamp
      Parameters:
        `c` - non-null

    - #### fromPersistentString

          public static Comment fromPersistentString(String s)

      Returns:
        null if can't be parsed

    - #### getID

          public int getID()

      A unique ID that may be used to delete this comment from the CommentSet via remove(int). NOT persisted across restarts.

    - #### getName

          public String getName()

    - #### getRating

          public int getRating()

    - #### getText

          public String getText()

    - #### getTime

          public long getTime()

      java time (ms)

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`
      Returns:
        bucket number

    - #### isHidden

          public boolean isHidden()

    - #### isMine

          public boolean isMine()

    - #### setHidden

          void setHidden()

    - #### toPersistentString

          public String toPersistentString()

      Returns:
        time,rating,mine,hidden,name,text