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
;
15 * Represents a test class.
19 public final class VMTestFrameworkTestClass
20 implements Comparable
<VMTestFrameworkTestClass
>
22 /** The class name this is in. */
23 public String className
;
26 public String variant
;
28 /** The normal test. */
31 /** The primary sub-variant, if any. */
32 public String primarySubVariant
;
34 /** The secondary sub-variant, if any. */
35 public String secondarySubVariant
;
38 * Initializes the class name reference.
40 * @param __testName The name of the test.
41 * @throws NullPointerException On null arguments.
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
73 int nextAt
= this.variant
.indexOf('@');
75 // Only a primary sub-variant
78 this.primarySubVariant
= this.variant
;
79 this.secondarySubVariant
= null;
82 // Has both sub-variants
85 this.primarySubVariant
= this.variant
.substring(0, nextAt
);
86 this.secondarySubVariant
=
87 this.variant
.substring(nextAt
+ 1);
97 public int compareTo(VMTestFrameworkTestClass __b
)
100 int rv
= this.className
.compareTo(__b
.className
);
105 rv
= this.normal
.compareTo(__b
.normal
);
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
));
122 public boolean equals(Object __o
)
126 if (!(__o
instanceof VMTestFrameworkTestClass
))
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
);
140 public int hashCode()
142 return Objects
.hash(this.normal
, this.className
, this.variant
);
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
);