1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
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 net
.multiphasicapps
.collections
;
12 import cc
.squirreljme
.runtime
.cldc
.util
.UnmodifiableIterator
;
13 import java
.util
.Iterator
;
16 * Wraps an iterable which makes it not able to be modified.
18 * @param <T> The type to iterate through.
21 public final class UnmodifiableIterable
<T
>
22 implements Iterable
<T
>
24 /** The iterable used. */
25 private final Iterable
<T
> iterable
;
28 * Initializes the unmodifiable iterable.
30 * @param __it The iterable used.
31 * @throws NullPointerException On null arguments.
34 UnmodifiableIterable(Iterable
<T
> __it
)
35 throws NullPointerException
38 throw new NullPointerException("NARG");
48 public Iterator
<T
> iterator()
50 return UnmodifiableIterator
.<T
>of(this.iterable
);
54 * Returns an unmodifiable iterable from the given one.
56 * @param <T> The type used.
57 * @param __it The iterator to wrap.
58 * @return The iterable but it cannot be modified.
59 * @throws NullPointerException On null arguments.
62 public static <T
> Iterable
<T
> of(Iterable
<T
> __it
)
63 throws NullPointerException
66 throw new NullPointerException("NARG");
68 return new UnmodifiableIterable
<>(__it
);