Make it so mapping files are used and then reapplied.
[SquirrelJME.git] / modules / cldc-compact / src / main / java / cc / squirreljme / jvm / suite / SuiteName.java
blob74d4b557ff46cff4cbeda6cc365e32173a97c4f2
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.annotation.Exported;
13 import cc.squirreljme.runtime.cldc.debug.Debugging;
14 import cc.squirreljme.runtime.cldc.util.StringUtils;
16 /**
17 * This represents the name of a midlet suite.
19 * @since 2016/10/12
21 @Exported
22 public final class SuiteName
23 implements Comparable<SuiteName>
25 /** String value. */
26 protected final String string;
28 /**
29 * Initializes the suite name.
31 * @param __v The value to parse.
32 * @throws InvalidSuiteException If the input is not valid.
33 * @throws NullPointerException On null arguments.
34 * @since 2016/10/12
36 @Exported
37 public SuiteName(String __v)
38 throws InvalidSuiteException, NullPointerException
40 // Check
41 if (__v == null)
42 throw new NullPointerException("NARG");
44 // Colon (':') is technically invalid, but so many JARs use it...
45 if (StringUtils.firstIndex(":", __v) >= 0)
46 Debugging.debugNote("Suite name has a colon: %s", __v);
48 // {@squirreljme.error DG0e An illegal character was
49 // specified in the midlet suite name. (The midlet suite
50 // name)}
51 if (StringUtils.firstIndex("\0\r\n;", __v) >= 0)
52 throw new InvalidSuiteException(String.format("AR0e %s", __v));
54 this.string = __v;
57 /**
58 * {@inheritDoc}
59 * @since 2016/10/12
61 @Override
62 public int compareTo(SuiteName __o)
64 if (this == __o)
65 return 0;
66 return this.string.compareTo(__o.string);
69 /**
70 * {@inheritDoc}
71 * @since 2016/10/12
73 @Override
74 public boolean equals(Object __o)
76 if (this == __o)
77 return true;
79 // Check
80 if (!(__o instanceof SuiteName))
81 return false;
83 return this.string.equals(((SuiteName)__o).string);
86 /**
87 * {@inheritDoc}
88 * @since 2016/10/12
90 @Override
91 public int hashCode()
93 return this.string.hashCode();
96 /**
97 * {@inheritDoc}
98 * @since 2016/10/12
100 @Override
101 public String toString()
103 return this.string;