Class WriteMode
- java.lang.Object
-
- com.dropbox.core.v2.files.WriteMode
-
public final class WriteMode extends java.lang.Object
Your intent when writing a file to some path. This is used to determine what constitutes a conflict and what the autorename strategy is. In some situations, the conflict behavior is identical: (a) If the target path doesn't refer to anything, the file is always written; no conflict. (b) If the target path refers to a folder, it's always a conflict. (c) If the target path refers to a file with identical contents, nothing gets written; no conflict. The conflict checking differs in the case where there's a file at the target path with contents different from the contents you're trying to write.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 returntrue
. You can usetag()
to determine the tag associated with this instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WriteMode.Tag
Discriminating tag type forWriteMode
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 ofWriteMode
that has its tag set toWriteMode.Tag.UPDATE
.
-
-
-
Field Detail
-
ADD
public static final WriteMode ADD
Do not overwrite an existing file if there is a conflict. The autorename strategy is to append a number to the file name. For example, "document.txt" might become "document (2).txt".
-
-
Method Detail
-
tag
public WriteMode.Tag tag()
Returns the tag for this instance.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 returntrue
. Callers are recommended to use the tag value in aswitch
statement to properly handle the different values for thisWriteMode
.- Returns:
- the tag for this instance.
-
isAdd
public boolean isAdd()
- Returns:
true
if this instance is tagged asWriteMode.Tag.ADD
,false
otherwise.
-
isOverwrite
public boolean isOverwrite()
- Returns:
true
if this instance is tagged asWriteMode.Tag.OVERWRITE
,false
otherwise.
-
isUpdate
public boolean isUpdate()
- Returns:
true
if this instance is tagged asWriteMode.Tag.UPDATE
,false
otherwise.
-
update
public static WriteMode update(java.lang.String value)
Returns an instance ofWriteMode
that has its tag set toWriteMode.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".
- Parameters:
value
- value to assign to this instance.- Returns:
- Instance of
WriteMode
with its tag set toWriteMode.Tag.UPDATE
. - Throws:
java.lang.IllegalArgumentException
- ifvalue
is shorter than 9, does not match pattern "[0-9a-f]+
", or isnull
.
-
getUpdateValue
public java.lang.String getUpdateValue()
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".This instance must be tagged as
WriteMode.Tag.UPDATE
.- Returns:
- The
String
value associated with this instance ifisUpdate()
istrue
. - Throws:
java.lang.IllegalStateException
- IfisUpdate()
isfalse
.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toStringMultiline
public java.lang.String toStringMultiline()
Returns a String representation of this object formatted for easier readability.The returned String may contain newlines.
- Returns:
- Formatted, multiline String representation of this object
-
-