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
.VMHelpers
;
14 import cc
.squirreljme
.plugin
.multivm
.VMSpecifier
;
15 import cc
.squirreljme
.plugin
.multivm
.VMType
;
16 import lombok
.AllArgsConstructor
;
17 import lombok
.Builder
;
18 import lombok
.NonNull
;
20 import org
.gradle
.api
.tasks
.SourceSet
;
23 * Represents a source set and a target classifier.
30 public class SourceTargetClassifier
32 /** The source set used. */
36 /** The classifier for the target that is used. */
38 TargetClassifier targetClassifier
;
41 * Initializes the classifier.
43 * @param __sourceSet The source set.
44 * @param __vmType The virtual machine type.
45 * @param __variant The variant used.
48 public SourceTargetClassifier(String __sourceSet
, VMSpecifier __vmType
,
49 BangletVariant __variant
)
51 this(__sourceSet
, new TargetClassifier(__vmType
, __variant
));
55 * Returns the banglet variant used.
57 * @return The banglet variant used.
60 public BangletVariant
getBangletVariant()
62 return this.getTargetClassifier().getBangletVariant();
66 * Returns the virtual machine type.
68 * @return The virtual machine type.
71 public VMSpecifier
getVmType()
73 return this.getTargetClassifier().getVmType();
77 * Is this the main source set?
79 * @return If this is the main source set or not.
82 public boolean isMainSourceSet()
84 return this.sourceSet
.equals(SourceSet
.MAIN_SOURCE_SET_NAME
);
88 * Is this the test fixtures source set?
90 * @return If this is the test fixtures source set or not.
93 public boolean isTestFixturesSourceSet()
95 return this.sourceSet
.equals(VMHelpers
.TEST_FIXTURES_SOURCE_SET_NAME
);
99 * Is this the test source set?
101 * @return If this is the test source set or not.
104 public boolean isTestSourceSet()
106 return this.sourceSet
.equals(SourceSet
.TEST_SOURCE_SET_NAME
);
110 * Modifies this classifier with the given source set.
112 * @param __sourceSet The source set to use instead.
113 * @return The classifier for the given source set.
114 * @throws NullPointerException On null arguments.
117 public SourceTargetClassifier
withSourceSet(String __sourceSet
)
118 throws NullPointerException
120 if (__sourceSet
== null)
121 throw new NullPointerException("NARG");
124 if (this.sourceSet
.equals(__sourceSet
))
128 return new SourceTargetClassifier(__sourceSet
, this.targetClassifier
);
132 * Specifies an alternative virtual machine to use, but with the same
135 * @param __vm The virtual machine to use instead.
136 * @return The modified source target classifier.
137 * @throws NullPointerException On null arguments.
140 public SourceTargetClassifier
withVm(VMSpecifier __vm
)
141 throws NullPointerException
144 throw new NullPointerException("NARG");
146 return new SourceTargetClassifier(this.sourceSet
,
147 this.targetClassifier
.withVm(__vm
));
151 * Returns the classifier to be used by the emulated JIT.
153 * @return The classifier with the appropriate VM based on if it supports
157 public SourceTargetClassifier
withVmByEmulatedJit()
159 if (this.targetClassifier
.getVmType().hasEmulatorJit())
160 return new SourceTargetClassifier(this.sourceSet
,
161 this.targetClassifier
.withVmByEmulatedJit());