Search in sources :

Example 76 with Collections

use of java.util.Collections in project coffeenet-starter by coffeenet.

the class CoffeeNetNavigationServiceImpl method get.

@Override
public CoffeeNetNavigationInformation get() {
    CurrentCoffeeNetUser currentCoffeeNetUser = dataExtractor.extractUser().orElse(null);
    CoffeeNetNavigationAppInformation appInformation = dataExtractor.extractAppInformation().orElse(null);
    Map<String, List<CoffeeNetApp>> apps = dataExtractor.extractApps().orElseGet(Collections::emptyMap);
    String logoutPath = dataExtractor.extractLogoutPath();
    List<CoffeeNetApp> profileApps = apps.get("profile");
    CoffeeNetApp profileApp = null;
    if (profileApps != null && !profileApps.isEmpty()) {
        profileApp = profileApps.get(0);
    }
    List<CoffeeNetApp> coffeeNetApps = apps.get("apps");
    return new CoffeeNetNavigationInformation(currentCoffeeNetUser, coffeeNetApps, profileApp, logoutPath, appInformation);
}
Also used : List(java.util.List) CoffeeNetApp(rocks.coffeenet.autoconfigure.discovery.service.CoffeeNetApp) Collections(java.util.Collections)

Example 77 with Collections

use of java.util.Collections in project spring-boot by spring-projects.

the class LoggingApplicationListener method setLogLevels.

/**
 * Set logging levels based on relevant {@link Environment} properties.
 * @param system the logging system
 * @param environment the environment
 * @since 2.2.0
 */
protected void setLogLevels(LoggingSystem system, ConfigurableEnvironment environment) {
    BiConsumer<String, LogLevel> customizer = getLogLevelConfigurer(system);
    Binder binder = Binder.get(environment);
    Map<String, LogLevel> levels = binder.bind(LOGGING_LEVEL, STRING_LOGLEVEL_MAP).orElseGet(Collections::emptyMap);
    levels.forEach((name, level) -> configureLogLevel(name, level, customizer));
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) Collections(java.util.Collections) LogLevel(org.springframework.boot.logging.LogLevel)

Example 78 with Collections

use of java.util.Collections in project spring-boot by spring-projects.

the class LayersIndex method writeTo.

/**
 * Write the layer index to an output stream.
 * @param out the destination stream
 * @throws IOException on IO error
 */
public void writeTo(OutputStream out) throws IOException {
    MultiValueMap<Layer, String> index = new LinkedMultiValueMap<>();
    this.root.buildIndex("", index);
    index.values().forEach(Collections::sort);
    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8));
    for (Layer layer : this.layers) {
        List<String> names = index.get(layer);
        writer.write("- \"" + layer + "\":\n");
        if (names != null) {
            for (String name : names) {
                writer.write("  - \"" + name + "\"\n");
            }
        }
    }
    writer.flush();
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) OutputStreamWriter(java.io.OutputStreamWriter) Collections(java.util.Collections) BufferedWriter(java.io.BufferedWriter)

Example 79 with Collections

use of java.util.Collections in project sonarqube by SonarSource.

the class SearchAction method doIndexSearch.

