Fix compiler ID checks

This commit is contained in:
Peter Dell 2022-12-27 01:12:42 +01:00
parent 59f387dae3
commit b51937217c
2 changed files with 10 additions and 7 deletions

View File

@ -164,7 +164,8 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
/**
* Sets the id of the compiler. Called by {@link CompilerRegistry} only.
*
* @param id The id of the compiler, lower case, not empty and not <code>null</code>.
* @param id The id of the compiler, lower case, not empty and not
* <code>null</code>.
*/
final void setId(String id) {
if (id == null) {
@ -173,8 +174,8 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
if (StringUtility.isEmpty(id)) {
throw new IllegalArgumentException("Parameter 'id' must not be empty.");
}
if (id.equals(id.toLowerCase())) {
throw new IllegalArgumentException("Parameter 'id' must not be lower case.");
if (!id.equals(id.toLowerCase())) {
throw new IllegalArgumentException("Parameter 'id' value " + id + " must be lower case.");
}
this.id = id;
}
@ -182,7 +183,8 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
/**
* Gets the id of the compiler.
*
* @return The id of the compiler, lower case, not empty and not <code>null</code>.
* @return The id of the compiler, lower case, not empty and not
* <code>null</code>.
*/
public final String getId() {
if (id == null) {

View File

@ -78,7 +78,8 @@ public final class CompilerPaths {
public CompilerPaths() {
compilerPaths = new TreeMap<String, CompilerPath>();
// TODO: Complete default compiler paths for all assemblers and compilers and write unit test.
// TODO: Complete default compiler paths for all assemblers and compilers and
// write unit test.
// See https://github.com/peterdell/wudsn-ide-tools
add(Language.ASM, "acme", Platform.OS_WIN32, Platform.ARCH_X86, "acme.exe");
add(Language.ASM, "asm6", Platform.OS_WIN32, Platform.ARCH_X86, "asm6.exe");
@ -101,8 +102,8 @@ public final class CompilerPaths {
}
private void add(Language language, String compilerId, String os, String osArch, String executablePath) {
if (compilerId.equals(compilerId.toLowerCase())) {
throw new IllegalArgumentException("Parameter 'compilerId' must not be lower case.");
if (!compilerId.equals(compilerId.toLowerCase())) {
throw new IllegalArgumentException("Parameter 'compilerId' value " + compilerId + " must be lower case.");
}
CompilerPath compilerPath = new CompilerPath(language, compilerId, os, osArch, executablePath);
compilerPaths.put(compilerPath.getKey(), compilerPath);