[ 
https://issues.apache.org/jira/browse/DIRAPI-360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17142407#comment-17142407
 ] 

Darth Bolek edited comment on DIRAPI-360 at 6/22/20, 8:57 PM:
--------------------------------------------------------------

What I was looking for (stream of values):
{code:java}
StreamSupport.stream(attribute.spliterator(), false)
{code}
{code:java}
Set<Dn> m = entry.getAttributes().stream()
                .filter(x -> group_fields.contains(x.getUpId()) )
                .flatMap(y -> StreamSupport.stream(y.spliterator(), false) )
                .map(c -> c.getString())
                .map(z -> LDAPUtil.getDn(z))
                .collect(Collectors.toSet());

{code}
BTW, your example works. The same way as my first example, except I used
{code:java}
attribute.forEach(...)
{code}
 

 

 


was (Author: darthbolek):
What I was looking for (stream of values):
{code:java}
StreamSupport.stream(attribute.spliterator(), false)
{code}
 
{code:java}
Set<Dn> m = entry.getAttributes().stream()
                .filter(x -> group_fields.contains(x.getUpId()) )
                .flatMap(y -> StreamSupport.stream(y.spliterator(), false) )
                .map(c -> c.getString())
                .map(z -> LDAPUtil.getDn(z))
                .collect(Collectors.toSet());

{code}
 

 

BTW, your example works. The same way as my first example, except I used

 
{code:java}
attribute.forEach(...)
{code}
 

 

 

> add stream convenient methods to class Attribute
> ------------------------------------------------
>
>                 Key: DIRAPI-360
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-360
>             Project: Directory Client API
>          Issue Type: Improvement
>    Affects Versions: 2.0.1
>            Reporter: Darth Bolek
>            Priority: Trivial
>
> When attribute has multiple values (groupOfUniqueNames -> uniqueMember) there 
> is no stream convenient way of processing all of the values.
>  
> what to do:
> add methods to class: org.apache.directory.api.ldap.model.entry.Attribute
> Collection<String> getStringValues()
> possibly also other methods with other/generic data types.
>  
> example:
> Before (that is right now):
>  
> {code:java}
> Set<Dn> m = entry.getAttributes().stream()
>               .filter(x -> group_fields.contains(x.getUpId()) )
>               .flatMap(y -> {
>                               Set<String> tmpSet = new HashSet<String>();
>                               y.forEach(z -> tmpSet.add(z.getString()));
>                               return tmpSet.stream();
>               } )
>               .map(z -> LDAPUtil.getDn(z))
>               .collect(Collectors.toSet());
> {code}
>  
> After:
> {code:java}
> Set<Dn> m = entry.getAttributes().stream()
>               .filter(x -> group_fields.contains(x.getUpId()) )
>               .flatMap(y -> y.getStringValues().stream() )
>                 .map(z -> LDAPUtil.getDn(z))
>               .collect(Collectors.toSet());
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to