public final class WriteMode
extends java.lang.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
Do not overwrite an existing file if there is a conflict.
|
static WriteMode |
OVERWRITE
Always overwrite the existing file.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
java.lang.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.
|
java.lang.String |
toString() |
java.lang.String |
toStringMultiline()
Returns a String representation of this object formatted for easier
readability.
|
static WriteMode |
update(java.lang.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(java.lang.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
.java.lang.IllegalArgumentException
- if value
is shorter than 9,
does not match pattern "[0-9a-f]+
", or is null
.public java.lang.String getUpdateValue()
This instance must be tagged as WriteMode.Tag.UPDATE
.
String
value associated with this instance if isUpdate()
is true
.java.lang.IllegalStateException
- If isUpdate()
is false
.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringMultiline()
The returned String may contain newlines.