List of usage examples for java.util.stream Stream concat
public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b)
From source file:com.thinkbiganalytics.auth.jwt.JwtRememberMeServices.java
/** * Decodes the specified JWT cookie into tokens. * * <p>The first element of the return value with be the JWT subject. The remaining elements are the elements in the {@code groups} list.</p> * * @param cookie the JWT cookie/*from w w w .java 2s . c om*/ * @return an array with the username and group names * @throws IllegalStateException if the secret key is invalid * @throws InvalidCookieException if the cookie cannot be decoded */ @Nonnull @Override protected String[] decodeCookie(@Nonnull final String cookie) throws InvalidCookieException { // Build the JWT parser final JwtConsumer consumer = new JwtConsumerBuilder() .setEvaluationTime(NumericDate.fromMilliseconds(DateTimeUtils.currentTimeMillis())) .setVerificationKey(getSecretKey()).build(); // Parse the cookie final String user; final List<String> groups; try { final JwtClaims claims = consumer.processToClaims(cookie); user = claims.getSubject(); groups = claims.getStringListClaimValue(GROUPS); } catch (final InvalidJwtException e) { throw new InvalidCookieException("JWT cookie is invalid: " + e); } catch (final MalformedClaimException e) { throw new InvalidCookieException("JWT cookie is malformed: " + cookie); } if (StringUtils.isBlank(user)) { throw new InvalidCookieException("Missing user in JWT cookie: " + cookie); } // Build the token array final Stream<String> userStream = Stream.of(user); final Stream<String> groupStream = groups.stream(); return Stream.concat(userStream, groupStream).toArray(String[]::new); }
From source file:com.wormsim.animals.AnimalStage2.java
@Override public String toVarianceString() { return Stream .concat(Stream.concat(Stream.concat(Stream.of(food_rate), Stream.of(pheromone_rates)), Stream.of(dev_time)), Stream.of(development)) .filter((v) -> v.isVisiblyTracked()).map((v) -> v.toVarianceString()).collect(Utils.TAB_JOINING); }
From source file:me.rkfg.xmpp.bot.plugins.CoolStoryPlugin.java
@Override public String getManual() { return Stream.concat(Stream.of(HELP_AVAILABLE_COMMANDS), Arrays.stream(WEBSITES).map(Website::getHelp)) .collect(Collectors.joining("\n")); }
From source file:org.obiba.mica.study.service.StudyService.java
public List<? extends EntityState> findAllStates(Iterable<String> ids) { return Stream.concat(individualStudyService.findAllStates(ids).stream(), harmonizationStudyService.findAllStates(ids).stream()).collect(Collectors.toList()); }
From source file:com.nestedbird.modules.sitemap.SitemapGenerator.java
@SafeVarargs private final Stream<String> concatStreams(final Stream<String>... streams) { if (streams.length == 0) throw new IllegalArgumentException("No stream provided"); Stream<String> currentStream = streams[0]; for (Integer i = 1; i < streams.length; i++) { currentStream = Stream.concat(currentStream, streams[i]); }// w ww . j av a2s . c om return currentStream; }
From source file:org.codice.ddf.catalog.plugin.metacard.util.MetacardServices.java
/** * Helper method to combine all system-recognized {@link AttributeDescriptor}s with any new ones * on the given list of {@link Metacard}s without repeats. * * @param metacards List of metacards whose attribute descriptors should be added to the map. * @return A map of all system-recognized descriptors plus any new ones introduced by the * metacards./* w w w . j av a 2s .c om*/ */ private Map<String, AttributeDescriptor> getUniqueSystemAndMetacardDescriptors(List<Metacard> metacards) { List<MetacardType> systemMetacardTypesCopy = ImmutableList.copyOf(systemMetacardTypes); return Stream .concat(systemMetacardTypesCopy.stream().map(MetacardType::getAttributeDescriptors) .flatMap(Set::stream).filter(Objects::nonNull), metacards.stream().map(Metacard::getMetacardType).map(MetacardType::getAttributeDescriptors) .flatMap(Set::stream).filter(Objects::nonNull)) .collect(Collectors.toMap(AttributeDescriptor::getName, Function.identity(), (oldValue, newValue) -> oldValue)); }
From source file:nl.salp.warcraft4j.dev.casc.dbc.DbcAnalyser.java
private Set<String> getAllDbcFilesByName() { LOGGER.debug("Getting all DBC files with a resolved name."); return Stream.concat(getCascResolvedDbcFilesByName().stream(), getListFileDbcFilesByName().stream()) .filter(StringUtils::isNotEmpty).distinct().collect(Collectors.toSet()); }
From source file:org.springframework.cloud.dataflow.server.service.impl.TaskAppDeploymentRequestCreator.java
private List<String> updateCommandLineArgs(List<String> commandLineArgs, TaskExecution taskExecution) { return Stream .concat(commandLineArgs.stream().filter(a -> !a.startsWith("--spring.cloud.task.executionid=")), Stream.of("--spring.cloud.task.executionid=" + taskExecution.getExecutionId())) .collect(Collectors.toList()); }
From source file:com.wormsim.animals.AnimalStage2.java
@Override public String toWithinVarianceString() { return Stream .concat(Stream.concat(Stream.concat(Stream.of(food_rate), Stream.of(pheromone_rates)), Stream.of(dev_time)), Stream.of(development)) .filter((v) -> v.isVisiblyTracked()).map((v) -> v.toWithinVarianceString()) .collect(Utils.TAB_JOINING); }
From source file:com.thinkbiganalytics.security.rest.controller.AccessControlController.java
@GET @Path("{name}/allowed") @Produces(MediaType.APPLICATION_JSON)//from w w w.ja va2 s . com @ApiOperation("Gets the list of allowed actions for a principal.") @ApiResponses({ @ApiResponse(code = 200, message = "Returns the actions.", response = ActionGroup.class), @ApiResponse(code = 404, message = "The given name was not found.", response = RestResponseStatus.class) }) public ActionGroup getAllowedActions(@PathParam("name") String moduleName, @QueryParam("user") Set<String> userNames, @QueryParam("group") Set<String> groupNames) { Set<? extends Principal> users = Arrays.stream(this.actionsTransform.asUserPrincipals(userNames)) .collect(Collectors.toSet()); Set<? extends Principal> groups = Arrays.stream(this.actionsTransform.asGroupPrincipals(groupNames)) .collect(Collectors.toSet()); Principal[] principals = Stream.concat(users.stream(), groups.stream()).toArray(Principal[]::new); // Retrieve the allowed actions by executing the query as the specified user/groups return metadata.read(() -> { return actionsProvider.getAllowedActions(moduleName) .map(this.actionsTransform.toActionGroup(AllowedActions.SERVICES)) .orElseThrow(() -> new WebApplicationException("The available service actions were not found", Status.NOT_FOUND)); }, principals); }