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 class
JWFileItem.Builder
Builds instances of typeJWFileItem
. -
Method Summary
Modifier and Type Method Description static JWFileItem.Builder
builder()
Creates a builder forJWFileItem
.static JWFileItem
copyOf(JWFileItemType instance)
Creates an immutable copy of aJWFileItemType
value.java.util.Optional<java.lang.String>
displayName()
boolean
equals(java.lang.Object another)
This instance is equal to all instances ofJWFileItem
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:kind
,path
,size
,modifiedTime
,displayName
.JWFileKind
kind()
java.nio.file.attribute.FileTime
modifiedTime()
java.nio.file.Path
path()
long
size()
java.lang.String
toString()
Prints the immutable valueJWFileItem
with attribute values.JWFileItem
withDisplayName(java.lang.String value)
Copy the current immutable object by setting a present value for the optionaldisplayName
attribute.JWFileItem
withDisplayName(java.util.Optional<java.lang.String> optional)
Copy the current immutable object by setting an optional value for thedisplayName
attribute.JWFileItem
withKind(JWFileKind value)
Copy the current immutable object by setting a value for thekind
attribute.JWFileItem
withModifiedTime(java.nio.file.attribute.FileTime value)
Copy the current immutable object by setting a value for themodifiedTime
attribute.JWFileItem
withPath(java.nio.file.Path value)
Copy the current immutable object by setting a value for thepath
attribute.JWFileItem
withSize(long value)
Copy the current immutable object by setting a value for thesize
attribute.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 Details
-
kind
- Specified by:
kind
in interfaceJWFileItemType
- Returns:
- The file kind
-
path
public java.nio.file.Path path()- Specified by:
path
in interfaceJWFileItemType
- Returns:
- The file path
-
size
public long size()- Specified by:
size
in interfaceJWFileItemType
- Returns:
- The file size
-
modifiedTime
public java.nio.file.attribute.FileTime modifiedTime()- Specified by:
modifiedTime
in interfaceJWFileItemType
- Returns:
- The file modification time
-
displayName
public java.util.Optional<java.lang.String> displayName()- Specified by:
displayName
in interfaceJWFileItemType
- Returns:
- The file display name override, if any
-
withKind
Copy the current immutable object by setting a value for thekind
attribute. 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
this
object
-
withPath
Copy the current immutable object by setting a value for thepath
attribute. 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
this
object
-
withSize
Copy the current immutable object by setting a value for thesize
attribute. 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
this
object
-
withModifiedTime
Copy the current immutable object by setting a value for themodifiedTime
attribute. 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
this
object
-
withDisplayName
Copy the current immutable object by setting a present value for the optionaldisplayName
attribute.- Parameters:
value
- The value for displayName- Returns:
- A modified copy of
this
object
-
withDisplayName
Copy the current immutable object by setting an optional value for thedisplayName
attribute. 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
this
object
-
equals
public boolean equals(java.lang.Object another)This instance is equal to all instances ofJWFileItem
that have equal attribute values.- Overrides:
equals
in classjava.lang.Object
- Returns:
true
ifthis
is equal toanother
instance
-
hashCode
public int hashCode()Computes a hash code from attributes:kind
,path
,size
,modifiedTime
,displayName
.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hashCode value
-
toString
public java.lang.String toString()Prints the immutable valueJWFileItem
with attribute values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the value
-
copyOf
Creates an immutable copy of aJWFileItemType
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
Creates a builder forJWFileItem
.JWFileItem.builder() .setKind(com.io7m.jwheatsheaf.api.JWFileKind) // required
kind
.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
-