Make it so mapping files are used and then reapplied.
[SquirrelJME.git] / modules / cldc-compact / src / main / java / cc / squirreljme / jvm / suite / APIName.java
blob4206df36dbba868d3e7412990c9285173b65a273
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.jvm.suite;
12 import cc.squirreljme.runtime.cldc.util.StringUtils;
14 /**
15 * This represents the name of an API.
17 * @since 2017/11/30
19 public final class APIName
20 implements Comparable<APIName>
22 /** The name of the API. */
23 protected final String string;
25 /**
26 * Initializes the API name from the given string.
28 * @param __n The name of the API.
29 * @throws InvalidSuiteException If the suite is not valid.
30 * @throws NullPointerException On null arguments.
31 * @since 2017/11/30
33 public APIName(String __n)
34 throws InvalidSuiteException, NullPointerException
36 if (__n == null)
37 throw new NullPointerException("NARG");
39 // Force all APIs to be uppercase
40 __n = StringUtils.toUpperCaseNoLocale(__n);
42 // {@squirreljme.error DG01 An illegal character was
43 // specified in the API name. (The API name)}
44 if (StringUtils.firstIndex("\0\r\n:;", __n) >= 0)
45 throw new InvalidSuiteException(String.format("DG01 %s", __n));
47 // {@squirreljme.error DG02 API name cannot be blank.}
48 if (__n.length() <= 0)
49 throw new InvalidSuiteException("DG02");
51 this.string = __n;
54 /**
55 * {@inheritDoc}
56 * @since 2017/11/30
58 @Override
59 public int compareTo(APIName __o)
61 return this.string.compareTo(__o.string);
64 /**
65 * {@inheritDoc}
66 * @since 2017/11/30
68 @Override
69 public boolean equals(Object __o)
71 if (this == __o)
72 return true;
74 if (!(__o instanceof APIName))
75 return false;
77 return this.string.equals(((APIName)__o).string);
80 /**
81 * {@inheritDoc}
82 * @since 2017/11/30
84 @Override
85 public int hashCode()
87 return this.string.hashCode();
90 /**
91 * {@inheritDoc}
92 * @since 2017/11/30
94 @Override
95 public String toString()
97 return this.string;