public final class WriteMode extends Object
This class is a tagged union. Tagged unions instances are always
associated to a specific tag. This means only one of the isAbc()
methods will return true
. You can use tag()
to determine the
tag associated with this instance.
Modifier and Type | Class and Description |
---|---|
static class |
WriteMode.Tag
Discriminating tag type for
WriteMode . |
Modifier and Type | Field and Description |
---|---|
static WriteMode |
ADD
Never overwrite the existing file.
|
static WriteMode |
OVERWRITE
Always overwrite the existing file.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getUpdateValue()
Overwrite if the given "rev" matches the existing file's "rev".
|
int |
hashCode() |
boolean |
isAdd()
|
boolean |
isOverwrite()
|
boolean |
isUpdate()
|
WriteMode.Tag |
tag()
Returns the tag for this instance.
|
String |
toString() |
String |
toStringMultiline()
Returns a String representation of this object formatted for easier
readability.
|
static WriteMode |
update(String value)
Returns an instance of
WriteMode that has its tag set to WriteMode.Tag.UPDATE . |
public static final WriteMode ADD
public WriteMode.Tag tag()
This class is a tagged union. Tagged unions instances are always
associated to a specific tag. This means only one of the isXyz()
methods will return true
. Callers are recommended to use the tag
value in a switch
statement to properly handle the different
values for this WriteMode
.
public boolean isAdd()
true
if this instance is tagged as WriteMode.Tag.ADD
,
false
otherwise.public boolean isOverwrite()
true
if this instance is tagged as WriteMode.Tag.OVERWRITE
,
false
otherwise.public boolean isUpdate()
true
if this instance is tagged as WriteMode.Tag.UPDATE
,
false
otherwise.public static WriteMode update(String value)
WriteMode
that has its tag set to WriteMode.Tag.UPDATE
.
Overwrite if the given "rev" matches the existing file's "rev". The autorename strategy is to append the string "conflicted copy" to the file name. For example, "document.txt" might become "document (conflicted copy).txt" or "document (Panda's conflicted copy).txt".
value
- value to assign to this instance.WriteMode
with its tag set to WriteMode.Tag.UPDATE
.IllegalArgumentException
- if value
is shorter than 9,
does not match pattern "[0-9a-f]+
", or is null
.public String getUpdateValue()
This instance must be tagged as WriteMode.Tag.UPDATE
.
String
value associated with this instance if isUpdate()
is true
.IllegalStateException
- If isUpdate()
is false
.public String toStringMultiline()
The returned String may contain newlines.