From 85a280b356e0d2d7d4e2b781e745a4d071e45cf9 Mon Sep 17 00:00:00 2001 From: norman Date: Fri, 4 May 2012 13:20:08 +0200 Subject: [PATCH] Let ChannelLocal implement Iterable. See #307 --- .../java/org/jboss/netty/channel/ChannelLocal.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jboss/netty/channel/ChannelLocal.java b/src/main/java/org/jboss/netty/channel/ChannelLocal.java index c8f1d80b92..1b883fb559 100644 --- a/src/main/java/org/jboss/netty/channel/ChannelLocal.java +++ b/src/main/java/org/jboss/netty/channel/ChannelLocal.java @@ -15,6 +15,9 @@ */ package org.jboss.netty.channel; +import java.util.Collections; +import java.util.Iterator; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentMap; import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap; @@ -30,7 +33,7 @@ import org.jboss.netty.util.internal.ConcurrentIdentityWeakKeyHashMap; * property, which performs better. * @apiviz.stereotype utility */ -public class ChannelLocal { +public class ChannelLocal implements Iterable>{ private final ConcurrentMap map = new ConcurrentIdentityWeakKeyHashMap(); @@ -153,4 +156,11 @@ public class ChannelLocal { return removed; } } + + /** + * Returns a read-only {@link Iterator} that holds all {@link Entry}'s of this ChannelLocal + */ + public Iterator> iterator() { + return Collections.unmodifiableSet(map.entrySet()).iterator(); + } }