1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
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 cc
.squirreljme
.plugin
.util
.FileLocation
;
13 import java
.io
.Serializable
;
14 import java
.util
.Collections
;
15 import java
.util
.LinkedHashMap
;
17 import java
.util
.Objects
;
20 * Represents a candidate test to run.
22 * This class is immutable.
26 public final class CandidateTestFiles
27 implements Serializable
29 /** Source code for the test. */
30 public final FileLocation sourceCode
;
32 /** The expected test results. */
33 public final FileLocation expectedResult
;
35 /** Expected values. */
36 public final Map
<String
, String
> expectedValues
;
38 /** Is this a primary test source? */
39 public final boolean primary
;
42 * Initializes the test.
44 * @param __primary Is this a primary test source?
45 * @param __sourceCode The source code for the test.
46 * @param __expectedResult The expected result file.
47 * @throws NullPointerException If {@code __sourceCode} is null.
50 public CandidateTestFiles(boolean __primary
, FileLocation __sourceCode
,
51 FileLocation __expectedResult
)
52 throws NullPointerException
54 this(__primary
, __sourceCode
, __expectedResult
, null);
58 * Initializes the test.
60 * @param __primary Is this a primary test source?
61 * @param __sourceCode The source code for the test.
62 * @param __expectedResult The expected result file.
63 * @param __expectedValues The expected values.
64 * @throws NullPointerException If {@code __sourceCode} is null.
67 public CandidateTestFiles(boolean __primary
, FileLocation __sourceCode
,
68 FileLocation __expectedResult
, Map
<String
, String
> __expectedValues
)
69 throws NullPointerException
71 if (__sourceCode
== null)
72 throw new NullPointerException("NARG");
74 this.primary
= __primary
;
75 this.sourceCode
= __sourceCode
;
76 this.expectedResult
= __expectedResult
;
77 this.expectedValues
= (__expectedValues
== null ||
78 __expectedValues
.isEmpty() ? Collections
.emptyMap() :
79 Collections
.unmodifiableMap(
80 new LinkedHashMap
<>(__expectedValues
)));
88 public final boolean equals(Object __o
)
93 if (!(__o
instanceof CandidateTestFiles
))
96 CandidateTestFiles o
= (CandidateTestFiles
)__o
;
97 return this.sourceCode
.equals(o
.sourceCode
) &&
98 Objects
.equals(this.expectedResult
, o
.expectedResult
);
106 public final int hashCode()
108 return this.sourceCode
.hashCode() ^
109 Objects
.hashCode(this.expectedResult
.hashCode());
117 public final String
toString()
119 return String
.format("{sourceCode=%s, expectedResult=%s}",
120 this.sourceCode
, this.expectedResult
);