Record Class FileChecksum

java.lang.Object
java.lang.Record
dev.latvian.mods.klib.io.checksum.FileChecksum

public record FileChecksum(Checksum checksum, long size, Instant lastModified, boolean changed) extends Record
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<FileChecksum> CODEC
  • Constructor Details

    • FileChecksum

      public FileChecksum(Checksum checksum, long size, Instant lastModified, boolean changed)
      Creates an instance of a FileChecksum record class.
      Parameters:
      checksum - the value for the checksum record component
      size - the value for the size record component
      lastModified - the value for the lastModified record component
      changed - the value for the changed record component
  • Method Details

    • read

      public static FileChecksum read(ChecksumType<?> type, ByteInput data) throws IOException
      Throws:
      IOException
    • loadExisting

      @Nullable public static @Nullable FileChecksum loadExisting(ChecksumType<?> type, FileInfo fileInfo)
    • load

      public static FileChecksum load(ChecksumType<?> type, FileInfo fileInfo, @Nullable @Nullable LongConsumer progress) throws IOException
      Throws:
      IOException
    • save

      public static void save(ChecksumType<?> type, Path file, FileChecksum metadata) throws IOException
      Throws:
      IOException
    • loadChanged

      @Nullable public static @Nullable FileChecksum loadChanged(ChecksumType<?> type, FileInfo fileInfo, @Nullable @Nullable LongConsumer progress) throws IOException
      Throws:
      IOException
    • write

      public void write(ByteOutput data) throws IOException
      Throws:
      IOException
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • checksum

      public Checksum checksum()
      Returns the value of the checksum record component.
      Returns:
      the value of the checksum record component
    • size

      public long size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • lastModified

      public Instant lastModified()
      Returns the value of the lastModified record component.
      Returns:
      the value of the lastModified record component
    • changed

      public boolean changed()
      Returns the value of the changed record component.
      Returns:
      the value of the changed record component