org.eclipse.ditto.json.JsonObject.getSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(118)

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

JsonObject.getSize介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public int getSize() {
  return wrapped.getSize();
}

代码示例来源:origin: eclipse/ditto

@Override
public int getSize() {
  return wrapped.getSize();
}

代码示例来源:origin: eclipse/ditto

@Override
public int getSize() {
  return wrapped.getSize();
}

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public int getSize() {
  return wrapped.getSize();
}

代码示例来源:origin: eclipse/ditto

/**
 * Verifies that the actual JSON object has the expected size.
 *
 * @param expectedSize the expected size.
 * @return this assert to allow method chaining.
 */
public JsonObjectAssert hasSize(final int expectedSize) {
  isNotNull();
  final int actualSize = actual.getSize();
  Assertions.assertThat(actualSize)
      .overridingErrorMessage("Expected JSON object to have size <%d> but was <%d>", expectedSize, actualSize)
      .isEqualTo(expectedSize);
  return this;
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-utils-health

/**
 * Creates a new {@link StatusDetailMessage} from a JSON object.
 *
 * @param jsonObject the JSON object.
 * @return the message.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 * @throws IllegalArgumentException if {@code jsonObject} is empty.
 * @throws JsonMissingFieldException if the passed in {@code jsonObject} was not in the expected format.
 */
public static StatusDetailMessage fromJson(final JsonObject jsonObject) {
  if (jsonObject.getSize() != 1) {
    throw new JsonParseException("Message must contain exactly one field, but does not:\n" + jsonObject);
  }
  final JsonField messageField = jsonObject.iterator().next();
  final Level level = Level.valueOf(messageField.getKeyName());
  final JsonValue message = messageField.getValue();
  return of(level, message);
}

代码示例来源:origin: eclipse/ditto

/**
 * Creates a new {@link StatusDetailMessage} from a JSON object.
 *
 * @param jsonObject the JSON object.
 * @return the message.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 * @throws IllegalArgumentException if {@code jsonObject} is empty.
 * @throws JsonMissingFieldException if the passed in {@code jsonObject} was not in the expected format.
 */
public static StatusDetailMessage fromJson(final JsonObject jsonObject) {
  if (jsonObject.getSize() != 1) {
    throw new JsonParseException("Message must contain exactly one field, but does not:\n" + jsonObject);
  }
  final JsonField messageField = jsonObject.iterator().next();
  final Level level = Level.valueOf(messageField.getKeyName());
  final JsonValue message = messageField.getValue();
  return of(level, message);
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-utils-persistence

/**
 * Maps the specified JsonObject to a {@link com.mongodb.BasicDBObject} which can be stored in MongoDB.
 *
 * @param jsonObject the object to be mapped.
 * @return {@code jsonObject} as BasicDBObject.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 */
private BasicDBObject mapJsonObjectToBasicDBObject(final JsonObject jsonObject) {
  checkNotNull(jsonObject, "JSON object to be mapped");
  final BasicDBObject result = new BasicDBObject(jsonObject.getSize());
  jsonObject.forEach(jsonField -> result.put(reviseKeyName(jsonField.getKey()),
      mapJsonValueToJavaObject(jsonField.getValue())));
  return result;
}

相关文章