Example usage for java.util Set forEach

List of usage examples for java.util Set forEach

Introduction

In this page you can find the example usage for java.util Set forEach.

Prototype

default void forEach(Consumer<? super T> action) 

Source Link

Document

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

Usage

From source file:edu.kit.dama.ui.admin.wizard.BaseMetadataExtractionAndIndexingCreation.java

@Override
public String getSummary() {
    StringBuilder result = new StringBuilder();
    result.append(getStepName()).append("\n");
    result.append(StringUtils.rightPad("", 50, "_")).append("\n");

    if (createMetsExtractor.getValue()) {
        result.append("Create METS Extractor: ").append((createMetsExtractor.getValue()) ? "yes\n" : "no\n");
        Set<Entry<String, TextField>> entries = extractorProperties.entrySet();
        result.append("Properties:\n");
        entries.forEach((entry) -> {
            result.append(entry.getKey()).append(": ").append(entry.getValue().getValue()).append("\n");
        });/* ww w.  j a va2s.  c o  m*/
    } else {
        result.append("No metadata extractor will be created.\n");
    }

    return result.toString();
}

From source file:org.onosproject.segmentrouting.cli.McastNextListCommand.java

@Override
protected void execute() {
    // Verify mcast group
    IpAddress mcastGroup = null;/*from   w w  w.j  av  a  2  s. com*/
    if (!isNullOrEmpty(gAddr)) {
        mcastGroup = IpAddress.valueOf(gAddr);
    }
    // Get SR service
    SegmentRoutingService srService = get(SegmentRoutingService.class);
    // Get the mapping
    Map<McastStoreKey, Integer> keyToNextId = srService.getMcastNextIds(mcastGroup);
    // Reduce to the set of mcast groups
    Set<IpAddress> mcastGroups = keyToNextId.keySet().stream().map(McastStoreKey::mcastIp)
            .collect(Collectors.toSet());
    // Print the nextids for each group
    mcastGroups.forEach(group -> {
        // Create a new map for the group
        Map<Pair<DeviceId, VlanId>, Integer> deviceIdNextMap = Maps.newHashMap();
        keyToNextId.entrySet().stream()
                // Filter only the elements related to this group
                .filter(entry -> entry.getKey().mcastIp().equals(group))
                // For each create a new entry in the group related map
                .forEach(entry -> deviceIdNextMap
                        .put(Pair.of(entry.getKey().deviceId(), entry.getKey().vlanId()), entry.getValue()));
        // Print the map
        printMcastNext(group, deviceIdNextMap);
    });
}

From source file:org.moserp.RestConfiguration.java

