This repository has been archived by the owner on Jul 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Check-And-Set option to DELETE operation (#178)
* Add eclipse project files to .gitignore * Add support for Check-And-Set option to DELETE operation.
- Loading branch information
Showing
4 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,6 @@ gradle/gradlew | |
gradle/gradlew.bat | ||
gradle/gradle | ||
src/gradle | ||
.classpath | ||
.project | ||
.settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.orbitz.consul.option; | ||
|
||
import static com.orbitz.consul.option.Options.optionallyAdd; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.immutables.value.Value; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
@Value.Immutable | ||
public abstract class DeleteOptions implements ParamAdder { | ||
|
||
public static final DeleteOptions BLANK = ImmutableDeleteOptions.builder().build(); | ||
public static final DeleteOptions RECURSE = ImmutableDeleteOptions.builder().recurse(true).build(); | ||
|
||
public abstract Optional<Long> getCas(); | ||
|
||
public abstract Optional<Boolean> getRecurse(); | ||
|
||
@Value.Derived | ||
public boolean isRecurse() { | ||
return getRecurse().isPresent(); | ||
} | ||
|
||
@Override | ||
public Map<String, Object> toQuery() { | ||
final Map<String, Object> result = new HashMap<>(); | ||
|
||
if (isRecurse()) { | ||
result.put("recurse", ""); | ||
} | ||
|
||
optionallyAdd(result, "cas", getCas()); | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters