Class JWFileItem

java.lang.Object
com.io7m.jwheatsheaf.ui.internal.JWFileItem
All Implemented Interfaces:
JWFileItemType

public final class JWFileItem extends Object implements JWFileItemType
A resolved file item.
  • Method Details

    • kind

      public JWFileKind kind()
      Specified by:
      kind in interface JWFileItemType
      Returns:
      The file kind
    • path

      public Path path()
      Specified by:
      path in interface JWFileItemType
      Returns:
      The file path
    • size

      public long size()
      Specified by:
      size in interface JWFileItemType
      Returns:
      The file size
    • modifiedTime

      public FileTime modifiedTime()
      Specified by:
      modifiedTime in interface JWFileItemType
      Returns:
      The file modification time
    • displayName

      public Optional<String> displayName()
      Specified by:
      displayName in interface JWFileItemType
      Returns:
      The file display name override, if any
    • withKind

      public final JWFileItem withKind(JWFileKind value)
      Copy the current immutable object by setting a value for the kind attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for kind
      Returns:
      A modified copy of the this object
    • withPath

      public final JWFileItem withPath(Path value)
      Copy the current immutable object by setting a value for the path attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for path
      Returns:
      A modified copy of the this object
    • withSize

      public final JWFileItem withSize(long value)
      Copy the current immutable object by setting a value for the size attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for size
      Returns:
      A modified copy of the this object
    • withModifiedTime

      public final JWFileItem withModifiedTime(FileTime value)
      Copy the current immutable object by setting a value for the modifiedTime attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for modifiedTime
      Returns:
      A modified copy of the this object
    • withDisplayName

      public final JWFileItem withDisplayName(String value)
      Copy the current immutable object by setting a present value for the optional displayName attribute.
      Parameters:
      value - The value for displayName
      Returns:
      A modified copy of this object
    • withDisplayName

      public final JWFileItem withDisplayName(Optional<String> optional)
      Copy the current immutable object by setting an optional value for the displayName attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for displayName
      Returns:
      A modified copy of this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of JWFileItem that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: kind, path, size, modifiedTime, displayName.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value JWFileItem with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static JWFileItem copyOf(JWFileItemType instance)
      Creates an immutable copy of a JWFileItemType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable JWFileItem instance
    • builder

      public static JWFileItem.Builder builder()
      Creates a builder for JWFileItem.
       JWFileItem.builder()
          .setKind(com.io7m.jwheatsheaf.api.JWFileKind) // required kind
          .setPath(java.nio.file.Path) // required path
          .setSize(long) // required size
          .setModifiedTime(java.nio.file.attribute.FileTime) // required modifiedTime
          .setDisplayName(String) // optional displayName
          .build();
       
      Returns:
      A new JWFileItem builder