private SearchResponse doIndexSearch(WsRequest wsRequest, DbSession dbSession, @Nullable ComponentDto project) {
    var builder = IssueQuery.builder().types(singleton(RuleType.SECURITY_HOTSPOT.name())).sort(IssueQuery.SORT_HOTSPOTS).asc(true).statuses(wsRequest.getStatus().map(Collections::singletonList).orElse(STATUSES));
    if (project != null) {
        String projectUuid = firstNonNull(project.getMainBranchProjectUuid(), project.uuid());
        if (Qualifiers.APP.equals(project.qualifier())) {
            builder.viewUuids(singletonList(projectUuid));
            if (wsRequest.isSinceLeakPeriod() && wsRequest.getPullRequest().isEmpty()) {
                addSinceLeakPeriodFilterByProjects(builder, dbSession, project);
            }
        } else {
            builder.projectUuids(singletonList(projectUuid));
            if (wsRequest.isSinceLeakPeriod() && wsRequest.getPullRequest().isEmpty()) {
                addSinceLeakPeriodFilter(dbSession, project, builder);
            }
        }
        addMainBranchFilter(project, builder);
    }
    if (!wsRequest.getHotspotKeys().isEmpty()) {
        builder.issueKeys(wsRequest.getHotspotKeys());
    }
    if (!wsRequest.getFiles().isEmpty()) {
        builder.files(wsRequest.getFiles());
    }
    if (wsRequest.isOnlyMine()) {
        userSession.checkLoggedIn();
        builder.assigneeUuids(Collections.singletonList(userSession.getUuid()));
    }
    wsRequest.getStatus().ifPresent(status -> builder.resolved(STATUS_REVIEWED.equals(status)));
    wsRequest.getResolution().ifPresent(resolution -> builder.resolutions(singleton(resolution)));
    addSecurityStandardFilters(wsRequest, builder);
    IssueQuery query = builder.build();
    SearchOptions searchOptions = new SearchOptions().setPage(wsRequest.page, wsRequest.index);
    return issueIndex.search(query, searchOptions);
}
Also used : IssueQuery(org.sonar.server.issue.index.IssueQuery) SearchOptions(org.sonar.server.es.SearchOptions) Collections(java.util.Collections)

Example 80 with Collections

use of java.util.Collections in project cayenne by apache.

the class FileProjectSaverTest method setUp.

@Before
public void setUp() throws Exception {
    Module testModule = binder -> binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
    saver = new FileProjectSaver(Collections.<ProjectExtension>emptyList());
    Injector injector = DIBootstrap.createInjector(testModule);
    injector.injectMembers(saver);
}
Also used : Injector(org.apache.cayenne.di.Injector) Arrays(java.util.Arrays) Project2Case(org.apache.cayenne.project.unit.Project2Case) XPath(javax.xml.xpath.XPath) XPathConstants(javax.xml.xpath.XPathConstants) URL(java.net.URL) ConfigurationNameMapper(org.apache.cayenne.configuration.ConfigurationNameMapper) Module(org.apache.cayenne.di.Module) DefaultConfigurationNameMapper(org.apache.cayenne.configuration.DefaultConfigurationNameMapper) Document(org.w3c.dom.Document) ConfigurationTree(org.apache.cayenne.configuration.ConfigurationTree) DIBootstrap(org.apache.cayenne.di.DIBootstrap) ProjectExtension(org.apache.cayenne.project.extension.ProjectExtension) Before(org.junit.Before) URLResource(org.apache.cayenne.resource.URLResource) NodeList(org.w3c.dom.NodeList) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) File(java.io.File) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) XPathFactory(javax.xml.xpath.XPathFactory) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) DataMap(org.apache.cayenne.map.DataMap) ConfigurationNameMapper(org.apache.cayenne.configuration.ConfigurationNameMapper) DefaultConfigurationNameMapper(org.apache.cayenne.configuration.DefaultConfigurationNameMapper) ProjectExtension(org.apache.cayenne.project.extension.ProjectExtension) Injector(org.apache.cayenne.di.Injector) Module(org.apache.cayenne.di.Module) Before(org.junit.Before)

Aggregations

Collections (java.util.Collections)113 List (java.util.List)59 ArrayList (java.util.ArrayList)41 Test (org.junit.Test)39 Map (java.util.Map)37 Collectors (java.util.stream.Collectors)34 Arrays (java.util.Arrays)28 HashMap (java.util.HashMap)26 Set (java.util.Set)25 HashSet (java.util.HashSet)23 IOException (java.io.IOException)19 Collection (java.util.Collection)19 Optional (java.util.Optional)19 TimeUnit (java.util.concurrent.TimeUnit)16 URI (java.net.URI)13 Assert (org.junit.Assert)13 Function (java.util.function.Function)12 Stream (java.util.stream.Stream)12 Before (org.junit.Before)12 Logger (org.slf4j.Logger)12