Cherry pick the banglets and such from wip-l1summercoat, this will be the basis for...
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / swm / SuiteDependencyLevel.java
blobe8150e13ab79c11ea988fb17aab21aaea28f296b
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.plugin.swm;
12 /**
13 * This represents the level of the dependency.
15 * @since 2017/02/22
17 public enum SuiteDependencyLevel
19 /** Required. */
20 REQUIRED,
22 /** Optional. */
23 OPTIONAL,
25 /** End. */
28 /**
29 * Is this an optional dependency level?
31 * @return {@code true} if this is an optional dependency level.
32 * @since 2017/11/22
34 public boolean isOptional()
36 return this == SuiteDependencyLevel.OPTIONAL;
39 /**
40 * Is this an required dependency level?
42 * @return {@code true} if this is an required dependency level.
43 * @since 2017/11/22
45 public boolean isRequired()
47 return this == SuiteDependencyLevel.REQUIRED;
50 /**
51 * {@inheritDoc}
52 * @since 2017/02/22
54 @Override
55 public String toString()
57 // Convert string
58 switch (this)
60 case REQUIRED: return "required";
61 case OPTIONAL: return "optional";
62 default:
63 throw new RuntimeException(this.toString());
67 /**
68 * Returns the dependency level based on the input string.
70 * @param __s The input string to parse.
71 * @return The dependency level for the given string.
72 * @throws NullPointerException On null arguments.
73 * @since 2017/02/22
75 public static SuiteDependencyLevel of(String __s)
76 throws NullPointerException
78 // Check
79 if (__s == null)
80 throw new NullPointerException("NARG");
82 // Depends
83 switch (__s.trim())
85 case "required": return SuiteDependencyLevel.REQUIRED;
86 case "optional": return SuiteDependencyLevel.OPTIONAL;
88 // Should not happen
89 default:
90 throw new RuntimeException(__s);