Make Exported just be SquirrelJMEVendorApi.
[SquirrelJME.git] / modules / cldc-compact / src / main / java / cc / squirreljme / runtime / cldc / util / SynchronizedEntrySetNotNull.java
blob16416e760bb0a06f8d7bc5c1804c33bdd9c804a5
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.runtime.cldc.util;
12 import java.util.AbstractSet;
13 import java.util.Iterator;
14 import java.util.Map;
15 import java.util.Set;
17 /**
18 * This is an entry set which is synchronized against a lock, null values
19 * are not allowed.
21 * @param <K> The entry keys.
22 * @param <V> The entry values.
23 * @since 2019/05/05
25 public final class SynchronizedEntrySetNotNull<K, V>
26 extends AbstractSet<Map.Entry<K, V>>
28 /** The locking object. */
29 protected final Object lock;
31 /** The backing set. */
32 protected final Set<Map.Entry<K, V>> set;
34 /**
35 * Initializes the synchronized entry set.
37 * @param __lock The locking object.
38 * @param __set The entry set object.
39 * @throws NullPointerException On null arguments.
40 * @since 2019/05/05
42 public SynchronizedEntrySetNotNull(Object __lock,
43 Set<Map.Entry<K, V>> __set)
44 throws NullPointerException
46 if (__lock == null || __set == null)
47 throw new NullPointerException("NARG");
49 this.lock = __lock;
50 this.set = __set;
53 /**
54 * {@inheritDoc}
55 * @since 2019/05/05
57 @Override
58 public final Iterator<Map.Entry<K, V>> iterator()
60 Object lock = this.lock;
61 synchronized (lock)
63 return new SynchronizedEntrySetIteratorNotNull<K, V>(
64 lock, this.set.iterator());
68 /**
69 * {@inheritDoc}
70 * @since 2019/05/05
72 @Override
73 public final int size()
75 synchronized (this.lock)
77 return this.set.size();