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 Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package net
.multiphasicapps
.classfile
;
12 import java
.lang
.ref
.Reference
;
13 import java
.lang
.ref
.WeakReference
;
14 import java
.util
.AbstractList
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
17 import java
.util
.RandomAccess
;
20 * Represents multiple class names.
24 public final class ClassNames
25 extends AbstractList
<ClassName
>
26 implements Contexual
, RandomAccess
29 private final ClassName
[] _names
;
35 private Reference
<String
> _string
;
38 * Initializes the class names.
40 * @param __n The names.
41 * @throws NullPointerException On null arguments.
44 public ClassNames(ClassName
... __n
)
45 throws NullPointerException
47 for (ClassName n
: (__n
=
48 (__n
== null ?
new ClassName
[0] : __n
.clone())))
50 throw new NullPointerException("NARG");
56 * Initializes the class names from the iterable.
58 * @param __n The names.
59 * @throws NullPointerException On null arguments.
62 public ClassNames(Iterable
<ClassName
> __n
)
63 throws NullPointerException
66 throw new NullPointerException("NARG");
68 List
<ClassName
> names
= new ArrayList
<>();
69 for (ClassName name
: __n
)
71 throw new NullPointerException("NARG");
75 this._names
= names
.<ClassName
>toArray(new ClassName
[names
.size()]);
83 public final int hashCode()
87 this._hash
= (rv
= super.hashCode());
96 public final ClassName
get(int __i
)
98 return this._names
[__i
];
106 public final int size()
108 return this._names
.length
;
116 public ClassName
[] toArray()
118 return this._names
.clone();
126 public final String
toString()
128 Reference
<String
> ref
= this._string
;
131 if (ref
== null || null == (rv
= ref
.get()))
132 this._string
= new WeakReference
<>((rv
= super.toString()));