com.couchbase.client.java.document.json.JsonObject.empty()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中com.couchbase.client.java.document.json.JsonObject.empty()方法的一些代码示例,展示了JsonObject.empty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonObject.empty()方法的具体详情如下:
包路径:com.couchbase.client.java.document.json.JsonObject
类名称:JsonObject
方法名:empty

JsonObject.empty介绍

[英]Creates a empty JsonObject.
[中]创建一个空的JsonObject。

代码示例

代码示例来源:origin: apache/incubator-gobblin

Bucket bucket = cbCluster.openBucket("default","");
try {
 JsonObject content = JsonObject.empty().put("name", "Michael");
 JsonDocument doc = JsonDocument.create("docId", content);
 JsonDocument inserted = bucket.insert(doc);

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

@Test(expected = DocumentAlreadyExistsException.class)
public void testInsertWithAlreadyExistingID() {
  //@eclipse-formatter:off
  new Couchbase().insert(HOST, BUCKET_NAME, "artist:vincent_van_gogh", JsonObject.empty().toString());
  //@eclipse-formatter:on
}

代码示例来源:origin: com.couchbase.client/java-client

@Override
public JsonObject raw() {
  return JsonObject.empty();
}

代码示例来源:origin: com.couchbase.client/java-client

public QueryExecutionException(String message, JsonObject n1qlError) {
  super(message);
  this.n1qlError = n1qlError == null ? JsonObject.empty() : n1qlError;
}

代码示例来源:origin: com.couchbase.client/java-client

public QueryExecutionException(String message, JsonObject n1qlError, Throwable cause) {
  super(message, cause);
  this.n1qlError = n1qlError == null ? JsonObject.empty() : n1qlError;
}

代码示例来源:origin: com.couchbase.client/java-client

private N1qlMetrics() {
  this(JsonObject.empty());
}

代码示例来源:origin: com.couchbase.client/java-client

private DefaultBucketSettings(Builder builder) {
  this(builder, JsonObject.empty());
}

代码示例来源:origin: com.couchbase.client/java-client

private AnalyticsMetrics() {
  this(JsonObject.empty());
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

@Test
public void testRemove() {
  try {
    //@eclipse-formatter:off
    couchbaseBucket.insert(JsonDocument.create("testRemove", JsonObject.empty()));
    new Couchbase().remove(HOST, BUCKET_NAME, "testRemove");
    assertFalse(couchbaseBucket.exists("testRemove"));
    //@eclipse-formatter:on
  } catch (Exception e) {
    e.printStackTrace();
    fail();
  }
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

@Test
public void testRemoveViaCall() {
  couchbaseBucket.insert(JsonDocument.create("testRemove", JsonObject.empty()));
  testCall(graphDB, "CALL apoc.couchbase.remove({host}, {bucket}, 'testRemove')",
      map("host", HOST, "bucket", BUCKET_NAME),
      r -> assertFalse(couchbaseBucket.exists("testRemove")));
}

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

@Test
public void testRemoveViaCall() {
  couchbaseBucket.insert(JsonDocument.create("testRemove", JsonObject.empty()));
  testCall(graphDB, "CALL apoc.couchbase.remove({host}, {bucket}, 'testRemove')",
      map("host", HOST, "bucket", BUCKET_NAME + ":" + PASSWORD),
      r -> assertFalse(couchbaseBucket.exists("testRemove")));
}

代码示例来源:origin: com.couchbase.client/java-client

@Override
public void clear() {
  //optimized version over AbstractMap's (which uses the entry set)
  bucket.upsert(JsonDocument.create(id, JsonObject.empty()));
}

代码示例来源:origin: com.couchbase.client/java-client

@Override
  public JsonObject deserialize(JsonParser jp, DeserializationContext ctx)
    throws IOException {
    if (jp.getCurrentToken() == JsonToken.START_OBJECT) {
      return decodeObject(jp, JsonObject.empty());
    } else {
      throw new IllegalStateException("Expecting Object as root level object, " +
        "was: " + jp.getCurrentToken());
    }
  }
}

代码示例来源:origin: com.couchbase.client/java-client

/**
 * Create a new {@link CouchbaseMap}, backed by the document identified by <code>id</code>
 * in the given Couchbase <code>bucket</code>. Note that if the document already exists,
 * its content will be used as initial content for this collection. Otherwise it is created empty.
 *
 * @param id the id of the Couchbase document to back the map.
 * @param bucket the {@link Bucket} through which to interact with the document.
 */
public CouchbaseMap(String id, Bucket bucket) {
  this.id = id;
  this.bucket = bucket;
  try {
    bucket.insert(JsonDocument.create(id, JsonObject.empty()));
  } catch (DocumentAlreadyExistsException ex) {
    // Ignore concurrent creations, keep on moving.
  }
}

代码示例来源:origin: lagom/lagom-recipes

private CompletionStage<Done> globalPrepare(CouchbaseSession session) {
  return
    session.get(DOC_ID).thenComposeAsync(doc -> {
      if (doc.isPresent()) {
        return CompletableFuture.completedFuture(Done.getInstance());
      }
      return session.insert(JsonDocument.create(DOC_ID, JsonObject.empty()))
        .thenApply(ignore -> Done.getInstance());
    });
}

代码示例来源:origin: com.couchbase.client/java-client

@Override
public JsonObject call(final ByteBuf input) {
  if (input == null || input.readableBytes() == 0) {
    return JsonObject.empty();
  }
  try {
    return TRANSCODER.byteBufToJsonObject(input);
  } catch (Exception e) {
    throw new TranscodingException("Could not decode View JSON: " + input.toString(CharsetUtil.UTF_8), e);
  } finally {
    if (input.refCnt() > 0) {
      input.release();
    }
  }
}

代码示例来源:origin: lukas-krecan/ShedLock

@Override
public boolean insertRecord(LockConfiguration lockConfiguration) {
  try {
    JsonObject content = JsonObject.empty();
    content.put(LOCK_NAME, lockConfiguration.getName());
    content.put(LOCK_UNTIL, toIsoString(lockConfiguration.getLockAtMostUntil()));
    content.put(LOCKED_AT, toIsoString(Instant.now()));
    content.put(LOCKED_BY, getHostname());
    JsonDocument document = JsonDocument.create(lockConfiguration.getName(), content);
    bucket.insert(document);
    return true;
  } catch (DocumentAlreadyExistsException e) {
    return false;
  }
}

代码示例来源:origin: com.couchbase.client/java-client

@Override
  public Observable<N1qlQueryResult> call(AsyncN1qlQueryResult aqr) {
    final boolean parseSuccess = aqr.parseSuccess();
    final String requestId = aqr.requestId();
    final String clientContextId = aqr.clientContextId();
    return Observable.zip(aqr.rows().toList(),
        aqr.signature().singleOrDefault(JsonObject.empty()),
        aqr.info().singleOrDefault(N1qlMetrics.EMPTY_METRICS),
        aqr.errors().toList(),
        aqr.profileInfo().singleOrDefault(JsonObject.empty()),
        aqr.status(),
        aqr.finalSuccess().singleOrDefault(Boolean.FALSE),
        new Func7<List<AsyncN1qlQueryRow>, Object, N1qlMetrics, List<JsonObject>, JsonObject, String, Boolean, N1qlQueryResult>() {
          @Override
          public N1qlQueryResult call(List<AsyncN1qlQueryRow> rows, Object signature,
                        N1qlMetrics info, List<JsonObject> errors, JsonObject profileInfo, String finalStatus, Boolean finalSuccess) {
            return new DefaultN1qlQueryResult(rows, signature, info, errors, profileInfo, finalStatus, finalSuccess,
                parseSuccess, requestId, clientContextId);
          }
        });
  }
};

代码示例来源:origin: com.couchbase.client/java-client

@Override
  public Observable<AnalyticsQueryResult> call(final AsyncAnalyticsQueryResult aqr) {
    final boolean parseSuccess = aqr.parseSuccess();
    final String requestId = aqr.requestId();
    final String clientContextId = aqr.clientContextId();
    return Observable.zip(aqr.signature().singleOrDefault(JsonObject.empty()),
        aqr.info().singleOrDefault(AnalyticsMetrics.EMPTY_METRICS),
        aqr.errors().toList(),
        aqr.status(),
        aqr.finalSuccess().singleOrDefault(Boolean.FALSE),
        new Func5<Object, AnalyticsMetrics, List<JsonObject>, String, Boolean, AnalyticsQueryResult>() {
          @Override
          public AnalyticsQueryResult call(Object signature, AnalyticsMetrics info, List<JsonObject> errors, String finalStatus, Boolean finalSuccess) {
            return new DefaultAnalyticsQueryResult(aqr.handle(), signature, info, errors, finalStatus, finalSuccess,
                parseSuccess, requestId, clientContextId);
          }
        });
  }
};

代码示例来源:origin: com.couchbase.client/java-client

@Override
  public Observable<AnalyticsQueryResult> call(AsyncAnalyticsQueryResult aqr) {
    final boolean parseSuccess = aqr.parseSuccess();
    final String requestId = aqr.requestId();
    final String clientContextId = aqr.clientContextId();
    return Observable.zip(aqr.rows().toList(),
      aqr.signature().singleOrDefault(JsonObject.empty()),
      aqr.info().singleOrDefault(AnalyticsMetrics.EMPTY_METRICS),
      aqr.errors().toList(),
      aqr.status(),
      aqr.finalSuccess().singleOrDefault(Boolean.FALSE),
      new Func6<List<AsyncAnalyticsQueryRow>, Object, AnalyticsMetrics, List<JsonObject>, String, Boolean, AnalyticsQueryResult>() {
        @Override
        public AnalyticsQueryResult call(List<AsyncAnalyticsQueryRow> rows, Object signature,
          AnalyticsMetrics info, List<JsonObject> errors, String finalStatus, Boolean finalSuccess) {
          return new DefaultAnalyticsQueryResult(rows, signature, info, errors, finalStatus, finalSuccess,
            parseSuccess, requestId, clientContextId);
        }
      });
  }
};

相关文章