@Value.Check void validate() { if (isBlocking()) { checkArgument(getIndex().isPresent(), "If wait is specified, index must also be specified"); } }
@Override public Map<String, Object> toQuery() { Map<String, Object> result = new HashMap<>(); switch (getConsistencyMode()) { case CONSISTENT: result.put("consistent", ""); break; case STALE: result.put("stale", ""); break; } if (isBlocking()) { optionallyAdd(result, "wait", getWait()); optionallyAdd(result, "index", getIndex()); } optionallyAdd(result, "token", getToken()); optionallyAdd(result, "near", getNear()); optionallyAdd(result, "dc", getDatacenter()); return result; } }
token(tokenOptional); Optional<BigInteger> indexOptional = instance.getIndex(); if (indexOptional.isPresent()) { index(indexOptional);
protected static QueryOptions watchParams(final BigInteger index, final int blockSeconds, QueryOptions queryOptions) { checkArgument(!queryOptions.getIndex().isPresent() && !queryOptions.getWait().isPresent(), "Index and wait cannot be overridden"); ImmutableQueryOptions.Builder builder = ImmutableQueryOptions.builder() .from(watchDefaultParams(index, blockSeconds)) .token(queryOptions.getToken()) .consistencyMode(queryOptions.getConsistencyMode()) .near(queryOptions.getNear()) .datacenter(queryOptions.getDatacenter()); for (String tag : queryOptions.getTag()) { builder.addTag(tag); } return builder.build(); }