Package com.io7m.jwheatsheaf.ui.internal
Class JWFileItem
- java.lang.Object
-
- com.io7m.jwheatsheaf.ui.internal.JWFileItem
-
- All Implemented Interfaces:
JWFileItemType
public final class JWFileItem extends java.lang.Object implements JWFileItemType
A resolved file item.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJWFileItem.BuilderBuilds instances of typeJWFileItem.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JWFileItem.Builderbuilder()Creates a builder forJWFileItem.static JWFileItemcopyOf(JWFileItemType instance)Creates an immutable copy of aJWFileItemTypevalue.java.util.Optional<java.lang.String>displayName()booleanequals(java.lang.Object another)This instance is equal to all instances ofJWFileItemthat have equal attribute values.inthashCode()Computes a hash code from attributes:kind,path,size,modifiedTime,displayName.JWFileKindkind()java.nio.file.attribute.FileTimemodifiedTime()java.nio.file.Pathpath()longsize()java.lang.StringtoString()Prints the immutable valueJWFileItemwith attribute values.JWFileItemwithDisplayName(java.lang.String value)Copy the current immutable object by setting a present value for the optionaldisplayNameattribute.JWFileItemwithDisplayName(java.util.Optional<java.lang.String> optional)Copy the current immutable object by setting an optional value for thedisplayNameattribute.JWFileItemwithKind(JWFileKind value)Copy the current immutable object by setting a value for thekindattribute.JWFileItemwithModifiedTime(java.nio.file.attribute.FileTime value)Copy the current immutable object by setting a value for themodifiedTimeattribute.JWFileItemwithPath(java.nio.file.Path value)Copy the current immutable object by setting a value for thepathattribute.JWFileItemwithSize(long value)Copy the current immutable object by setting a value for thesizeattribute.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.io7m.jwheatsheaf.ui.internal.JWFileItemType
name
-
-
-
-
Method Detail
-
kind
public JWFileKind kind()
- Specified by:
kindin interfaceJWFileItemType- Returns:
- The file kind
-
path
public java.nio.file.Path path()
- Specified by:
pathin interfaceJWFileItemType- Returns:
- The file path
-
size
public long size()
- Specified by:
sizein interfaceJWFileItemType- Returns:
- The file size
-
modifiedTime
public java.nio.file.attribute.FileTime modifiedTime()
- Specified by:
modifiedTimein interfaceJWFileItemType- Returns:
- The file modification time
-
displayName
public java.util.Optional<java.lang.String> displayName()
- Specified by:
displayNamein interfaceJWFileItemType- 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 thekindattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for kind- Returns:
- A modified copy of the
thisobject
-
withPath
public final JWFileItem withPath(java.nio.file.Path value)
Copy the current immutable object by setting a value for thepathattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for path- Returns:
- A modified copy of the
thisobject
-
withSize
public final JWFileItem withSize(long value)
Copy the current immutable object by setting a value for thesizeattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for size- Returns:
- A modified copy of the
thisobject
-
withModifiedTime
public final JWFileItem withModifiedTime(java.nio.file.attribute.FileTime value)
Copy the current immutable object by setting a value for themodifiedTimeattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for modifiedTime- Returns:
- A modified copy of the
thisobject
-
withDisplayName
public final JWFileItem withDisplayName(java.lang.String value)
Copy the current immutable object by setting a present value for the optionaldisplayNameattribute.- Parameters:
value- The value for displayName- Returns:
- A modified copy of
thisobject
-
withDisplayName
public final JWFileItem withDisplayName(java.util.Optional<java.lang.String> optional)
Copy the current immutable object by setting an optional value for thedisplayNameattribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for displayName- Returns:
- A modified copy of
thisobject
-
equals
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofJWFileItemthat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:kind,path,size,modifiedTime,displayName.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueJWFileItemwith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
copyOf
public static JWFileItem copyOf(JWFileItemType instance)
Creates an immutable copy of aJWFileItemTypevalue. 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 forJWFileItem.JWFileItem.builder() .setKind(com.io7m.jwheatsheaf.api.JWFileKind) // requiredkind.setPath(java.nio.file.Path) // requiredpath.setSize(long) // requiredsize.setModifiedTime(java.nio.file.attribute.FileTime) // requiredmodifiedTime.setDisplayName(String) // optionaldisplayName.build();- Returns:
- A new JWFileItem builder
-
-