@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
            true);//from   w  w  w .  jav  a 2s .  c  om
    provider.addIncludeFilter(new AssignableTypeFilter(IdentifiableEntity.class));
    Set<BeanDefinition> components = provider.findCandidateComponents(this.getClass().getPackage().getName());
    List<Class<?>> classes = new ArrayList<>();

    components.forEach(component -> {
        try {
            classes.add(Class.forName(component.getBeanClassName()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    });

    config.exposeIdsFor(classes.toArray(new Class[classes.size()]));
}

From source file:se.uu.it.cs.recsys.dataloader.impl.FuturePlannedCourseLoader.java

private void writeMappingInfo(Integer courseId, Course course) {

    Set<se.uu.it.cs.recsys.api.type.ComputingDomain> relatedDomains = course.getRelatedDomain();

    relatedDomains.forEach(relatedDomain -> {
        CourseDomainRelevance newEntry = new CourseDomainRelevance(
                new CourseDomainRelevancePK(courseId, relatedDomain.getId()));

        this.courseDomainRelevanceRepository.save(newEntry);
    });// ww w  . j  a  va 2  s.c  om

}

From source file:cc.kave.commons.model.groum.Groum.java

public Groum(String methodSignature, Set<Node> nodes, Set<Pair<Node, Node>> edges) {
    this.methodSignature = methodSignature;
    groum = new DefaultDirectedGraph<Node, LabelledEdge>(LabelledEdge.class);
    nodes.forEach(node -> groum.addVertex(node));
    edges.forEach(edge -> groum.addEdge(edge.getLeft(), edge.getRight()));
}

From source file:se.uu.it.cs.recsys.service.resource.FrequenPatternResource.java

private Map<Set<Course>, Integer> convertToCourse(Map<Set<Integer>, Integer> patterns) {

    Map<Set<Course>, Integer> output = new HashMap<>();

    patterns.forEach((k, v) -> {/*from   w w w  . j  a v  a2 s.co  m*/
        Set<se.uu.it.cs.recsys.persistence.entity.Course> courses = this.courseRepository.findByAutoGenIds(k);

        Set<Course> apiCourses = new HashSet<>();

        courses.forEach(entity -> apiCourses.add(CourseConverter.convert(entity)));

        output.put(apiCourses, v);

    });

    return output;
}

From source file:org.onosproject.vpls.Vpls.java

private void bindMacAddr(Map.Entry<VlanId, ConnectPoint> e,
        SetMultimap<VlanId, Pair<ConnectPoint, MacAddress>> confHostPresentCPoint) {
    VlanId vlanId = e.getKey();// w  w  w .  j a  v a 2s.  c om
    ConnectPoint cp = e.getValue();
    Set<Host> connectedHosts = hostService.getConnectedHosts(cp);
    connectedHosts.forEach(host -> {
        if (host.vlan().equals(vlanId)) {
            confHostPresentCPoint.put(vlanId, Pair.of(cp, host.mac()));
        } else {
            confHostPresentCPoint.put(vlanId, Pair.of(cp, null));
        }
    });
    if (connectedHosts.isEmpty()) {
        confHostPresentCPoint.put(vlanId, Pair.of(cp, null));
    }
}

From source file:com.rockagen.gnext.service.spring.security.extension.ExAuthenticationProvider.java

/**
 * Create a new {@link org.springframework.security.core.userdetails.UserDetails} by uid
 *
 * @param uid         uid//from   w  w w. ja va 2s. c  o  m
 * @param credentials Credentials(always was password)
 * @return {@link org.springframework.security.core.userdetails.UserDetails}
 * @throws org.springframework.security.authentication.BadCredentialsException if credentials invalid
 */
private UserDetails loadUser(String uid, String credentials) {

    // Not empty
    if (CommUtil.isBlank(uid) || CommUtil.isBlank(credentials)) {
        throw new BadCredentialsException(messages
                .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
    }

    // Load user
    Optional<AuthUser> u = authUserServ.load(uid);

    if (u.filter(x -> x.enabled()).isPresent()) {
        AuthUser user = u.get();
        // Check credentials
        checkCredentials(user.getPassword(), credentials, user.getSalt());

        // After authenticated handler
        afterAuthenticatedHandler(user);

        List<GrantedAuthority> authorities = new LinkedList<>();
        Set<AuthGroup> groups = user.getGroups();
        if (groups != null && groups.size() > 0) {
            groups.forEach(x -> x.getRoles()
                    .forEach(y -> authorities.add(new SimpleGrantedAuthority(y.getName().trim()))));
        }
        return new User(user.getUid(), user.getPassword(), true, true, true, true, authorities);

    } else {
        throw new UsernameNotFoundException(
                messages.getMessage("", new Object[] { uid }, "User {0} has no GrantedAuthority"));
    }

}

From source file:com.rockagen.gnext.service.spring.security.extension.ExFilterInvocationSecurityMetadataSource.java

private Map<RequestMatcher, Collection<ConfigAttribute>> processMap() {

    Map<RequestMatcher, Collection<ConfigAttribute>> requestToExpressionAttributesMap = new LinkedHashMap<>();

    List<AuthResource> resources = authResourceServ.findAll();

    if (resources != null && resources.size() > 0) {
        // Sort by priority
        // Jdk8 only
        resources.stream().sorted((a, b) -> a.getPriority().compareTo(b.getPriority())).forEach(x -> {

            RequestMatcher request = new RegexRequestMatcher(x.getPath(), null);
            Set<AuthRole> roles = x.getRoles();
            List<ConfigAttribute> attrs = new ArrayList<>(roles.size());
            roles.forEach(y -> attrs.add(new SecurityConfig(y.getName().trim())));

            requestToExpressionAttributesMap.put(request, attrs);

        });// w  w  w.  j  a va  2 s  . c  o m

    }
    return requestToExpressionAttributesMap;
}

From source file:io.mapzone.arena.ArenaPlugin.java

protected void testMBeanConnection() throws Exception {
    // test connection
    String port = System.getProperty("com.sun.management.jmxremote.port");
    if (port != null) {
        String url = "service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi";
        JMXServiceURL serviceUrl = new JMXServiceURL(url);
        try (JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceUrl, null);) {
            MBeanServerConnection conn = jmxConnector.getMBeanServerConnection();
            Set<ObjectName> beanSet = conn.queryNames(null, null);
            beanSet.forEach(n -> log.debug("    MBean: " + n));

            beanSet = conn.queryNames(ArenaConfigMBean.NAME.get(), null);
            beanSet.forEach(n -> log.debug("    MBean: " + n));

            ArenaConfigMBean arenaConfig = JMX.newMBeanProxy(conn, ArenaConfigMBean.NAME.get(),
                    ArenaConfigMBean.class);
            arenaConfig.setAppTitle("Arena");
        }//from w ww  .  j a v a2s  .  co m
    } else {
        log.info("No jmxremote.port specified.");
    }
}