Limit how often GC can be run.
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / multivm / VMTestFrameworkTestClass.java
blob4d96156addd4dab301c0a85bcb277a16c6a1e643
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // Multi-Phasic Applications: 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.plugin.multivm;
12 import java.util.Objects;
14 /**
15 * Represents a test class.
17 * @since 2022/09/14
19 public final class VMTestFrameworkTestClass
20 implements Comparable<VMTestFrameworkTestClass>
22 /** The class name this is in. */
23 public String className;
25 /** The variant. */
26 public String variant;
28 /** The normal test. */
29 public String normal;
31 /** The primary sub-variant, if any. */
32 public String primarySubVariant;
34 /** The secondary sub-variant, if any. */
35 public String secondarySubVariant;
37 /**
38 * Initializes the class name reference.
40 * @param __testName The name of the test.
41 * @throws NullPointerException On null arguments.
42 * @since 2022/09/14
44 public VMTestFrameworkTestClass(String __testName)
45 throws NullPointerException
47 if (__testName == null)
48 throw new NullPointerException("NARG");
50 // Split off from the test and the class
51 int firstAt = __testName.indexOf('@');
52 int lastDot = __testName.lastIndexOf('.',
53 (firstAt < 0 ? __testName.length() : firstAt));
55 // Determine the actual class name and variant
56 this.normal = __testName;
57 this.className = (firstAt >= 0 && firstAt > lastDot ?
58 __testName.substring(0, firstAt) : __testName);
59 this.variant = (firstAt >= 0 && firstAt > lastDot ?
60 __testName.substring(firstAt + 1) : null);
62 // If there is no variant, there is no possibility of of a sub-variant
63 if (this.variant == null)
65 this.primarySubVariant = null;
66 this.secondarySubVariant = null;
69 // Otherwise the sub-variants will be the left and right side of the
70 // variant's at sign.
71 else
73 int nextAt = this.variant.indexOf('@');
75 // Only a primary sub-variant
76 if (nextAt < 0)
78 this.primarySubVariant = this.variant;
79 this.secondarySubVariant = null;
82 // Has both sub-variants
83 else
85 this.primarySubVariant = this.variant.substring(0, nextAt);
86 this.secondarySubVariant =
87 this.variant.substring(nextAt + 1);
92 /**
93 * {@inheritDoc}
94 * @since 2022/09/16
96 @Override
97 public int compareTo(VMTestFrameworkTestClass __b)
99 // By class
100 int rv = this.className.compareTo(__b.className);
101 if (rv != 0)
102 return rv;
104 // By normal
105 rv = this.normal.compareTo(__b.normal);
106 if (rv != 0)
107 return rv;
109 // By variant
110 String av = this.variant;
111 String bv = __b.variant;
112 if ((av == null) != (bv == null))
113 return (av == null ? -1 : 1);
114 return (av == null ? 0 : av.compareTo(bv));
118 * {@inheritDoc}
119 * @since 2022/09/16
121 @Override
122 public boolean equals(Object __o)
124 if (this == __o)
125 return true;
126 if (!(__o instanceof VMTestFrameworkTestClass))
127 return false;
129 VMTestFrameworkTestClass other = (VMTestFrameworkTestClass)__o;
130 return Objects.equals(this.normal, other.normal) &&
131 Objects.equals(this.className, other.className) &&
132 Objects.equals(this.variant, other.variant);
136 * {@inheritDoc}
137 * @since 2022/09/16
139 @Override
140 public int hashCode()
142 return Objects.hash(this.normal, this.className, this.variant);
146 * {@inheritDoc}
147 * @since 2022/12/23
149 @Override
150 public String toString()
152 return String.format("Test[%s, %s, %s (%s, %s)]",
153 this.normal, this.className, this.variant,
154 this.primarySubVariant, this.secondarySubVariant);