Source:
<code>public Response getDatabaseSegments( @Context final HttpServletRequest req, @QueryParam("datasources") final Set<String> datasources, @QueryParam("includeOvershadowedStatus") final String includeOvershadowedStatus ) { Collection<ImmutableDruidDataSource> druidDataSources = metadataSegmentManager.getDataSources(); if (datasources != null && !datasources.isEmpty()) { druidDataSources = druidDataSources.stream() .filter(src -> datasources.contains(src.getName())) .collect(Collectors.toSet()); } final Stream<DataSegment> metadataSegments = druidDataSources .stream() .flatMap(t -> t.getSegments().stream()); if (includeOvershadowedStatus != null) { final Set<SegmentId> overshadowedSegments = findOvershadowedSegments(druidDataSources); final Stream<SegmentWithOvershadowedStatus> segmentsWithOvershadowedStatus = metadataSegments.map(segment -> { <START> if (overshadowedSegments.contains(segment.getId())) { <END> return new SegmentWithOvershadowedStatus(segment, true); } else { return new SegmentWithOvershadowedStatus(segment, false); } }).collect(Collectors.toList()).stream(); final Function<SegmentWithOvershadowedStatus, Iterable<ResourceAction>> raGenerator = segment -> Collections.singletonList( AuthorizationUtils.DATASOURCE_READ_RA_GENERATOR.apply(segment.getDataSegment().getDataSource())); final Iterable<SegmentWithOvershadowedStatus> authorizedSegments = AuthorizationUtils.filterAuthorizedResources( req, segmentsWithOvershadowedStatus::iterator, raGenerator, authorizerMapper ); Response.ResponseBuilder builder = Response.status(Response.Status.OK); return builder.entity(authorizedSegments).build(); } else { final Function<DataSegment, Iterable<ResourceAction>> raGenerator = segment -> Collections.singletonList( AuthorizationUtils.DATASOURCE_READ_RA_GENERATOR.apply(segment.getDataSource())); final Iterable<DataSegment> authorizedSegments = AuthorizationUtils.filterAuthorizedResources(req, metadataSegments::iterator, raGenerator, authorizerMapper); Response.ResponseBuilder builder = Response.status(Response.Status.OK); return builder.entity(authorizedSegments).build(); } }</code><technical_language>This block return new SegmentWithOvershadowedStatus( segment, overshadowedSegments.contains(segment.getId()) );</technical_language>

Target:
public Response getDatabaseSegments( @Context final HttpServletRequest req, @QueryParam("datasources") final Set<String> datasources, @QueryParam("includeOvershadowedStatus") final String includeOvershadowedStatus ) { Collection<ImmutableDruidDataSource> druidDataSources = Optional.ofNullable(metadataSegmentManager.getDataSources()) .orElse(Collections.emptyList()); Stream<ImmutableDruidDataSource> dataSourceStream = druidDataSources.stream(); if (datasources != null && !datasources.isEmpty()) { dataSourceStream = dataSourceStream.filter(src -> datasources.contains(src.getName())); } final Stream<DataSegment> metadataSegments = dataSourceStream.flatMap(t -> t.getSegments().stream()); if (includeOvershadowedStatus != null) { final Iterable<SegmentWithOvershadowedStatus> authorizedSegments = findAuthorizedSegmentWithOvershadowedStatus( req, druidDataSources, metadataSegments ); Response.ResponseBuilder builder = Response.status(Response.Status.OK); return builder.entity(authorizedSegments).build(); } else { final Function<DataSegment, Iterable<ResourceAction>> raGenerator = segment -> Collections.singletonList( AuthorizationUtils.DATASOURCE_READ_RA_GENERATOR.apply(segment.getDataSource())); final Iterable<DataSegment> authorizedSegments = AuthorizationUtils.filterAuthorizedResources( req, metadataSegments::iterator, raGenerator, authorizerMapper ); Response.ResponseBuilder builder = Response.status(Response.Status.OK); return builder.entity(authorizedSegments).build(); } }