Class WriteMode
- java.lang.Object
-
- com.dropbox.core.v2.files.WriteMode
-
public final class WriteMode extends java.lang.ObjectYour 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 classWriteMode.TagDiscriminating tag type forWriteMode.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.StringgetUpdateValue()Overwrite if the given "rev" matches the existing file's "rev".inthashCode()booleanisAdd()booleanisOverwrite()booleanisUpdate()WriteMode.Tagtag()Returns the tag for this instance.java.lang.StringtoString()java.lang.StringtoStringMultiline()Returns a String representation of this object formatted for easier readability.static WriteModeupdate(java.lang.String value)Returns an instance ofWriteModethat 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 aswitchstatement to properly handle the different values for thisWriteMode.- Returns:
- the tag for this instance.
-
isAdd
public boolean isAdd()
- Returns:
trueif this instance is tagged asWriteMode.Tag.ADD,falseotherwise.
-
isOverwrite
public boolean isOverwrite()
- Returns:
trueif this instance is tagged asWriteMode.Tag.OVERWRITE,falseotherwise.
-
isUpdate
public boolean isUpdate()
- Returns:
trueif this instance is tagged asWriteMode.Tag.UPDATE,falseotherwise.
-
update
public static WriteMode update(java.lang.String value)
Returns an instance ofWriteModethat has its tag set toWriteMode.Tag.UPDATE.Overwrite if the given "rev" matches the existing file's "rev". The supplied value should be the latest known "rev" of the file, for example, from
FileMetadata, from when the file was last downloaded by the app. This will cause the file on the Dropbox servers to be overwritten if the given "rev" matches the existing file's current "rev" on the Dropbox servers. 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
WriteModewith its tag set toWriteMode.Tag.UPDATE. - Throws:
java.lang.IllegalArgumentException- ifvalueis 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 supplied value should be the latest known "rev" of the file, for example, fromFileMetadata, from when the file was last downloaded by the app. This will cause the file on the Dropbox servers to be overwritten if the given "rev" matches the existing file's current "rev" on the Dropbox servers. 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
Stringvalue associated with this instance ifisUpdate()istrue. - Throws:
java.lang.IllegalStateException- IfisUpdate()isfalse.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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
-
-