List of usage examples for io.vertx.core.json JsonObject stream
public Stream<Map.Entry<String, Object>> stream()
From source file:io.knotx.mocks.adapter.MockActionAdapterHandler.java
License:Apache License
private Pair<Optional<String>, JsonObject> getTransitionResult(ClientRequest request, JsonObject transitions) { return transitions.stream().filter(entry -> matchRequest(request, entry)).findFirst() .map(this::toTransitionPair).orElse(getErrorResponse()); }
From source file:io.knotx.mocks.adapter.MockActionAdapterHandler.java
License:Apache License
private boolean matchRequest(ClientRequest request, Map.Entry<String, Object> transition) { final JsonObject condition = ((JsonObject) transition.getValue()).getJsonObject("condition"); final MultiMap formAttributes = request.getFormAttributes(); return condition.stream().allMatch(entry -> formAttributes.contains(entry.getKey()) && formAttributes.get(entry.getKey()).matches(String.valueOf(entry.getValue()))); }
From source file:io.knotx.server.KnotxServerConfiguration.java
License:Apache License
private Map<String, RoutingEntry> parseOnTransition(JsonObject onTransition) { Map<String, RoutingEntry> transitions = Maps.newHashMap(); if (onTransition != null) { onTransition.stream().forEach( entry -> transitions.put(entry.getKey(), parseRoutingCriteria((JsonObject) entry.getValue()))); }/* w w w . jav a 2s . c o m*/ return transitions; }
From source file:io.knotx.util.MultiMapConverter.java
License:Apache License
/** * Converts JsonObject to MultiMap. It expects the JsonObject key, contains JsonArray with list of * String objects.<br>/* w ww. ja va2s . c om*/ * Each jsonObject key is converted into MultiMap "key", while JsonArray as List of String objects * for this velue. * * @param json - {@link JsonObject} to convert * @return - {@link MultiMap} created from {@link JsonObject} */ public static MultiMap fromJsonObject(JsonObject json) { MultiMap map = MultiMap.caseInsensitiveMultiMap(); json.stream().forEach(entry -> ((JsonArray) entry.getValue()).stream() .forEach(value -> map.add(entry.getKey(), (String) value))); return map; }
From source file:org.eclipse.hono.authorization.impl.InMemoryAuthorizationService.java
License:Open Source License
private void parsePermissions(final JsonObject permissionsObject) { permissionsObject.stream().filter(resources -> resources.getValue() instanceof JsonObject) .forEach(resources -> {// w ww . j av a 2 s .co m final ResourceIdentifier resourceIdentifier = getResourceIdentifier(resources); final JsonObject subjects = (JsonObject) resources.getValue(); subjects.stream().filter(subject -> subject.getValue() instanceof JsonArray) .forEach(subject -> { final JsonArray permissions = (JsonArray) subject.getValue(); addPermission(subject.getKey(), resourceIdentifier, toSet(permissions)); }); }); }
From source file:org.eclipse.hono.service.auth.impl.FileBasedAuthenticationService.java
License:Open Source License
private void parseRoles(final JsonObject rolesObject) { rolesObject.stream().filter(entry -> entry.getValue() instanceof JsonArray).forEach(entry -> { final String roleName = entry.getKey(); final JsonArray authSpecs = (JsonArray) entry.getValue(); log.debug("adding role [{}] with {} authorities", roleName, authSpecs.size()); roles.put(roleName, toAuthorities(authSpecs)); });//from w w w . j a v a 2 s . com }
From source file:org.eclipse.hono.service.auth.impl.FileBasedAuthenticationService.java
License:Open Source License
private void parseUsers(final JsonObject usersObject) { usersObject.stream().filter(entry -> entry.getValue() instanceof JsonObject).forEach(entry -> { final String authenticationId = entry.getKey(); final JsonObject userSpec = (JsonObject) entry.getValue(); log.debug("adding user [{}]", authenticationId); users.put(authenticationId, userSpec); });/*from w w w . ja v a 2 s.com*/ }