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 cc
.squirreljme
.jvm
.suite
;
12 import java
.lang
.ref
.Reference
;
13 import java
.lang
.ref
.WeakReference
;
16 * This is the identity for a midlet suite which contains a name, vendor,
21 public final class SuiteIdentifier
22 implements Comparable
<SuiteIdentifier
>
24 /** The suite name. */
25 protected final SuiteName name
;
27 /** The suite vendor. */
28 protected final SuiteVendor vendor
;
30 /** The suite version. */
31 protected final SuiteVersion version
;
33 /** String representation. */
34 private Reference
<String
> _string
;
37 * Initializes the suite identifier.
39 * @param __name The name of the suite.
40 * @param __ven The vendor of the suite.
41 * @param __ver The version of the suite.
42 * @throws NullPointerException On null arguments.
45 public SuiteIdentifier(SuiteName __name
, SuiteVendor __ven
,
47 throws NullPointerException
49 this(__ven
, __name
, __ver
);
53 * Initializes the suite identifier.
55 * @param __ven The vendor of the suite.
56 * @param __name The name of the suite.
57 * @param __ver The version of the suite.
58 * @throws NullPointerException On null arguments.
61 public SuiteIdentifier(SuiteVendor __ven
, SuiteName __name
,
63 throws NullPointerException
66 if (__ven
== null || __name
== null || __ver
== null)
67 throw new NullPointerException("NARG");
80 public int compareTo(SuiteIdentifier __o
)
86 int rv
= this.name
.compareTo(__o
.name
);
91 rv
= this.vendor
.compareTo(__o
.vendor
);
95 // Then the version last
96 return this.version
.compareTo(__o
.version
);
104 public boolean equals(Object __o
)
110 if (!(__o
instanceof SuiteIdentifier
))
113 return 0 == (this.compareTo((SuiteIdentifier
)__o
));
121 public int hashCode()
123 return this.name
.hashCode() ^
this.vendor
.hashCode() ^
124 this.version
.hashCode();
128 * Returns the suite name.
130 * @return The suite name.
133 public SuiteName
name()
143 public String
toString()
146 Reference
<String
> ref
= this._string
;
150 if (ref
== null || null == (rv
= ref
.get()))
151 this._string
= new WeakReference
<>((rv
= this.vendor
+ ";" +
152 this.name
+ ";" + this.version
));
159 * Returns the suite vendor.
161 * @return The suite vendor.
164 public SuiteVendor
vendor()
170 * Returns the suite version.
172 * @return The suite version.
175 public SuiteVersion
version()