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:edu.pitt.dbmi.ccd.anno.group.GroupController.java
/** * Get group mods/*from ww w .jav a 2 s. c o m*/ * * @param id group id * @return mods */ @RequestMapping(value = GroupLinks.MODS, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody public PagedResources<UserResource> mods(@AuthenticationPrincipal UserAccountDetails principal, @PathVariable Long id, @PageableDefault(size = 20, sort = { "username" }) Pageable pageable) throws NotFoundException { final UserAccount requester = principal.getUserAccount(); final Group group = groupService.findById(id); if (group == null) { throw new GroupNotFoundException(id); } if (Stream.concat(group.getMembers().stream(), group.getModerators().stream()).map(UserAccount::getId) .anyMatch(u -> u.equals(requester.getId()))) { final Page<UserAccount> page = userService.findByGroupModeration(group, pageable); final PagedResources<UserResource> pagedResources = userPageAssembler.toResource(page, userAssembler, request); return pagedResources; } else { throw new ForbiddenException(requester, request); } }
From source file:org.bsc.confluence.rest.AbstractRESTConfluenceService.java
protected List<JsonObject> rxDescendantPages(final String id) { final HttpUrl url = urlBuilder().addPathSegment("content").addPathSegment(id) //.addPathSegments("descendant/page") .addPathSegments("child/page").addQueryParameter("expand", EXPAND).build(); return fromUrlGET(url, "get descendant pages").flatMap(this::mapToStream).flatMap((JsonObject o) -> { final String childId = o.getString("id"); return Stream.concat(Stream.of(o), rxDescendantPages(childId).stream()); }).collect(Collectors.toList()); }
From source file:enumj.StreamComparator.java
private Pair<Function<Stream<T>, Stream<T>>, Function<E, E>> getConcatFuns() { rndSpin();/*from w w w .j a v a2 s . c om*/ final StreamComparator<T, E> sub = subComparator(new Random(rnd.nextInt()), depth - 1, length); sub.statistics = statistics; sub.build(); rndSpin(); final Function<Stream<T>, Stream<T>> lhs = s -> Stream.concat(s.limit(length / 2), sub.lhs.skip(length / 2)); final Function<E, E> rhs = e -> concat(limit(e, length / 2), skip(sub.rhs, length / 2)); if (statistics != null) { statistics.concat(); } return Pair.of(lhs, rhs); }
From source file:com.francetelecom.clara.cloud.techmodel.cf.App.java
public List<String> getServiceNames() { return Stream .concat(userProvidedServices.stream().map(AbstractUserProvidedService::getServiceName), managedServices.stream().map(ManagedService::getServiceInstance)) .collect(Collectors.toList()); }
From source file:com.wormsim.animals.AnimalStage2.java
@Override public String toRecentPotentialScaleReductionString() { 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.toRecentPotentialScaleReductionString()) .collect(Utils.TAB_JOINING); }
From source file:org.lightjason.agentspeak.language.CCommon.java
/** * instantiate a plan with context and plan-specific variables * * @param p_plan plan/*from w w w . j ava2 s. c o m*/ * @param p_fail fail runs * @param p_success successful runs * @param p_agent agent * @param p_variables instantiated variables * @return pair of plan and context object */ public static Pair<IPlan, IContext> instantiateplan(final IPlan p_plan, final double p_fail, final double p_success, final IAgent<?> p_agent, final Set<IVariable<?>> p_variables) { final double l_sum = p_success + p_fail; return new ImmutablePair<>(p_plan, p_plan.instantiate(p_agent, Stream.concat(p_variables.stream(), Stream.of( // execution count new CConstant<>("PlanSuccessful", p_success), new CConstant<>("PlanFail", p_fail), new CConstant<>("PlanRuns", l_sum), // execution ratio new CConstant<>("PlanSuccessfulRatio", l_sum == 0 ? 0 : p_success / l_sum), new CConstant<>("PlanFailRatio", l_sum == 0 ? 0 : p_fail / l_sum))))); }
From source file:org.codice.ddf.configuration.migration.ImportMigrationManagerImplTest.java
@Test public void testConstructorWithAdditionalMigratable() throws Exception { final Migratable migratable4 = Mockito.mock(Migratable.class); initMigratableMock(migratable4, "test-migratable-4"); mgr = new ImportMigrationManagerImpl(report, exportFile, Stream.concat(Stream.of(migratables), Stream.of(migratable4)), zip); Assert.assertThat(mgr.getReport(), Matchers.sameInstance(report)); Assert.assertThat(mgr.getExportFile(), Matchers.sameInstance(exportFile)); Assert.assertThat(/*from w ww .j a v a2 s . c o m*/ mgr.getContexts().stream().map(ImportMigrationContextImpl::getMigratable) .toArray(Migratable[]::new), Matchers.arrayContaining(Matchers.sameInstance(migratable), Matchers.sameInstance(migratable2), Matchers.sameInstance(migratable3), Matchers.sameInstance(migratable4), Matchers.nullValue())); // null correspond to the system context }
From source file:com.carlomicieli.jtrains.value.objects.DeliveryDate.java
/** * Returns the list of {@code DeliveryDate}. * <p>/*from ww w . j a v a2s . c o m*/ * This methods provides two different years ranges: * <ul> * <li>since {@code endYearWithQuarters} back to {@code startYearWithQuarters} * the years are listed with quarter information; * <li>since {@code endYearWithoutQuarters} back to {@code startYearWithoutQuarters} * the years are listed without quarter information. * </ul> * </p> * * @param startYearWithoutQuarters the first year without quarters * @param endYearWithoutQuarters the last year without quarters * @param startYearWithQuarters the first year with quarters * @param endYearWithQuarters the last year with quarters * @return the {@code DeliveryDate} list */ public static Stream<DeliveryDate> range(int startYearWithoutQuarters, int endYearWithoutQuarters, int startYearWithQuarters, int endYearWithQuarters) { Assert.isTrue(startYearWithoutQuarters <= endYearWithoutQuarters, "DeliveryDate: startYearWithoutQuarters <= endYearWithoutQuarters"); Assert.isTrue(startYearWithQuarters <= endYearWithQuarters, "DeliveryDate: startYearWithQuarters <= endYearWithQuarters"); Function<Integer, Stream<DeliveryDate>> deliveryDatesForYear = year -> quarters() .mapToObj(qtr -> DeliveryDate.of(year, qtr)); return Stream.concat( IntStream.rangeClosed(startYearWithQuarters, endYearWithQuarters).boxed() .flatMap(deliveryDatesForYear), IntStream.rangeClosed(startYearWithoutQuarters, endYearWithoutQuarters).mapToObj(DeliveryDate::of)) .sorted(deliveryDateComparator().reversed()); }
From source file:org.apache.tinkerpop.gremlin.structure.util.star.StarGraph.java
@Override public Iterator<Edge> edges(final Object... edgeIds) { return null == this.starVertex ? Collections.emptyIterator() : Stream.concat( null == this.starVertex.inEdges ? Stream.empty() : this.starVertex.inEdges.values().stream(), null == this.starVertex.outEdges ? Stream.empty() : this.starVertex.outEdges.values().stream()) .flatMap(List::stream).filter(edge -> { // todo: kinda fishy - need to better nail down how stuff should work here - none of these feel consistent right now. if (edgeIds.length > 0 && edgeIds[0] instanceof Edge) return ElementHelper.idExists(edge.id(), Stream.of(edgeIds).map(e -> ((Edge) e).id()).toArray()); else return ElementHelper.idExists(edge.id(), edgeIds); }).iterator();/*from ww w. j ava 2 s. co m*/ }
From source file:com.thinkbiganalytics.auth.jwt.JwtRememberMeServices.java
/** * Sets a JWT cookie when the user has successfully logged in. * * @param request the HTTP request * @param response the HTTP response * @param authentication the user/* www . ja va2 s .c om*/ */ @Override protected void onLoginSuccess(@Nonnull final HttpServletRequest request, @Nonnull final HttpServletResponse response, @Nonnull final Authentication authentication) { final Stream<String> user = Stream.of(authentication.getPrincipal().toString()); final Stream<String> groups = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority); final String[] tokens = Stream.concat(user, groups).toArray(String[]::new); setCookie(tokens, getTokenValiditySeconds(), request, response); }