Example usage for org.apache.commons.collections4 MapIterator remove

List of usage examples for org.apache.commons.collections4 MapIterator remove

Introduction

In this page you can find the example usage for org.apache.commons.collections4 MapIterator remove.

Prototype

void remove();

Source Link

Document

Removes the last returned key from the underlying Map (optional operation).

Usage

From source file:at.bitfire.davdroid.MemoryCookieStore.java

@Override
public List<Cookie> loadForRequest(HttpUrl url) {
    List<Cookie> cookies = new LinkedList<>();

    synchronized (storage) {
        MapIterator<MultiKey<? extends String>, Cookie> iter = storage.mapIterator();
        while (iter.hasNext()) {
            iter.next();//ww  w .  j a v a  2 s  .  c o m
            Cookie cookie = iter.getValue();

            // remove expired cookies
            if (cookie.expiresAt() <= System.currentTimeMillis()) {
                iter.remove();
                continue;
            }

            // add applicable cookies
            if (cookie.matches(url))
                cookies.add(cookie);
        }
    }

    return cookies;
}

From source file:org.tasks.caldav.MemoryCookieStore.java

@Override
public List<Cookie> loadForRequest(HttpUrl url) {
    List<Cookie> cookies = new LinkedList<>();

    synchronized (storage) {
        MapIterator<MultiKey<? extends String>, Cookie> iter = storage.mapIterator();
        while (iter.hasNext()) {
            iter.next();/*from w w w . ja v a 2s  .  c  o m*/
            Cookie cookie = iter.getValue();

            // remove expired cookies
            if (cookie.expiresAt() <= System.currentTimeMillis()) {
                iter.remove();
                continue;
            }

            // add applicable cookies
            if (cookie.matches(url)) {
                cookies.add(cookie);
            }
        }
    }

    return cookies;
}