Indentations break the feed.
[SquirrelJME.git] / modules / cldc-compact / src / main / java / cc / squirreljme / jvm / suite / SuiteDependencyLevel.java
blob110ef2c55ea08a4c7b78c9c9662c93e172e5fd9b
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;
14 /**
15 * This represents the level of the dependency.
17 * @since 2017/02/22
19 public enum SuiteDependencyLevel
21 /** Required. */
22 REQUIRED,
24 /** Optional. */
25 OPTIONAL,
27 /** End. */
30 /**
31 * Is this an optional dependency level?
33 * @return {@code true} if this is an optional dependency level.
34 * @since 2017/11/22
36 public boolean isOptional()
38 return this == SuiteDependencyLevel.OPTIONAL;
41 /**
42 * Is this an required dependency level?
44 * @return {@code true} if this is an required dependency level.
45 * @since 2017/11/22
47 public boolean isRequired()
49 return this == SuiteDependencyLevel.REQUIRED;
52 /**
53 * {@inheritDoc}
54 * @since 2017/02/22
56 @Override
57 public String toString()
59 // Convert string
60 switch (this)
62 case REQUIRED: return "required";
63 case OPTIONAL: return "optional";
64 default:
65 throw Debugging.oops();
69 /**
70 * Returns the dependency level based on the input string.
72 * @param __s The input string to parse.
73 * @return The dependency level for the given string.
74 * @throws IllegalArgumentException If the level is not valid.
75 * @throws NullPointerException On null arguments.
76 * @since 2017/02/22
78 public static SuiteDependencyLevel of(String __s)
79 throws IllegalArgumentException, NullPointerException
81 // Check
82 if (__s == null)
83 throw new NullPointerException("NARG");
85 // Depends
86 switch (__s.trim())
88 case "required": return SuiteDependencyLevel.REQUIRED;
89 case "optional": return SuiteDependencyLevel.OPTIONAL;
91 /* {@squirreljme.error DG82 Invalid dependency level. (Level)} */
92 default:
93 throw new IllegalArgumentException(String.format(
94 "DG82 %s", __s));