Record Class MuteEntry

java.lang.Object
java.lang.Record
me.github.simonplays15.betterbansystem.core.mute.MuteEntry
All Implemented Interfaces:
IMuteEntry

public record MuteEntry(UUID uuid, String name, String source, Date created, Object expires, String reason) extends Record implements IMuteEntry
Represents a mute entry for a player. Implements the IMuteEntry interface.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    The IMuteEntryAdapter class is a Gson TypeAdapter for serializing and deserializing IMuteEntry objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MuteEntry (UUID uuid, String name, String source, Date created, Object expires, String reason)
    Creates a mute entry if the file does not exist.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the created record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the expires record component.
    static IMuteEntry
    findEntry (UUID targetUUID)
    Finds an entry in the list of mute entries with the specified target UUID.
    static @NotNull List<IMuteEntry>
    Retrieves a list of all mute entries.
    final int
    Returns a hash code value for this object.
    name()
    Returns the value of the name record component.
    Returns the value of the reason record component.
    static void
    removeEntry (@NotNull IMuteEntry entry)
    Removes an entry from the system.
    static void
    removeFromJson (UUID targetUUID)
    Removes a mute entry with the given UUID from a JSON file or database.
    static void
    Saves an IMuteEntry object to JSON.
    Returns the value of the source record component.
    Returns a string representation of the mute entry.
    uuid()
    Returns the value of the uuid record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MuteEntry

      public MuteEntry (UUID uuid, String name, String source, Date created, Object expires, String reason)
      Creates a mute entry if the file does not exist.
      Parameters:
      file - The file to be checked and created if necessary.
      Throws:
      IOException - If an I/O error occurs.
  • Method Details

    • saveToJson

      public static void saveToJson (IMuteEntry entry)
      Saves an IMuteEntry object to JSON.
      Parameters:
      entry - The IMuteEntry object to save.
    • removeEntry

      public static void removeEntry (@NotNull @NotNull IMuteEntry entry)
      Removes an entry from the system.
      Parameters:
      entry - The entry to be removed.
      Throws:
      NullPointerException - if the entry is null.
    • removeFromJson

      public static void removeFromJson (UUID targetUUID)
      Removes a mute entry with the given UUID from a JSON file or database.
      Parameters:
      targetUUID - The UUID of the mute entry to be removed.
    • getAllEntries

      @NotNull public static @NotNull List<IMuteEntry> getAllEntries()
      Retrieves a list of all mute entries.
      Returns:
      A list of all mute entries, represented as IMuteEntry. If no entries are found, an empty list is returned.
      Throws:
      IOException - if there is an error reading the mute entries from the file
    • findEntry

      public static IMuteEntry findEntry (UUID targetUUID)
      Finds an entry in the list of mute entries with the specified target UUID.
      Parameters:
      targetUUID - The UUID of the target entry.
      Returns:
      The first mute entry with the specified UUID, or null if no such entry is found.
    • toString

      public String toString()
      Returns a string representation of the mute entry.
      Specified by:
      toString in class Record
      Returns:
      A string representation of the mute entry.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals (Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • uuid

      public UUID uuid()
      Returns the value of the uuid record component.
      Specified by:
      uuid in interface IMuteEntry
      Returns:
      the value of the uuid record component
    • name

      public String name()
      Returns the value of the name record component.
      Specified by:
      name in interface IMuteEntry
      Returns:
      the value of the name record component
    • source

      public String source()
      Returns the value of the source record component.
      Specified by:
      source in interface IMuteEntry
      Returns:
      the value of the source record component
    • created

      public Date created()
      Returns the value of the created record component.
      Specified by:
      created in interface IMuteEntry
      Returns:
      the value of the created record component
    • expires

      public Object expires()
      Returns the value of the expires record component.
      Specified by:
      expires in interface IMuteEntry
      Returns:
      the value of the expires record component
    • reason

      public String reason()
      Returns the value of the reason record component.
      Specified by:
      reason in interface IMuteEntry
      Returns:
      the value of the reason record component