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 GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.plugin
.multivm
.ident
;
12 import cc
.squirreljme
.plugin
.multivm
.BangletVariant
;
13 import cc
.squirreljme
.plugin
.multivm
.ClutterLevel
;
14 import cc
.squirreljme
.plugin
.multivm
.VMHelpers
;
15 import cc
.squirreljme
.plugin
.multivm
.VMSpecifier
;
16 import cc
.squirreljme
.plugin
.multivm
.VMType
;
17 import lombok
.AllArgsConstructor
;
18 import lombok
.Builder
;
19 import lombok
.NonNull
;
21 import org
.gradle
.api
.tasks
.SourceSet
;
24 * Represents a source set and a target classifier.
31 public class SourceTargetClassifier
33 /** The source set used. */
37 /** The classifier for the target that is used. */
39 TargetClassifier targetClassifier
;
42 * Initializes the classifier.
44 * @param __sourceSet The source set.
45 * @param __vmType The virtual machine type.
46 * @param __variant The variant used.
47 * @param __clutterLevel The clutter level used.
50 public SourceTargetClassifier(String __sourceSet
, VMSpecifier __vmType
,
51 BangletVariant __variant
, ClutterLevel __clutterLevel
)
53 this(__sourceSet
, new TargetClassifier(__vmType
, __variant
,
58 * Returns the banglet variant used.
60 * @return The banglet variant used.
63 public BangletVariant
getBangletVariant()
65 return this.getTargetClassifier().getBangletVariant();
69 * Returns the virtual machine type.
71 * @return The virtual machine type.
74 public VMSpecifier
getVmType()
76 return this.getTargetClassifier().getVmType();
80 * Is this the main source set?
82 * @return If this is the main source set or not.
85 public boolean isMainSourceSet()
87 return this.sourceSet
.equals(SourceSet
.MAIN_SOURCE_SET_NAME
);
91 * Is this the test fixtures source set?
93 * @return If this is the test fixtures source set or not.
96 public boolean isTestFixturesSourceSet()
98 return this.sourceSet
.equals(VMHelpers
.TEST_FIXTURES_SOURCE_SET_NAME
);
102 * Is this the test source set?
104 * @return If this is the test source set or not.
107 public boolean isTestSourceSet()
109 return this.sourceSet
.equals(SourceSet
.TEST_SOURCE_SET_NAME
);
113 * Modifies this classifier with the given source set.
115 * @param __sourceSet The source set to use instead.
116 * @return The classifier for the given source set.
117 * @throws NullPointerException On null arguments.
120 public SourceTargetClassifier
withSourceSet(String __sourceSet
)
121 throws NullPointerException
123 if (__sourceSet
== null)
124 throw new NullPointerException("NARG");
127 if (this.sourceSet
.equals(__sourceSet
))
131 return new SourceTargetClassifier(__sourceSet
, this.targetClassifier
);
135 * Specifies an alternative virtual machine to use, but with the same
138 * @param __vm The virtual machine to use instead.
139 * @return The modified source target classifier.
140 * @throws NullPointerException On null arguments.
143 public SourceTargetClassifier
withVm(VMSpecifier __vm
)
144 throws NullPointerException
147 throw new NullPointerException("NARG");
149 return new SourceTargetClassifier(this.sourceSet
,
150 this.targetClassifier
.withVm(__vm
));
154 * Returns the classifier to be used by the emulated JIT.
156 * @return The classifier with the appropriate VM based on if it supports
160 public SourceTargetClassifier
withVmByEmulatedJit()
162 if (this.targetClassifier
.getVmType().hasEmulatorJit())
163 return new SourceTargetClassifier(this.sourceSet
,
164 this.targetClassifier
.withVmByEmulatedJit());