@Override public final Map<String, Object> toQuery() { Map<String, Object> result = new HashMap<>(); optionallyAdd(result, "dc", getDc()); optionallyAdd(result, "cas", getCas()); optionallyAdd(result, "acquire", getAcquire()); optionallyAdd(result, "release", getRelease()); optionallyAdd(result, "token", getToken()); return result; } }
/** * Puts a value into the key/value store. * * @param key The key to use as index. * @param value The value to index. * @param putOptions PUT options (e.g. wait, acquire). * @return <code>true</code> if the value was successfully indexed. */ public boolean putValue(String key, String value, long flags, PutOptions putOptions, Charset charset) { checkArgument(StringUtils.isNotEmpty(key), "Key must be defined"); Map<String, Object> query = putOptions.toQuery(); if (flags != 0) { query.put("flags", UnsignedLongs.toString(flags)); } if (value == null) { return http.extract(api.putValue(trimLeadingSlash(key), query)); } else { return http.extract(api.putValue(trimLeadingSlash(key), RequestBody.create(MediaType.parse("text/plain; charset=" + charset.name()), value), query)); } }
/** * Puts a value into the key/value store. * * @param key The key to use as index. * @param value The value to index. * @param putOptions PUT options (e.g. wait, acquire). * @return <code>true</code> if the value was successfully indexed. */ public boolean putValue(String key, byte[] value, long flags, PutOptions putOptions) { checkArgument(StringUtils.isNotEmpty(key), "Key must be defined"); Map<String, Object> query = putOptions.toQuery(); if (flags != 0) { query.put("flags", UnsignedLongs.toString(flags)); } if (value == null) { return http.extract(api.putValue(trimLeadingSlash(key), query)); } else { return http.extract(api.putValue(trimLeadingSlash(key), RequestBody.create(MediaType.parse("application/octet-stream"), value), query)); } }
Optional<Long> casOptional = instance.getCas(); if (casOptional.isPresent()) { cas(casOptional); Optional<String> acquireOptional = instance.getAcquire(); if (acquireOptional.isPresent()) { acquire(acquireOptional); Optional<String> releaseOptional = instance.getRelease(); if (releaseOptional.isPresent()) { release(releaseOptional); Optional<String> dcOptional = instance.getDc(); if (dcOptional.isPresent()) { dc(dcOptional); Optional<String> tokenOptional = instance.getToken(); if (tokenOptional.isPresent()) { token(tokenOptional);