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
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, waitMethods inherited from interface com.io7m.jwheatsheaf.ui.internal.JWFileItemType
name
-
Method Details
-
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
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
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
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
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
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
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
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
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
-