Remove exported everywhere.
[SquirrelJME.git] / modules / tool-classfile / src / main / java / net / multiphasicapps / classfile / Identifier.java
blob5013d1461bbb725d11a758d4742e6557d074a9e8
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 net.multiphasicapps.classfile;
12 /**
13 * This represents an identifier which acts as a name of a fragment of a class
14 * or a member of a class.
16 * @since 2017/06/12
18 public abstract class Identifier
20 /** The string which makes up the identifier. */
21 protected final String string;
23 /**
24 * Initializes the identifier.
26 * @param __n The input identifier to decode.
27 * @throws InvalidClassFormatException If it is not a valid identifier.
28 * @throws NullPointerException On null arguments.
29 * @since 2017/06/12
31 Identifier(String __n)
32 throws InvalidClassFormatException, NullPointerException
34 // Check
35 if (__n == null)
36 throw new NullPointerException("NARG");
38 // Set
39 this.string = __n;
41 // Check characters
42 for (int i = 0, n = __n.length(); i < n; i++)
44 char c = __n.charAt(i);
46 // {@squirreljme.error JC2x The specified identifier contains an
47 // invalid character. (The identifier)}
48 if (c == '.' || c == ';' || c == '[' || c == '/')
49 throw new InvalidClassFormatException(
50 String.format("JC2x %s", __n));
54 /**
55 * {@inheritDoc}
56 * @since 2017/06/12
58 @Override
59 public boolean equals(Object __o)
61 if (this == __o)
62 return true;
64 // Check
65 if (!(__o instanceof Identifier))
66 return false;
68 return this.string.equals(((Identifier)__o).string);
71 /**
72 * {@inheritDoc}
73 * @since 2017/06/12
75 @Override
76 public int hashCode()
78 return this.string.hashCode();
81 /**
82 * Returns the identifier.
84 * @return The identifier.
85 * @since 2017/10/02
87 public final String identifier()
89 return this.string;
92 /**
93 * {@inheritDoc}
94 * @since 2017/06/12
96 @Override
97 public String toString()
99 return this.string;