You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lécharny (Jira)" <ji...@apache.org> on 2020/06/22 12:54:00 UTC
[jira] [Commented] (DIRAPI-360) add stream convenient methods to
class Attribute
[ https://issues.apache.org/jira/browse/DIRAPI-360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17142018#comment-17142018 ]
Emmanuel Lécharny commented on DIRAPI-360:
------------------------------------------
Assuming you want to gather all the values for an attribute that has many values, you can already do something like :
{code:java}
Set<Dn> dns = new HashSet<>();
attribute.iterator().forEachRemaining( dn -> dns.add( LDAPUtil.getDn(dn ) ));
return dns;
{code}
(sort of, I have not tested this code. There may be even more efficient ways to do that...)
> 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: dev-unsubscribe@directory.apache.org
For additional commands, e-mail: dev-help@directory.apache.org