private static Set<ObjectPermission> getPermissions(Collection<String> identifiers) {

        // Include one READ permission for each of the given identifiers
        Set<ObjectPermission> permissions = new HashSet<ObjectPermission>();
        for (String identifier : identifiers)
            permissions.add(new ObjectPermission(ObjectPermission.Type.READ, identifier));

        return permissions;

    }

    /**
     * Creates a new SharedObjectPermissionSet which grants read-only access to
     * the objects having the given identifiers. No other permissions are
     * granted.
     *
     * @param identifiers
     *     The identifiers of the objects for which READ access should be
     *     granted.
     */
    public SharedObjectPermissionSet(Collection<String> identifiers) {
        super(getPermissions(identifiers));
    }

}
private static Set < ObjectPermission > getPermissions ( Collection < String > identifiers ) { Set < ObjectPermission > permissions = new HashSet < ObjectPermission > ( ) ; for ( String identifier : identifiers ) permissions . add ( new ObjectPermission ( ObjectPermission . Type . READ , identifier ) ) ; return permissions ; } public SharedObjectPermissionSet ( Collection < String > identifiers ) { super ( getPermissions ( identifiers ) ) ; } }
Returns a new Set of ObjectPermissions defining READ access for each of
the given identifiers.

@param identifiers
The identifiers of the objects for which READ permission should be
granted.

@return
A new Set of ObjectPermissions granting READ access for each of the
given identifiers.