Class JWFileItem

  • All Implemented Interfaces:
    JWFileItemType

    public final class JWFileItem
    extends java.lang.Object
    implements JWFileItemType
    A resolved file item.
    • Method Detail

      • path

        public java.nio.file.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 java.nio.file.attribute.FileTime modifiedTime()
        Specified by:
        modifiedTime in interface JWFileItemType
        Returns:
        The file modification time
      • displayName

        public java.util.Optional<java.lang.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​(java.nio.file.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​(java.nio.file.attribute.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​(java.lang.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​(java.util.Optional<java.lang.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​(java.lang.Object another)
        This instance is equal to all instances of JWFileItem that have equal attribute values.
        Overrides:
        equals in class java.lang.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 java.lang.Object
        Returns:
        hashCode value
      • toString

        public java.lang.String toString()
        Prints the immutable value JWFileItem with attribute values.
        Overrides:
        toString in class java.lang.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