com.alibaba.fastjson.JSONObject.fluentPut()方法的使用及代码示例

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

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

JSONObject.fluentPut介绍

暂无

代码示例

代码示例来源:origin: alibaba/Sentinel

@Override
public CommandResponse<String> handle(CommandRequest request) {
  JSONObject res = new JSONObject()
    .fluentPut("mode", ClusterStateManager.getMode())
    .fluentPut("lastModified", ClusterStateManager.getLastModified())
    .fluentPut("clientAvailable", isClusterClientSpiAvailable())
    .fluentPut("serverAvailable", isClusterServerSpiAvailable());
  return CommandResponse.ofSuccess(res.toJSONString());
}

代码示例来源:origin: com.scireum/sirius-db

/**
   * Builds the function score query.
   *
   * @return the function score query as {@link JSONObject}
   */
  public JSONObject build() {
    return new JSONObject().fluentPut(FUNCTION_SCORE,
                     new JSONObject().fluentPut(FUNCTIONS,
                                   new JSONArray(new ArrayList<Object>(functions)))
                             .fluentPutAll(parameters));
  }
}

代码示例来源:origin: alibaba/Sentinel

private JSONArray buildRequestLimitData(Set<String> namespaceSet) {
    JSONArray array = new JSONArray();
    for (String namespace : namespaceSet) {
      array.add(new JSONObject()
        .fluentPut("namespace", namespace)
        .fluentPut("currentQps", GlobalRequestLimiter.getCurrentQps(namespace))
        .fluentPut("maxAllowedQps", GlobalRequestLimiter.getMaxAllowedQps(namespace))
      );
    }
    return array;
  }
}

代码示例来源:origin: alibaba/Sentinel

private CommandResponse<String> globalConfigResult() {
    ServerTransportConfig transportConfig = new ServerTransportConfig()
      .setPort(ClusterServerConfigManager.getPort())
      .setIdleSeconds(ClusterServerConfigManager.getIdleSeconds());
    ServerFlowConfig flowConfig = new ServerFlowConfig()
      .setExceedCount(ClusterServerConfigManager.getExceedCount())
      .setMaxOccupyRatio(ClusterServerConfigManager.getMaxOccupyRatio())
      .setIntervalMs(ClusterServerConfigManager.getIntervalMs())
      .setSampleCount(ClusterServerConfigManager.getSampleCount());
    JSONObject config = new JSONObject()
      .fluentPut("transport", transportConfig)
      .fluentPut("flow", flowConfig)
      .fluentPut("namespaceSet", ClusterServerConfigManager.getNamespaceSet());
    return CommandResponse.ofSuccess(config.toJSONString());
  }
}

代码示例来源:origin: alibaba/Sentinel

@Override
public CommandResponse<String> handle(CommandRequest request) {
  JSONObject info = new JSONObject();
  JSONArray connectionGroups = new JSONArray();
  Set<String> namespaceSet = ClusterServerConfigManager.getNamespaceSet();
  for (String namespace : namespaceSet) {
    ConnectionGroup group = ConnectionManager.getOrCreateConnectionGroup(namespace);
    if (group != null) {
      connectionGroups.add(group);
    }
  }
  ServerTransportConfig transportConfig = new ServerTransportConfig()
    .setPort(ClusterServerConfigManager.getPort())
    .setIdleSeconds(ClusterServerConfigManager.getIdleSeconds());
  ServerFlowConfig flowConfig = new ServerFlowConfig()
    .setExceedCount(ClusterServerConfigManager.getExceedCount())
    .setMaxOccupyRatio(ClusterServerConfigManager.getMaxOccupyRatio())
    .setIntervalMs(ClusterServerConfigManager.getIntervalMs())
    .setSampleCount(ClusterServerConfigManager.getSampleCount())
    .setMaxAllowedQps(ClusterServerConfigManager.getMaxAllowedQps());
  JSONArray requestLimitData = buildRequestLimitData(namespaceSet);
  info.fluentPut("port", ClusterServerConfigManager.getPort())
    .fluentPut("connection", connectionGroups)
    .fluentPut("requestLimitData", requestLimitData)
    .fluentPut("transport", transportConfig)
    .fluentPut("flow", flowConfig)
    .fluentPut("namespaceSet", namespaceSet)
    .fluentPut("embedded", ClusterServerConfigManager.isEmbedded());
  return CommandResponse.ofSuccess(info.toJSONString());
}

代码示例来源:origin: alibaba/Sentinel

private CommandResponse<String> namespaceConfigResult(/*@NonEmpty*/ String namespace) {
  ServerFlowConfig flowConfig = new ServerFlowConfig()
    .setExceedCount(ClusterServerConfigManager.getExceedCount(namespace))
    .setMaxOccupyRatio(ClusterServerConfigManager.getMaxOccupyRatio(namespace))
    .setIntervalMs(ClusterServerConfigManager.getIntervalMs(namespace))
    .setSampleCount(ClusterServerConfigManager.getSampleCount(namespace));
  JSONObject config = new JSONObject()
    .fluentPut("flow", flowConfig);
  return CommandResponse.ofSuccess(config.toJSONString());
}

代码示例来源:origin: com.scireum/sirius-db

/**
   * Generates a {@link JSONObject} that represents this suggester.
   *
   * @return the suggester as a JSON object
   */
  public JSONObject build() {
    return new JSONObject().fluentPut(PARAM_TEXT, text).fluentPut(type, body);
  }
}

代码示例来源:origin: com.scireum/sirius-db

