Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: add JSON.SET and JSON.GET #2462

Merged
merged 7 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Java: Added `FT.CREATE` ([#2414](https://github.com/valkey-io/valkey-glide/pull/2414))
* Java: Added `FT.DROPINDEX` ([#2440](https://github.com/valkey-io/valkey-glide/pull/2440))
* Java: Added `FT.SEARCH` ([#2439](https://github.com/valkey-io/valkey-glide/pull/2439))
* Java: Added `JSON.SET` and `JSON.GET` ([#2462](https://github.com/valkey-io/valkey-glide/pull/2462))
* Core: Update routing for commands from server modules ([#2461](https://github.com/valkey-io/valkey-glide/pull/2461))

#### Breaking Changes
Expand Down
460 changes: 460 additions & 0 deletions java/client/src/main/java/glide/api/commands/servermodules/Json.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.api.models.commands.json;

import glide.api.commands.servermodules.Json;
import java.util.ArrayList;
import java.util.List;
import lombok.Builder;

/** Additional parameters for {@link Json#get} command. */
@Builder
public final class JsonGetOptions {
/** ValKey API string to designate INDENT */
public static final String INDENT_VALKEY_API = "INDENT";
jamesx-improving marked this conversation as resolved.
Show resolved Hide resolved

/** ValKey API string to designate NEWLINE */
public static final String NEWLINE_VALKEY_API = "NEWLINE";

/** ValKey API string to designate SPACE */
public static final String SPACE_VALKEY_API = "SPACE";

jamesx-improving marked this conversation as resolved.
Show resolved Hide resolved
/** ValKey API string to designate SPACE */
public static final String NOESCAPE_VALKEY_API = "NOESCAPE";

/** Sets an indentation string for nested levels. */
private String indent;

/** Sets a string that's printed at the end of each line. */
private String newline;

/** Sets a string that's put between a key and a value. */
private String space;

/** Allowed to be present for legacy compatibility and has no other effect. */
private boolean noescape;

jamesx-improving marked this conversation as resolved.
Show resolved Hide resolved
/**
* Converts JsonGetOptions into a String[].
*
* @return String[]
*/
public String[] toArgs() {
List<String> args = new ArrayList<>();
if (indent != null) {
args.add(INDENT_VALKEY_API);
args.add(indent);
}

if (newline != null) {
args.add(NEWLINE_VALKEY_API);
args.add(newline);
}

if (space != null) {
args.add(SPACE_VALKEY_API);
args.add(space);
}

if (noescape) {
jamesx-improving marked this conversation as resolved.
Show resolved Hide resolved
args.add(NOESCAPE_VALKEY_API);
}

return args.toArray(new String[0]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.api.models.commands.json;

import static glide.api.models.GlideString.gs;

import glide.api.commands.servermodules.Json;
import glide.api.models.GlideString;
import java.util.ArrayList;
import java.util.List;
import lombok.Builder;

/** GlideString version of additional parameters for {@link Json#get} command. */
@Builder
public final class JsonGetOptionsBinary {
jamesx-improving marked this conversation as resolved.
Show resolved Hide resolved
/** ValKey API string to designate INDENT */
public static final GlideString INDENT_VALKEY_API = gs("INDENT");

/** ValKey API string to designate NEWLINE */
public static final GlideString NEWLINE_VALKEY_API = gs("NEWLINE");

/** ValKey API string to designate SPACE */
public static final GlideString SPACE_VALKEY_API = gs("SPACE");

/** ValKey API string to designate SPACE */
public static final GlideString NOESCAPE_VALKEY_API = gs("NOESCAPE");

/** Sets an indentation string for nested levels. */
private GlideString indent;

/** Sets a string that's printed at the end of each line. */
private GlideString newline;

/** Sets a string that's put between a key and a value. */
private GlideString space;

/** Allowed to be present for legacy compatibility and has no other effect. */
private boolean noescape;

/**
* Converts JsonGetOptions into a GlideString[].
*
* @return GlideString[]
*/
public GlideString[] toArgs() {
List<GlideString> args = new ArrayList<>();
if (indent != null) {
args.add(INDENT_VALKEY_API);
args.add(indent);
}

if (newline != null) {
args.add(NEWLINE_VALKEY_API);
args.add(newline);
}

if (space != null) {
args.add(SPACE_VALKEY_API);
args.add(space);
}

if (noescape) {
args.add(NOESCAPE_VALKEY_API);
}

return args.toArray(new GlideString[0]);
}
}
1 change: 1 addition & 0 deletions java/client/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
exports glide.api.models.commands.scan;
exports glide.api.models.commands.stream;
exports glide.api.models.commands.FT;
exports glide.api.models.commands.json;
jamesx-improving marked this conversation as resolved.
Show resolved Hide resolved
exports glide.api.models.configuration;
exports glide.api.models.exceptions;
exports glide.api.commands.servermodules;
Expand Down
Loading
Loading