public <ObjectType extends Identifiable> Map<String, ObjectType>
        asMap(List<Entry> entries, Function<Entry, ObjectType> mapper) {

        // Convert each entry to the corresponding Guacamole API object
        Map<String, ObjectType> objects = new HashMap<>(entries.size());
        for (Entry entry : entries) {

            ObjectType object = mapper.apply(entry);
            if (object == null) {
                logger.debug("Ignoring object \"{}\".", entry.getDn().toString());
                continue;
            }

            // Attempt to add object to map, warning if the object appears
            // to be a duplicate
            String identifier = object.getIdentifier();
            if (objects.putIfAbsent(identifier, object) != null)
                logger.warn("Multiple objects ambiguously map to the "
                        + "same identifier (\"{}\"). Ignoring \"{}\" as "
                        + "a duplicate.", identifier, entry.getDn().toString());

        }

        return objects;

    }
Converts a given list of LDAP entries to a {@link Map} of Guacamole
objects stored by their identifiers.

@param <ObjectType>
    The type of object to store within the {@link Map}.

@param entries
    A list of LDAP entries to convert to Guacamole objects.

@param mapper
    A mapping function which converts a given LDAP entry to its
    corresponding Guacamole object. If the LDAP entry cannot be
    converted, null should be returned.

@return
    A new {@link Map} containing Guacamole object versions of each of
    the given LDAP entries, where each object is stored within the
    {@link Map} under its corresponding identifier.
extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ObjectQueryService.java