Indentations break the feed.
[SquirrelJME.git] / modules / cldc-compact / src / main / java / cc / squirreljme / jvm / suite / SuiteName.java
blobab2f5c48a0c1cfaf160910bfcb80bb53e11e7a66
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 Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.jvm.suite;
12 import cc.squirreljme.runtime.cldc.debug.Debugging;
13 import cc.squirreljme.runtime.cldc.util.StringUtils;
15 /**
16 * This represents the name of a midlet suite.
18 * @since 2016/10/12
20 public final class SuiteName
21 implements Comparable<SuiteName>
23 /** String value. */
24 protected final String string;
26 /**
27 * Initializes the suite name.
29 * @param __v The value to parse.
30 * @throws InvalidSuiteException If the input is not valid.
31 * @throws NullPointerException On null arguments.
32 * @since 2016/10/12
34 public SuiteName(String __v)
35 throws InvalidSuiteException, NullPointerException
37 // Check
38 if (__v == null)
39 throw new NullPointerException("NARG");
41 // Colon (':') is technically invalid, but so many JARs use it...
42 if (StringUtils.firstIndex(":", __v) >= 0)
43 Debugging.debugNote("Suite name has a colon: %s", __v);
45 /* {@squirreljme.error DG0e An illegal character was
46 specified in the midlet suite name. (The midlet suite
47 name)} */
48 if (StringUtils.firstIndex("\0\r\n;", __v) >= 0)
49 throw new InvalidSuiteException(String.format("AR0e %s", __v));
51 this.string = __v;
54 /**
55 * {@inheritDoc}
56 * @since 2016/10/12
58 @Override
59 public int compareTo(SuiteName __o)
61 if (this == __o)
62 return 0;
63 return this.string.compareTo(__o.string);
66 /**
67 * {@inheritDoc}
68 * @since 2016/10/12
70 @Override
71 public boolean equals(Object __o)
73 if (this == __o)
74 return true;
76 // Check
77 if (!(__o instanceof SuiteName))
78 return false;
80 return this.string.equals(((SuiteName)__o).string);
83 /**
84 * {@inheritDoc}
85 * @since 2016/10/12
87 @Override
88 public int hashCode()
90 return this.string.hashCode();
93 /**
94 * {@inheritDoc}
95 * @since 2016/10/12
97 @Override
98 public String toString()
100 return this.string;