Package co.ankatech.ankasecure.sdk.model
Enum Class OverwritePolicy
- All Implemented Interfaces:
Serializable,Comparable<OverwritePolicy>,Constable
Governs how a file-output operation promotes its result onto an already-existing destination
(PRD §64).
Every SDK file-output operation — streaming and compact — quarantines its
result to a sidecar (<destination>.part) and promotes it to the final path with an atomic
rename. This policy selects the rename semantics:
FAIL_IF_EXISTS— the default. The sidecar is promoted with a plain same-directory rename (noREPLACE_EXISTING; deliberately NOTATOMIC_MOVE, because an atomic rename silently replaces an existing target on both Windows and POSIX). If a file already exists at the destination the promotion fails, the sidecar is deleted, and a typedDestinationExistsExceptionis thrown — the pre-existing destination is left byte-for-byte untouched. The rename itself is the TOCTOU race guard: a destination that appears between preflight and promotion is never clobbered.OVERWRITE— opt-in. The sidecar is promoted withATOMIC_MOVE + REPLACE_EXISTING, atomically replacing any existing destination. On a filesystem that does not support an atomic replacing move (some Windows configurations raiseAtomicMoveNotSupportedException) the SDK falls back to deleting the destination and then atomically renaming the sidecar onto it, leaving a minimal, documented non-atomic window.
The policy is selected on an AuthenticatedSdk instance via the immutable withers
withOverwritePolicy(OverwritePolicy) / withOverwrite(), each of which returns a new
instance sharing the same JWT and HTTP client (no re-authentication).
- Since:
- 3.0.0
- Author:
- ANKATech Solutions Inc.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDefault: refuse to clobber an existing destination (atomic-rename is the TOCTOU guard).Opt-in: atomically replace an existing destination (REPLACE_EXISTING, Windows fallback). -
Method Summary
Modifier and TypeMethodDescriptionstatic OverwritePolicyReturns the enum constant of this class with the specified name.static OverwritePolicy[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
FAIL_IF_EXISTS
Default: refuse to clobber an existing destination (atomic-rename is the TOCTOU guard). -
OVERWRITE
Opt-in: atomically replace an existing destination (REPLACE_EXISTING, Windows fallback).
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-