本文整理了Java中io.vertx.core.json.JsonArray.forEach()
方法的一些代码示例,展示了JsonArray.forEach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonArray.forEach()
方法的具体详情如下:
包路径:io.vertx.core.json.JsonArray
类名称:JsonArray
方法名:forEach
暂无
代码示例来源:origin: apache/servicecomb-java-chassis
public void refreshMembers(JsonObject members) {
List<String> newServerAddresses = new ArrayList<>();
members.getJsonArray("instances").forEach(m -> {
JsonObject instance = (JsonObject) m;
if ("UP".equals(instance.getString("status", "UP"))) {
String endpoint = instance.getJsonArray("endpoints").getString(0);
String scheme = instance.getBoolean("isHttps", false) ? "https" : "http";
newServerAddresses.add(scheme + SCHEMA_SEPRATOR
+ endpoint.substring(endpoint.indexOf(SCHEMA_SEPRATOR) + SCHEMA_SEPRATOR.length()));
}
});
synchronized (lock) {
this.configServerAddresses.clear();
this.configServerAddresses.addAll(newServerAddresses);
Collections.shuffle(this.configServerAddresses);
}
LOGGER.info("New config center members: {}", this.configServerAddresses);
}
}
代码示例来源:origin: org.eclipse.hono/hono-core
/**
* Gets this credentials' secret(s) as {@code Map} instances.
*
* @return The (potentially empty) list of secrets.
*/
@JsonProperty(CredentialsConstants.FIELD_SECRETS)
public List<Map<String, Object>> getSecretsAsMaps() {
final List<Map<String, Object>> result = new LinkedList<>();
secrets.forEach(secret -> result.add(((JsonObject) secret).getMap()));
return result;
}
代码示例来源:origin: eclipse/hono
/**
* Gets this credentials' secret(s) as {@code Map} instances.
*
* @return The (potentially empty) list of secrets.
*/
@JsonProperty(CredentialsConstants.FIELD_SECRETS)
public List<Map<String, Object>> getSecretsAsMaps() {
final List<Map<String, Object>> result = new LinkedList<>();
secrets.forEach(secret -> result.add(((JsonObject) secret).getMap()));
return result;
}
代码示例来源:origin: wang007/vertx-start
@Override
public JsonArraySend addAll(JsonArray array) {
assertSend();
array.forEach(this::add);
return this;
}
代码示例来源:origin: io.vertx/vertx-dropwizard-metrics
private List<Match> loadMonitored(String arrayField, JsonObject json) {
List<Match> list = new ArrayList<>();
JsonArray monitored = json.getJsonArray(arrayField, new JsonArray());
monitored.forEach(object -> {
if (object instanceof JsonObject) list.add(new Match((JsonObject) object));
});
return list;
}
代码示例来源:origin: io.vertx/vertx-micrometer-metrics
private List<Match> loadLabelMatches(JsonObject json) {
List<Match> list = new ArrayList<>();
JsonArray monitored = json.getJsonArray("labelMatches", new JsonArray());
monitored.forEach(object -> {
if (object instanceof JsonObject) list.add(new Match((JsonObject) object));
});
return list;
}
代码示例来源:origin: com.progressoft.brix.domino.api/domino-api-server
private void addCSRFHandler(Router router) {
JsonArray jsonArray = config.getJsonArray("csrf.whitelist", new JsonArray());
Set<String> whiteList=new HashSet<>();
jsonArray.forEach(o-> whiteList.add(o.toString()));
router.route().handler(new DominoCSRFHandler(secret,config));
}
代码示例来源:origin: org.apache.servicecomb/config-cc
public void refreshMembers(JsonObject members) {
List<String> newServerAddresses = new ArrayList<>();
members.getJsonArray("instances").forEach(m -> {
JsonObject instance = (JsonObject) m;
if ("UP".equals(instance.getString("status", "UP"))) {
String endpoint = instance.getJsonArray("endpoints").getString(0);
String scheme = instance.getBoolean("isHttps", false) ? "https" : "http";
newServerAddresses.add(scheme + SCHEMA_SEPRATOR
+ endpoint.substring(endpoint.indexOf(SCHEMA_SEPRATOR) + SCHEMA_SEPRATOR.length()));
}
});
synchronized (lock) {
this.configServerAddresses.clear();
this.configServerAddresses.addAll(newServerAddresses);
Collections.shuffle(this.configServerAddresses);
}
LOGGER.info("New config center members: {}", this.configServerAddresses);
}
}
代码示例来源:origin: eclipse/hono
private Authorities getAuthorities(final JsonObject user) {
final AuthoritiesImpl result = new AuthoritiesImpl();
user.getJsonArray(FIELD_AUTHORITIES).forEach(obj -> {
final String authority = (String) obj;
final Authorities roleAuthorities = roles.get(authority);
if (roleAuthorities != null) {
result.addAll(roleAuthorities);
}
});
return result;
}
代码示例来源:origin: io.knotx/knotx-core
public static void fromJson(JsonObject json, MethodRoutingEntries obj) {
if (json.getValue("items") instanceof JsonArray) {
java.util.ArrayList<io.knotx.server.configuration.RoutingEntry> list = new java.util.ArrayList<>();
json.getJsonArray("items").forEach( item -> {
if (item instanceof JsonObject)
list.add(new io.knotx.server.configuration.RoutingEntry((JsonObject)item));
});
obj.setItems(list);
}
}
代码示例来源:origin: eclipse/hono
/**
* Add default values for optional fields that are not filled in the payload.
* <p>
* Payload should be checked for validity first, there is no error handling inside this method anymore.
* </p>
*
* @param checkedPayload The checked payload to add optional fields to.
* @throws ClassCastException If the {@link TenantConstants#FIELD_ADAPTERS_TYPE} element is not a {@link JsonArray}
* or the JsonArray contains elements that are not of type {@link JsonObject}.
*/
protected final void addNotPresentFieldsWithDefaultValuesForTenant(final JsonObject checkedPayload) {
if (!checkedPayload.containsKey(TenantConstants.FIELD_ENABLED)) {
log.trace("adding 'enabled' key to payload");
checkedPayload.put(TenantConstants.FIELD_ENABLED, Boolean.TRUE);
}
final JsonArray adapters = checkedPayload.getJsonArray(TenantConstants.FIELD_ADAPTERS);
if (adapters != null) {
adapters.forEach(elem -> addNotPresentFieldsWithDefaultValuesForAdapter((JsonObject) elem));
}
}
代码示例来源:origin: com.progressoft.brix.domino/vertx-domino-event-bus-backend
private BridgeOptions configureBridgeOptions(JsonObject config) {
BridgeOptions bridgeOptions = new BridgeOptions();
JsonObject addresses=config.getJsonObject(ADDRESSES);
JsonArray outbounds=addresses.getJsonArray(OUTBOUND);
JsonArray inbounds=addresses.getJsonArray(INBOUND);
outbounds.forEach(o-> addOutboundPermitted(bridgeOptions, (JsonObject) o));
inbounds.forEach(i-> addInboundPermitted(bridgeOptions, (JsonObject) i));
return bridgeOptions;
}
代码示例来源:origin: eclipse/hono
/**
* Hashes clear text passwords contained in hashed-password credentials
* provided by a client.
*
* @param credentials The credentials to hash the clear text passwords for.
* @return A future containing the (updated) credentials.
*/
protected final Future<CredentialsObject> hashPlainPasswords(final CredentialsObject credentials) {
final Future<CredentialsObject> result = Future.future();
if (CredentialsConstants.SECRETS_TYPE_HASHED_PASSWORD.equals(credentials.getType())) {
getVertx().executeBlocking(blockingCodeHandler -> {
log.debug("hashing password on vert.x worker thread [{}]", Thread.currentThread().getName());
credentials.getSecrets().forEach(secret -> hashPwdAndUpdateSecret((JsonObject) secret));
blockingCodeHandler.complete(credentials);
}, result);
} else {
result.complete(credentials);
}
return result;
}
代码示例来源:origin: io.devcon5.timeseries/ts-collector
@Override
public void start() throws Exception {
JsonObject config = config();
this.http = vertx.createHttpClient(new HttpClientOptions(config));
if(config.containsKey("dbnames")){
config.getJsonArray("dbnames").forEach(dbname -> registerConsumer((String) dbname));
LOG.info("InfluxDB timeseries verticle started");
} else {
LOG.warn("No InfluxDB name configured");
}
}
代码示例来源:origin: io.vertx/vertx-consul-client
/**
* Constructor from JSON
*
* @param json the JSON
*/
public TxnResponse(JsonObject json) {
if (json.getValue("Results") instanceof JsonArray) {
json.getJsonArray("Results").forEach(entry -> {
JsonObject obj = (JsonObject) entry;
if (obj.containsKey("KV")) {
results.add(new KeyValue(obj.getJsonObject("KV")));
}
});
}
if (json.getValue("Errors") instanceof JsonArray) {
json.getJsonArray("Errors").forEach(entry -> errors.add(new TxnError((JsonObject) entry)));
}
}
代码示例来源:origin: wang007/vertx-start
private static List handleList(JsonArray array) {
array.forEach(v -> {
if (v instanceof Map) {
throw new UnsupportedOperationException("unsupported map, but support json");
} else if (v instanceof List) {
throw new UnsupportedOperationException("unsupported list, but support jsonArray");
}
CheckUtil.checkAndCopy(v, false);
if (v instanceof JsonObject) {
CollectionUtils.wrapToImmutable((JsonObject) v);
} else if (v instanceof JsonArray) {
CollectionUtils.wrapToImmutable((JsonArray) v);
}
});
List list = array.getList();
CollectionUtils.wrapToImmutable(array);
return list;
}
代码示例来源:origin: io.vertx/vertx-codetrans
public static List<Object> fromJsonArray(JsonConverter converter, JsonArray arr) {
List<Object> m = new ArrayList<>();
arr.forEach( value -> {
if (value instanceof JsonObject) {
m.add(fromJsonObject(converter, (JsonObject) value));
} else if (value instanceof JsonArray) {
m.add(fromJsonArray(converter, (JsonArray) value));
} else {
m.add(value);
}
});
return m;
}
}
代码示例来源:origin: com.progressoft.brix.domino/vertx-domino-event-bus-backend
private SockJSHandler configureSockJsHandler(VertxContext vertxContext, BridgeOptions bridgeOptions,
JsonObject config) {
SockJSHandler sockJSHandler = SockJSHandler.create(vertxContext.vertx());
sockJSHandler.bridge(bridgeOptions, event -> event.complete(true));
JsonArray jsonArray=config.getJsonArray(ALLOWED_ORIGINS);
sockJSHandler.socketHandler(event -> jsonArray.forEach(o -> event.headers().set(ACCESS_CONTROL_ALLOW_ORIGIN, (String)o)));
return sockJSHandler;
}
代码示例来源:origin: io.knotx.acme/acme-forms-adapter-http
public static void fromJson(JsonObject json, HttpFormsAdapterOptions obj) {
if (json.getValue("address") instanceof String) {
obj.setAddress((String)json.getValue("address"));
}
if (json.getValue("clientOptions") instanceof JsonObject) {
obj.setClientOptions(new io.vertx.ext.web.client.WebClientOptions((JsonObject)json.getValue("clientOptions")));
}
if (json.getValue("customHttpHeader") instanceof JsonObject) {
obj.setCustomHttpHeader(new io.knotx.configuration.CustomHttpHeader((JsonObject)json.getValue("customHttpHeader")));
}
if (json.getValue("services") instanceof JsonArray) {
java.util.ArrayList<com.acme.forms.adapter.http.common.configuration.HttpFormsSettings> list = new java.util.ArrayList<>();
json.getJsonArray("services").forEach( item -> {
if (item instanceof JsonObject)
list.add(new com.acme.forms.adapter.http.common.configuration.HttpFormsSettings((JsonObject)item));
});
obj.setServices(list);
}
}
代码示例来源:origin: io.knotx/knotx-core
public static void fromJson(JsonObject json, KnotContext obj) {
if (json.getValue("clientRequest") instanceof JsonObject) {
obj.setClientRequest(new io.knotx.dataobjects.ClientRequest((JsonObject)json.getValue("clientRequest")));
}
if (json.getValue("clientResponse") instanceof JsonObject) {
obj.setClientResponse(new io.knotx.dataobjects.ClientResponse((JsonObject)json.getValue("clientResponse")));
}
if (json.getValue("fragments") instanceof JsonArray) {
java.util.ArrayList<io.knotx.dataobjects.Fragment> list = new java.util.ArrayList<>();
json.getJsonArray("fragments").forEach( item -> {
if (item instanceof JsonObject)
list.add(new io.knotx.dataobjects.Fragment((JsonObject)item));
});
obj.setFragments(list);
}
if (json.getValue("transition") instanceof String) {
obj.setTransition((String)json.getValue("transition"));
}
}
内容来源于网络,如有侵权,请联系作者删除!