@Override
protected Object transformToElastic(Object object) {
  return ((Map<?, ?>) object).entrySet()
                .stream()
                .map(e -> new JSONObject().fluentPut(StringMapProperty.KEY, e.getKey())
                             .fluentPut(StringMapProperty.VALUE, e.getValue()))
                .collect(Collectors.toList());
}

代码示例来源:origin: com.scireum/sirius-db

@Override
@SuppressWarnings("unchecked")
protected Object transformToElastic(Object object) {
  return ((Map<?, ?>) object).entrySet()
                .stream()
                .map(e -> new JSONObject().fluentPut(KEY, e.getKey()).fluentPut(VALUE, e.getValue()))
                .collect(Collectors.toList());
}

代码示例来源:origin: com.scireum/sirius-db

@Override
protected Object transformToElastic(Object object) {
  return ((Map<?, ?>) object).entrySet()
                .stream()
                .map(e -> new JSONObject().fluentPut(StringMapProperty.KEY, e.getKey())
                             .fluentPut(StringMapProperty.VALUE,
                                  Elastic.FILTERS.transform(e.getValue())))
                .collect(Collectors.toList());
}

代码示例来源:origin: xiancloud/xian

@Override
  public void execute(UnitRequest request, Handler<UnitResponse> handler) throws ExecutionException {
    handler.handle(UnitResponse.createSuccess(
        new JSONObject()
            .fluentPut("cols", TableMetaCache.COLS.get(TABLE_NAME))
            .fluentPut("idCol", TableMetaCache.ID_COL.get(TABLE_NAME))
    ));
  }
}

代码示例来源:origin: xiancloud/xian

@Override
  public void execute(UnitRequest request, Handler<UnitResponse> handler) throws ExecutionException {
    handler.handle(UnitResponse.createSuccess(
        new JSONObject()
            .fluentPut("cols", TableMetaCache.COLS.get(TABLE_NAME))
            .fluentPut("idCol", TableMetaCache.ID_COL.get(TABLE_NAME))
    ));
  }
}

代码示例来源:origin: com.scireum/sirius-db

/**
 * Creates a query that matches everything.
 *
 * @return a new match_all query.
 */
public ElasticConstraint matchAll() {
  return wrap(new JSONObject().fluentPut("match_all", new JSONObject()));
}

代码示例来源:origin: com.scireum/sirius-db

/**
 * Adds a descending sort by the given field to the query.
 *
 * @param field the field to order by
 * @return the query itself for fluent method calls
 */
@Override
public ElasticQuery<E> orderDesc(Mapping field) {
  return sort(field, new JSONObject().fluentPut(KEY_ORDER, KEY_DESC));
}

代码示例来源:origin: com.scireum/sirius-db

/**
   * Creates a query that matches nothing.
   *
   * @return a new match_none query.
   */
  public ElasticConstraint matchNone() {
    return wrap(new JSONObject().fluentPut("match_none", new JSONObject()));
  }
}

代码示例来源:origin: com.alibaba.csp/sentinel-transport-common

@Override
public CommandResponse<String> handle(CommandRequest request) {
  JSONObject res = new JSONObject()
    .fluentPut("mode", ClusterStateManager.getMode())
    .fluentPut("lastModified", ClusterStateManager.getLastModified())
    .fluentPut("clientAvailable", isClusterClientSpiAvailable())
    .fluentPut("serverAvailable", isClusterServerSpiAvailable());
  return CommandResponse.ofSuccess(res.toJSONString());
}

代码示例来源:origin: com.alibaba.csp/sentinel-cluster-server-default

private JSONArray buildRequestLimitData(Set<String> namespaceSet) {
    JSONArray array = new JSONArray();
    for (String namespace : namespaceSet) {
      array.add(new JSONObject()
        .fluentPut("namespace", namespace)
        .fluentPut("currentQps", GlobalRequestLimiter.getCurrentQps(namespace))
        .fluentPut("maxAllowedQps", GlobalRequestLimiter.getMaxAllowedQps(namespace))
      );
    }
    return array;
  }
}

代码示例来源:origin: com.scireum/sirius-db

/**
 * Adds a sort statement for the given field to the query.
 *
 * @param field    the field to sort by
 * @param sortSpec a JSON object describing a sort requirement
 * @return the query itself for fluent method calls
 */
public ElasticQuery<E> sort(Mapping field, JSONObject sortSpec) {
  return sort(new JSONObject().fluentPut(field.toString(), sortSpec));
}

代码示例来源:origin: com.scireum/sirius-db

/**
 * Closes a scroll query.
 *
 * @param scrollId the id of the scroll cursor
 * @return the response of the call
 */
public JSONObject closeScroll(String scrollId) {
  return performDelete().data(new JSONObject().fluentPut("scroll_id", scrollId))
             .execute("/_search/scroll")
             .response();
}

代码示例来源:origin: com.alibaba.csp/sentinel-cluster-server-default

private CommandResponse<String> namespaceConfigResult(/*@NonEmpty*/ String namespace) {
  ServerFlowConfig flowConfig = new ServerFlowConfig()
    .setExceedCount(ClusterServerConfigManager.getExceedCount(namespace))
    .setMaxOccupyRatio(ClusterServerConfigManager.getMaxOccupyRatio(namespace))
    .setIntervalMs(ClusterServerConfigManager.getIntervalMs(namespace))
    .setSampleCount(ClusterServerConfigManager.getSampleCount(namespace));
  JSONObject config = new JSONObject()
    .fluentPut("flow", flowConfig);
  return CommandResponse.ofSuccess(config.toJSONString());
}

相关文章

微信公众号

最新文章

更多