From 4922c424a212112d8109bcc4429d02a3c62ca375 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:09:58 +0000 Subject: [PATCH 001/162] Initial storage classes, no tests --- src/main/java/storage/Loadable.java | 7 +++ src/main/java/storage/Storable.java | 7 +++ src/main/java/storage/StorageData.java | 9 +++ .../storage/storageMethods/StorageMethod.java | 55 +++++++++++++++++++ .../storage/storageMethods/StringStorage.java | 24 ++++++++ .../storage/storageValues/StorageValue.java | 9 +++ 6 files changed, 111 insertions(+) create mode 100644 src/main/java/storage/Loadable.java create mode 100644 src/main/java/storage/Storable.java create mode 100644 src/main/java/storage/StorageData.java create mode 100644 src/main/java/storage/storageMethods/StorageMethod.java create mode 100644 src/main/java/storage/storageMethods/StringStorage.java create mode 100644 src/main/java/storage/storageValues/StorageValue.java diff --git a/src/main/java/storage/Loadable.java b/src/main/java/storage/Loadable.java new file mode 100644 index 0000000..025ebe4 --- /dev/null +++ b/src/main/java/storage/Loadable.java @@ -0,0 +1,7 @@ +package storage; + +public interface Loadable { + + public void load(StorageData data); + +} diff --git a/src/main/java/storage/Storable.java b/src/main/java/storage/Storable.java new file mode 100644 index 0000000..a6b3c1c --- /dev/null +++ b/src/main/java/storage/Storable.java @@ -0,0 +1,7 @@ +package storage; + +public interface Storable { + + public StorageData getStorageRepresentation(); + +} diff --git a/src/main/java/storage/StorageData.java b/src/main/java/storage/StorageData.java new file mode 100644 index 0000000..389ae86 --- /dev/null +++ b/src/main/java/storage/StorageData.java @@ -0,0 +1,9 @@ +package storage; + +import java.util.HashMap; +import storage.storageValues.StorageValue; + +/** + * A memento/storage object for Storable objects + */ +public class StorageData extends HashMap> {} diff --git a/src/main/java/storage/storageMethods/StorageMethod.java b/src/main/java/storage/storageMethods/StorageMethod.java new file mode 100644 index 0000000..d5de0a5 --- /dev/null +++ b/src/main/java/storage/storageMethods/StorageMethod.java @@ -0,0 +1,55 @@ +package storage.storageMethods; + +import java.nio.file.*; + +import storage.storageValues.StorageValue; + +public abstract class StorageMethod { + + protected static final String DEFAULT_FILE_PATH = "./compilerStorage"; + + protected String filePath; + protected String fileExtension; + + protected Path storageFile; + + /** + * Initiates this storage method with a default filepath of ./compilerStorage and a prechosen file extension. + */ + public StorageMethod() { + filePath = DEFAULT_FILE_PATH; + fileExtension = defineFileExtension(); + + createStoragePath(filePath, fileExtension); + } + + /** + * Initiates this storage method with a custom filepath of ./compilerStorage and a prechosen file extension. + * @param filePath The path of the storage file + */ + public StorageMethod(String filePath) { + filePath = DEFAULT_FILE_PATH; + + createStoragePath(filePath, fileExtension); + } + + + private void createStoragePath(String path, String extension) { + try { + storageFile = Paths.get(path + extension); + } catch (InvalidPathException e) { + throw e; + } catch (NullPointerException e) { + throw e; // TODO: Test how to cause this, and make appropriate error message if not already provided. + } + } + + /** + * Defines the file extension to use when creating the storage file. This must be in the form ".". + * @return The file extension for the storage file + */ + protected abstract String defineFileExtension(); + + public abstract void store(String key, String storageType, T value); // TODO: Consider wiping file on first storage attempt + public abstract StorageValue load(String key); +} diff --git a/src/main/java/storage/storageMethods/StringStorage.java b/src/main/java/storage/storageMethods/StringStorage.java new file mode 100644 index 0000000..a657a8e --- /dev/null +++ b/src/main/java/storage/storageMethods/StringStorage.java @@ -0,0 +1,24 @@ +package storage.storageMethods; + +import storage.storageValues.StorageValue; + +public class StringStorage extends StorageMethod { + + @Override + protected String defineFileExtension() { + return ".storage.txt"; + } + + @Override + public void store(String key, String storageType, String value) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'store'"); + } + + @Override + public StorageValue load(String key) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'load'"); + } + +} diff --git a/src/main/java/storage/storageValues/StorageValue.java b/src/main/java/storage/storageValues/StorageValue.java new file mode 100644 index 0000000..7b79084 --- /dev/null +++ b/src/main/java/storage/storageValues/StorageValue.java @@ -0,0 +1,9 @@ +package storage.storageValues; + +public abstract class StorageValue { + private T value; + + public StorageValue(T value) { + this.value = value; + } +} From 4008b8efaaef74e234e4e6365973129b755c4e40 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 11 Jan 2025 20:05:55 +0000 Subject: [PATCH 002/162] String storage method and general file operations Storage code remains untested --- src/main/java/storage/FileOperations.java | 68 +++++++++++++++++++ .../helper_objects/DuplicateKeyException.java | 8 +++ .../storage/storageMethods/StringStorage.java | 46 +++++++++++-- .../storage/storageValues/StorageValue.java | 4 ++ .../storageValues/StringStorageValue.java | 9 +++ 5 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 src/main/java/storage/FileOperations.java create mode 100644 src/main/java/storage/helper_objects/DuplicateKeyException.java create mode 100644 src/main/java/storage/storageValues/StringStorageValue.java diff --git a/src/main/java/storage/FileOperations.java b/src/main/java/storage/FileOperations.java new file mode 100644 index 0000000..cf2d095 --- /dev/null +++ b/src/main/java/storage/FileOperations.java @@ -0,0 +1,68 @@ +package storage; + +import java.io.*; +import java.nio.file.*; + +public class FileOperations { + + /** + * Eases the contents of the provided file + * @param path The path of the file to be cleared. + * @throws UncheckedIOException The provided file could not be cleared. + */ + public static void eraseFileContents(Path path) throws UncheckedIOException { + try { + Files.newBufferedWriter(path , StandardOpenOption.TRUNCATE_EXISTING); + } catch (IOException e) { + throw new UncheckedIOException("The file " + path.toString() + "could not be cleared.", e); + } + } + + /** + * Checks if the file at the path provided exists + * @param path The path of the file. + * @return The existance of the specified file. + */ + public static boolean fileExists(Path path) { + return Files.exists(path); + } + + /** + * Creates a file for the provided path + * @param path The path of the file to be created. + */ + public static void createFile(Path path) { + try { + Files.createFile(path); + } catch (IOException e) { + throw new UncheckedIOException("The file " + path.toString() + "could not be created.", e); + } + } + + /** + * Deletes the file at the provided path + * @param path The path of the file to be deleted. + */ + public static void deleteFile(Path path) { + try { + Files.delete(path); + } catch (IOException e) { + throw new UncheckedIOException("The file " + path.toString() + "could not be deleted.", e); + } + } + + /** + * Appends a new line to the specified file with the given contents + * @param path The path of the file to be edited. + * @param line The contents to be added on the line. + */ + public static void appendLine(Path path, String line) { + line = line + "\n"; + + try (FileOutputStream fos = new FileOutputStream(path.toFile(), true);) { + fos.write(line.getBytes()); + } catch (IOException e) { + throw new UncheckedIOException("The file " + path.toString() + "could not be appended to.", e); + } + } +} diff --git a/src/main/java/storage/helper_objects/DuplicateKeyException.java b/src/main/java/storage/helper_objects/DuplicateKeyException.java new file mode 100644 index 0000000..541a380 --- /dev/null +++ b/src/main/java/storage/helper_objects/DuplicateKeyException.java @@ -0,0 +1,8 @@ +package storage.helper_objects; + +public class DuplicateKeyException extends RuntimeException { + + public DuplicateKeyException(T key) { + super("Duplicated definition of the key \'" + key.toString() + " was provided."); + } +} diff --git a/src/main/java/storage/storageMethods/StringStorage.java b/src/main/java/storage/storageMethods/StringStorage.java index a657a8e..896bf6b 100644 --- a/src/main/java/storage/storageMethods/StringStorage.java +++ b/src/main/java/storage/storageMethods/StringStorage.java @@ -1,9 +1,23 @@ package storage.storageMethods; -import storage.storageValues.StorageValue; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.util.*; +import java.util.stream.Stream; + +import storage.FileOperations; +import storage.helper_objects.DuplicateKeyException; +import storage.storageValues.*; public class StringStorage extends StorageMethod { + protected static final String KEY_VALUE_SEPERATOR = " : "; + + boolean storageUsed = false; + List existingKeys = new ArrayList(); + @Override protected String defineFileExtension() { return ".storage.txt"; @@ -11,14 +25,36 @@ protected String defineFileExtension() { @Override public void store(String key, String storageType, String value) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'store'"); + if (existingKeys.contains(key)) throw new DuplicateKeyException(key); + + if (!storageUsed) { + if (!FileOperations.fileExists(storageFile)) + FileOperations.createFile(storageFile); + else + FileOperations.eraseFileContents(storageFile); + } + + if (key.contains("KEY_VALUE_SEPERATOR")) throw new IllegalArgumentException("The character sequence \'" + KEY_VALUE_SEPERATOR + "\' may not appear within a key"); + if (key.contains("\n")) throw new IllegalArgumentException("Newline characters may not appear within a key"); + + FileOperations.appendLine(storageFile, key + KEY_VALUE_SEPERATOR + value); + + storageUsed = true; + existingKeys.add(key); } @Override public StorageValue load(String key) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'load'"); + try (Stream stream = Files.lines(storageFile)) { + List keyLines = stream.filter(line -> line.startsWith(key)).toList(); + String line = keyLines.get(0); + + String value = line.split(KEY_VALUE_SEPERATOR, 2)[1]; + return new StringStorageValue(value); + } + catch (IOException e) { + throw new UncheckedIOException("The file " + storageFile.toString() + "could not be appended to.", e); + } } } diff --git a/src/main/java/storage/storageValues/StorageValue.java b/src/main/java/storage/storageValues/StorageValue.java index 7b79084..580ceb4 100644 --- a/src/main/java/storage/storageValues/StorageValue.java +++ b/src/main/java/storage/storageValues/StorageValue.java @@ -6,4 +6,8 @@ public abstract class StorageValue { public StorageValue(T value) { this.value = value; } + + public T getValue() { + return value; + } } diff --git a/src/main/java/storage/storageValues/StringStorageValue.java b/src/main/java/storage/storageValues/StringStorageValue.java new file mode 100644 index 0000000..528364a --- /dev/null +++ b/src/main/java/storage/storageValues/StringStorageValue.java @@ -0,0 +1,9 @@ +package storage.storageValues; + +public class StringStorageValue extends StorageValue { + + public StringStorageValue(String string) { + super(string); + } + +} From a500d2664e6134760448e037e639157d06a2601e Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:08:49 +0000 Subject: [PATCH 003/162] Diagram for storage proposal --- docs/diagrams/Storage.drawio.svg | 673 +++++++++++++++++++++++++++++++ 1 file changed, 673 insertions(+) create mode 100644 docs/diagrams/Storage.drawio.svg diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg new file mode 100644 index 0000000..5736209 --- /dev/null +++ b/docs/diagrams/Storage.drawio.svg @@ -0,0 +1,673 @@ + + + + + + + +
+
+
+ Storable <I> +
+
+
+
+ + Storable <... + +
+
+ + + + + + +
+
+
+ Storage Values +
+
+
+
+ + Storage Values + +
+
+ + + + +
+
+
+ StorageValue<T> +
+ <A> +
+
+
+
+ + StorageValue<T>... + +
+
+ + + + +
+
+
+ StringStorageValue +
+
+
+
+ + StringStorageValue + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + + + + +
+
+
+ Storage Methods +
+
+
+
+ + Storage Methods + +
+
+ + + + +
+
+
+ StorageMethod<T> +
+ <A> +
+
+
+
+ + StorageMethod<T>... + +
+
+ + + + +
+
+
+ StringStorage +
+
+
+
+ + StringStorage + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + +
+
+
+ Loadable <I> +
+
+
+
+ + Loadable <... + +
+
+ + + + + + +
+
+
+ Compiler Component +
+
+
+
+ + Compiler Comp... + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + Proposed + + + + + Current + + + + + + +
+
+
+ Storable <I> +
+
+
+
+ + Storable <... + +
+
+ + + + + + +
+
+
+ Storage Values +
+
+
+
+ + Storage Values + +
+
+ + + + +
+
+
+ StorageValue<T> +
+ <A> +
+
+
+
+ + StorageValue<T>... + +
+
+ + + + +
+
+
+ StringStorageValue +
+
+
+
+ + StringStorageValue + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + + + + +
+
+
+ Storage Methods +
+
+
+
+ + Storage Methods + +
+
+ + + + +
+
+
+ StorageMethod<T> +
+ <A> +
+
+
+
+ + StorageMethod<T>... + +
+
+ + + + +
+
+
+ StringStorage +
+
+
+
+ + StringStorage + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + +
+
+
+ Loadable <I> +
+
+
+
+ + Loadable <... + +
+
+ + + + + +
+
+
+ Produces a set of +
+
+
+
+ + Produces a set of + +
+
+ + + + +
+
+
+ Compiler Component +
+
+
+
+ + Compiler Comp... + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + + + +
+
+
+ Storage Value Adapters +
+
+
+
+ + Storage Value Adapters + +
+
+ + + + +
+
+
+ StorageValueAdapter <I> +
+
+
+
+ + StorageValueAdapter <... + +
+
+ + + + +
+
+
+ StringValueToString +
+
+
+
+ + StringValueToString + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + +
+
+
+ UnsupportedValueException +
+
+
+
+ + UnsupportedValueException + +
+
+ + + + + +
+
+
+ Passed into +
+
+
+
+ + Passed into + +
+
+ + + + +
+
+
+ RuntimeException +
+
+
+
+ + RuntimeException + +
+
+ + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+ + + + + + + +
+
+
+ Throws +
+
+
+
+ + Throws + +
+
+
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file From 7919910df84d7284a89b2cca4d16009f744e4abd Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 13 Jan 2025 23:05:11 +0000 Subject: [PATCH 004/162] Beginning of small storage architecture rework --- docs/diagrams/Storage.drawio.svg | 78 ++++++++++--------- .../storageMethods/StorageValueAdapter.java | 10 +++ .../storage/storageMethods/StringStorage.java | 3 +- .../UnsupportedValueException.java | 5 ++ 4 files changed, 57 insertions(+), 39 deletions(-) create mode 100644 src/main/java/storage/storageMethods/StorageValueAdapter.java create mode 100644 src/main/java/storage/storageValueAdapters/UnsupportedValueException.java diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index 5736209..2cddbf4 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,4 +1,4 @@ - + @@ -78,7 +78,7 @@ -
+
Extends @@ -86,7 +86,7 @@
- + Extends @@ -206,7 +206,7 @@ -
+
Extends @@ -214,7 +214,7 @@
- + Extends @@ -224,7 +224,7 @@ -
+
Extends @@ -232,7 +232,7 @@
- + Extends @@ -271,7 +271,7 @@ -
+
Storage Values @@ -345,7 +345,7 @@ -
+
Storage Methods @@ -477,7 +477,7 @@
- + Extends @@ -495,7 +495,7 @@
- + Extends
@@ -506,7 +506,7 @@ -
+
Storage Value Adapters @@ -536,11 +536,11 @@ - + -
+
StringValueToString @@ -548,29 +548,11 @@
- + StringValueToString - - - - - -
-
-
- Extends -
-
-
-
- - Extends - -
-
@@ -588,6 +570,8 @@
+ + @@ -643,12 +627,12 @@ - - + + -
+
Throws @@ -656,11 +640,31 @@
- + Throws + + + + + +
+
+
+ Storage File +
+
+
+
+ + Storage File + +
+
+ + diff --git a/src/main/java/storage/storageMethods/StorageValueAdapter.java b/src/main/java/storage/storageMethods/StorageValueAdapter.java new file mode 100644 index 0000000..5167637 --- /dev/null +++ b/src/main/java/storage/storageMethods/StorageValueAdapter.java @@ -0,0 +1,10 @@ +package storage.storageMethods; + +import storage.storageValues.StorageValue; + +public interface StorageValueAdapter { + + public T retreiveValue(StorageValue storageValue); + public StorageValue packageValue(T value); + +} diff --git a/src/main/java/storage/storageMethods/StringStorage.java b/src/main/java/storage/storageMethods/StringStorage.java index 896bf6b..5b81df5 100644 --- a/src/main/java/storage/storageMethods/StringStorage.java +++ b/src/main/java/storage/storageMethods/StringStorage.java @@ -1,8 +1,7 @@ package storage.storageMethods; -import java.io.IOException; -import java.io.UncheckedIOException; +import java.io.*; import java.nio.file.Files; import java.util.*; import java.util.stream.Stream; diff --git a/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java b/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java new file mode 100644 index 0000000..6e08c63 --- /dev/null +++ b/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java @@ -0,0 +1,5 @@ +package storage.storageValueAdapters; + +public class UnsupportedValueException extends RuntimeException { + +} From 7c81bd9e21b47a2157e7c80970065a65366f7cc2 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:51:12 +0000 Subject: [PATCH 005/162] Basic storageValues --- .../java/storage/storageMethods/StringStorage.java | 1 - .../storage/storageValues/IntegerStorageValue.java | 9 +++++++++ .../java/storage/storageValues/MapStorageValue.java | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/main/java/storage/storageValues/IntegerStorageValue.java create mode 100644 src/main/java/storage/storageValues/MapStorageValue.java diff --git a/src/main/java/storage/storageMethods/StringStorage.java b/src/main/java/storage/storageMethods/StringStorage.java index 5b81df5..5585e2f 100644 --- a/src/main/java/storage/storageMethods/StringStorage.java +++ b/src/main/java/storage/storageMethods/StringStorage.java @@ -1,6 +1,5 @@ package storage.storageMethods; - import java.io.*; import java.nio.file.Files; import java.util.*; diff --git a/src/main/java/storage/storageValues/IntegerStorageValue.java b/src/main/java/storage/storageValues/IntegerStorageValue.java new file mode 100644 index 0000000..f556e6d --- /dev/null +++ b/src/main/java/storage/storageValues/IntegerStorageValue.java @@ -0,0 +1,9 @@ +package storage.storageValues; + +public class IntegerStorageValue extends StorageValue { + + public IntegerStorageValue(Integer integer) { + super(integer); + } + +} diff --git a/src/main/java/storage/storageValues/MapStorageValue.java b/src/main/java/storage/storageValues/MapStorageValue.java new file mode 100644 index 0000000..d4a6f13 --- /dev/null +++ b/src/main/java/storage/storageValues/MapStorageValue.java @@ -0,0 +1,11 @@ +package storage.storageValues; + +import java.util.Map; + +public class MapStorageValue extends StorageValue>> { + + public MapStorageValue(Map> map) { + super(map); + } + +} \ No newline at end of file From 92e2a4be7c5d6fb254e3cc9e49761f71892a635a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:41:03 +0000 Subject: [PATCH 006/162] StorageValueAdapter rework and relocation --- docs/diagrams/Storage.drawio.svg | 14 +++++++------- .../storageMethods/StorageValueAdapter.java | 10 ---------- .../storageValueAdapters/StorageValueAdapter.java | 13 +++++++++++++ 3 files changed, 20 insertions(+), 17 deletions(-) delete mode 100644 src/main/java/storage/storageMethods/StorageValueAdapter.java create mode 100644 src/main/java/storage/storageValueAdapters/StorageValueAdapter.java diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index 2cddbf4..63fba98 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,4 +1,4 @@ - + @@ -78,7 +78,7 @@ -
+
Extends @@ -86,7 +86,7 @@
- + Extends @@ -214,7 +214,7 @@
- + Extends
@@ -232,7 +232,7 @@
- + Extends
@@ -627,8 +627,8 @@
- - + + diff --git a/src/main/java/storage/storageMethods/StorageValueAdapter.java b/src/main/java/storage/storageMethods/StorageValueAdapter.java deleted file mode 100644 index 5167637..0000000 --- a/src/main/java/storage/storageMethods/StorageValueAdapter.java +++ /dev/null @@ -1,10 +0,0 @@ -package storage.storageMethods; - -import storage.storageValues.StorageValue; - -public interface StorageValueAdapter { - - public T retreiveValue(StorageValue storageValue); - public StorageValue packageValue(T value); - -} diff --git a/src/main/java/storage/storageValueAdapters/StorageValueAdapter.java b/src/main/java/storage/storageValueAdapters/StorageValueAdapter.java new file mode 100644 index 0000000..03d23e3 --- /dev/null +++ b/src/main/java/storage/storageValueAdapters/StorageValueAdapter.java @@ -0,0 +1,13 @@ +package storage.storageValueAdapters; + +import storage.storageValues.StorageValue; + +/** + * An interface that defines an adapter converting StorageValues to a chosen representation for use within a StorageMethod + */ +public interface StorageValueAdapter { + + public E retreiveValue(StorageValue storageValue); + public StorageValue packageValue(E value); + +} From 099b2594b01c442a6f48bbebc4f7db6757de5326 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 14 Jan 2025 22:38:53 +0000 Subject: [PATCH 007/162] Storage proposed representation/file storage architecture edit --- docs/diagrams/Storage.drawio.svg | 77 ++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index 63fba98..48327c2 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,4 +1,4 @@ - + @@ -78,7 +78,7 @@ -
+
Extends @@ -86,7 +86,7 @@
- + Extends @@ -214,7 +214,7 @@
- + Extends
@@ -232,7 +232,7 @@
- + Extends
@@ -627,8 +627,8 @@
- - + + @@ -645,12 +645,12 @@ - - + + -
+
Storage File @@ -658,13 +658,64 @@
- + Storage File - - + + + + + +
+
+
+ Produces +
+
+
+
+ + Produces + +
+
+ + + + +
+
+
+ Storage Representation +
+
+
+
+ + Storage Representation + +
+
+ + + + + +
+
+
+ May be transferred to +
+
+
+
+ + May be transferred to + +
+
From 3f96f141eb14c0e11e310880b1739b7e09c39d67 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 18 Jan 2025 21:03:52 +0000 Subject: [PATCH 008/162] Storage architecture rework to add FileWriters --- docs/diagrams/Storage.drawio.svg | 500 ++++++++++--------------------- 1 file changed, 156 insertions(+), 344 deletions(-) diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index 48327c2..d08f858 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,11 +1,11 @@ - + - + -
+
Storable <I> @@ -13,18 +13,18 @@
- + Storable <... - - - + + + -
+
Storage Values @@ -32,16 +32,16 @@
- + Storage Values - + -
+
StorageValue<T> @@ -51,16 +51,16 @@
- + StorageValue<T>... - + -
+
StringStorageValue @@ -68,17 +68,17 @@
- + StringStorageValue - - + + -
+
Extends @@ -86,19 +86,19 @@
- + Extends - - - - + + + + -
+
Storage Methods @@ -106,16 +106,16 @@
- + Storage Methods - + -
+
StorageMethod<T> @@ -125,16 +125,16 @@
- + StorageMethod<T>... - + -
+
StringStorage @@ -142,17 +142,17 @@
- + StringStorage - - + + -
+
Extends @@ -160,16 +160,16 @@
- + Extends - + -
+
Loadable <I> @@ -177,155 +177,70 @@
- + Loadable <... - - - + + -
-
-
- Compiler Component -
-
-
-
- - Compiler Comp... - -
-
- - - - - -
-
-
- Extends -
-
-
-
- - Extends - -
-
- - - - - -
+
- Extends -
-
-
- - - Extends - - - - - - - Proposed - - - - - Current - - - - - - -
-
-
- Storable <I> -
-
-
-
- - Storable <... - -
-
- - - - - - -
-
-
- Storage Values + Produces a set of
- - Storage Values + + Produces a set of
- + -
+
- StorageValue<T> -
- <A> + Compiler Component
- - StorageValue<T>... + + Compiler Comp... - + + -
-
-
- StringStorageValue +
+
+
+ Extends
- - StringStorageValue + + Extends - - + + -
+
Extends @@ -333,143 +248,124 @@
- + Extends - - - - + + + -
+
- Storage Methods + Storage Value Adapters
- - Storage Methods + + Storage Value Adapters - + -
+
- StorageMethod<T> -
- <A> + StorageValueAdapter <I>
- - StorageMethod<T>... + + StorageValueAdapter <... - + -
+
- StringStorage -
-
-
- - - StringStorage - - - - - - - - -
-
-
- Extends + StringValueToString
- - Extends + + StringValueToString
- + -
+
- Loadable <I> + UnsupportedValueException
- - Loadable <... + + UnsupportedValueException - - + + + + -
+
- Produces a set of + Passed into
- - Produces a set of + + Passed into - + -
+
- Compiler Component + RuntimeException
- - Compiler Comp... + + RuntimeException - - + + -
+
Extends @@ -477,245 +373,161 @@
- + Extends - - + + + + -
+
- Extends -
-
-
- - - Extends - - - - - - - - - -
-
-
- Storage Value Adapters -
-
-
-
- - Storage Value Adapters - -
-
- - - - -
-
-
- StorageValueAdapter <I> -
-
-
-
- - StorageValueAdapter <... - -
-
- - - - -
-
-
- StringValueToString + Throws
- - StringValueToString + + Throws
- + + -
+
- UnsupportedValueException + Storage File
- - UnsupportedValueException + + Storage File - - - - + + -
+
- Passed into + Produces
- - Passed into + + Produces - + + + -
+
- RuntimeException -
-
-
- - - RuntimeException - - - - - - - - -
-
-
- Extends + Storage Representation
- - Extends + + Storage Representation
- - - - + + + -
-
-
- Throws +
+
+
+ File Writers
- - Throws + + File Writers - - + -
+
- Storage File -
-
-
- - - Storage File - - - - - - - - -
-
-
- Produces + FileWriter<T> +
+ <I>
- - Produces + + FileWriter<T>...
- + -
+
- Storage Representation + StringFileWriter
- - Storage Representation + + StringFileWriter - - + + -
+
- May be transferred to + Extends
- - May be transferred to + + Extends + + From 0f57567aef4c7a5f480a1bc1b384322fade14db1 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 18 Jan 2025 21:04:11 +0000 Subject: [PATCH 009/162] FileWriter and basic string file writer --- .../java/storage/fileWriters/FileWriter.java | 17 +++++++++++++++++ .../storage/fileWriters/StringFileWriter.java | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/main/java/storage/fileWriters/FileWriter.java create mode 100644 src/main/java/storage/fileWriters/StringFileWriter.java diff --git a/src/main/java/storage/fileWriters/FileWriter.java b/src/main/java/storage/fileWriters/FileWriter.java new file mode 100644 index 0000000..a12df41 --- /dev/null +++ b/src/main/java/storage/fileWriters/FileWriter.java @@ -0,0 +1,17 @@ +package storage.fileWriters; + +import java.io.File; +import java.nio.file.Path; + +public abstract class FileWriter { + + public void store(File file, T contents) { + store(file.getAbsolutePath(), contents); + } + + public void store(Path path, T contents) { + store(path.toAbsolutePath(), contents); + } + + public abstract void store(String path, T contents); +} \ No newline at end of file diff --git a/src/main/java/storage/fileWriters/StringFileWriter.java b/src/main/java/storage/fileWriters/StringFileWriter.java new file mode 100644 index 0000000..ad10b26 --- /dev/null +++ b/src/main/java/storage/fileWriters/StringFileWriter.java @@ -0,0 +1,17 @@ +package storage.fileWriters; + +import java.io.*; +import java.nio.file.*; + +public class StringFileWriter extends FileWriter { + + @Override + public void store(String path, String contents) { + try { + Files.writeString(Paths.get(path), contents); + } catch (IOException e) { + new UncheckedIOException("Failed to store content to \"" + path + "\"", e); + } + } + +} From 6037eeecfb3bf6a894cfa9a104b5a004514593e3 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 18 Jan 2025 22:08:45 +0000 Subject: [PATCH 010/162] File editor interface alterations and abstract class --- docs/diagrams/Storage.drawio.svg | 114 ++++++++++++------ .../java/storage/fileEditors/FileEditor.java | 24 ++++ .../java/storage/fileEditors/FileReader.java | 5 + .../java/storage/fileEditors/FileWriter.java | 5 + .../StringFileWriter.java | 10 +- .../java/storage/fileWriters/FileWriter.java | 17 --- 6 files changed, 120 insertions(+), 55 deletions(-) create mode 100644 src/main/java/storage/fileEditors/FileEditor.java create mode 100644 src/main/java/storage/fileEditors/FileReader.java create mode 100644 src/main/java/storage/fileEditors/FileWriter.java rename src/main/java/storage/{fileWriters => fileEditors}/StringFileWriter.java (54%) delete mode 100644 src/main/java/storage/fileWriters/FileWriter.java diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index d08f858..b5ad449 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,4 +1,4 @@ - + @@ -187,7 +187,7 @@ -
+
Produces a set of @@ -195,7 +195,7 @@
- + Produces a set of @@ -380,7 +380,7 @@ - + @@ -398,12 +398,12 @@ - - + + -
+
Storage File @@ -411,17 +411,17 @@
- + Storage File - - + + -
+
Produces @@ -429,18 +429,18 @@
- + Produces - - - + + + -
+
Storage Representation @@ -448,35 +448,35 @@
- + Storage Representation - - - + + + -
+
- File Writers + File Editors
- - File Writers + + File Editors - + -
+
FileWriter<T> @@ -486,16 +486,16 @@
- + FileWriter<T>... - + -
+
StringFileWriter @@ -503,17 +503,55 @@
- + StringFileWriter - - + -
+
+
+
+ FileReader<T> +
+ <I> +
+
+
+ + + FileReader<T>... + + + + + + + +
+
+
+ FileEditor<T> +
+ <A> +
+
+
+
+ + FileEditor<T>... + +
+
+ + + + + +
Extends @@ -521,13 +559,17 @@
- + Extends - - + + + + + + diff --git a/src/main/java/storage/fileEditors/FileEditor.java b/src/main/java/storage/fileEditors/FileEditor.java new file mode 100644 index 0000000..aedf218 --- /dev/null +++ b/src/main/java/storage/fileEditors/FileEditor.java @@ -0,0 +1,24 @@ +package storage.fileEditors; + +import java.io.File; +import java.nio.file.Path; + +public abstract class FileEditor implements FileReader, FileWriter { + + public T readFrom(File file) { + return readFrom(file.getAbsolutePath()); + } + + public T store(Path path) { + return readFrom(path.toString()); + } + + public void store(File file, T contents) { + store(file.getAbsolutePath(), contents); + } + + public void store(Path path, T contents) { + store(path.toString(), contents); + } + +} diff --git a/src/main/java/storage/fileEditors/FileReader.java b/src/main/java/storage/fileEditors/FileReader.java new file mode 100644 index 0000000..bf3c9c4 --- /dev/null +++ b/src/main/java/storage/fileEditors/FileReader.java @@ -0,0 +1,5 @@ +package storage.fileEditors; + +public interface FileReader { + public abstract T readFrom(String path); +} diff --git a/src/main/java/storage/fileEditors/FileWriter.java b/src/main/java/storage/fileEditors/FileWriter.java new file mode 100644 index 0000000..a3263b3 --- /dev/null +++ b/src/main/java/storage/fileEditors/FileWriter.java @@ -0,0 +1,5 @@ +package storage.fileEditors; + +public interface FileWriter { + public abstract void store(String path, T contents); +} \ No newline at end of file diff --git a/src/main/java/storage/fileWriters/StringFileWriter.java b/src/main/java/storage/fileEditors/StringFileWriter.java similarity index 54% rename from src/main/java/storage/fileWriters/StringFileWriter.java rename to src/main/java/storage/fileEditors/StringFileWriter.java index ad10b26..04c4c78 100644 --- a/src/main/java/storage/fileWriters/StringFileWriter.java +++ b/src/main/java/storage/fileEditors/StringFileWriter.java @@ -1,9 +1,9 @@ -package storage.fileWriters; +package storage.fileEditors; import java.io.*; import java.nio.file.*; -public class StringFileWriter extends FileWriter { +public class StringFileWriter extends FileEditor { @Override public void store(String path, String contents) { @@ -13,5 +13,11 @@ public void store(String path, String contents) { new UncheckedIOException("Failed to store content to \"" + path + "\"", e); } } + + @Override + public String readFrom(String path) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'readFrom'"); + } } diff --git a/src/main/java/storage/fileWriters/FileWriter.java b/src/main/java/storage/fileWriters/FileWriter.java deleted file mode 100644 index a12df41..0000000 --- a/src/main/java/storage/fileWriters/FileWriter.java +++ /dev/null @@ -1,17 +0,0 @@ -package storage.fileWriters; - -import java.io.File; -import java.nio.file.Path; - -public abstract class FileWriter { - - public void store(File file, T contents) { - store(file.getAbsolutePath(), contents); - } - - public void store(Path path, T contents) { - store(path.toAbsolutePath(), contents); - } - - public abstract void store(String path, T contents); -} \ No newline at end of file From 1a8e33a90d344ecf686eefe37044b5bab910fc70 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 22 Jan 2025 21:56:07 +0000 Subject: [PATCH 011/162] Storage methods converted to Value formatters --- docs/diagrams/Storage.drawio.svg | 54 ++++++++--------- .../storage/storageMethods/StorageMethod.java | 55 ------------------ .../storage/storageMethods/StringStorage.java | 58 ------------------- .../valueFormatters/StringStorage.java | 31 ++++++++++ .../valueFormatters/ValueFormatter.java | 8 +++ 5 files changed, 66 insertions(+), 140 deletions(-) delete mode 100644 src/main/java/storage/storageMethods/StorageMethod.java delete mode 100644 src/main/java/storage/storageMethods/StringStorage.java create mode 100644 src/main/java/storage/valueFormatters/StringStorage.java create mode 100644 src/main/java/storage/valueFormatters/ValueFormatter.java diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index b5ad449..e20d689 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,4 +1,4 @@ - + @@ -101,49 +101,49 @@
- Storage Methods + Value Formatters
- Storage Methods + Value Formatters
- + -
+
- StorageMethod<T> + ValueFormatter<T>
- <A> + <I>
- StorageMethod<T>... + ValueFormatter<T>... - + -
+
- StringStorage + ValueToStringFormatter
- StringStorage + ValueToStringFormatter @@ -187,7 +187,7 @@ -
+
Produces a set of @@ -195,7 +195,7 @@
- + Produces a set of @@ -325,12 +325,12 @@ - - + + -
+
Passed into @@ -338,7 +338,7 @@
- + Passed into @@ -378,14 +378,14 @@ - - - + + + -
+
Throws @@ -393,7 +393,7 @@
- + Throws @@ -421,7 +421,7 @@ -
+
Produces @@ -436,11 +436,11 @@ - + -
+
Storage Representation @@ -449,7 +449,7 @@
- Storage Representation + Storage Represen... diff --git a/src/main/java/storage/storageMethods/StorageMethod.java b/src/main/java/storage/storageMethods/StorageMethod.java deleted file mode 100644 index d5de0a5..0000000 --- a/src/main/java/storage/storageMethods/StorageMethod.java +++ /dev/null @@ -1,55 +0,0 @@ -package storage.storageMethods; - -import java.nio.file.*; - -import storage.storageValues.StorageValue; - -public abstract class StorageMethod { - - protected static final String DEFAULT_FILE_PATH = "./compilerStorage"; - - protected String filePath; - protected String fileExtension; - - protected Path storageFile; - - /** - * Initiates this storage method with a default filepath of ./compilerStorage and a prechosen file extension. - */ - public StorageMethod() { - filePath = DEFAULT_FILE_PATH; - fileExtension = defineFileExtension(); - - createStoragePath(filePath, fileExtension); - } - - /** - * Initiates this storage method with a custom filepath of ./compilerStorage and a prechosen file extension. - * @param filePath The path of the storage file - */ - public StorageMethod(String filePath) { - filePath = DEFAULT_FILE_PATH; - - createStoragePath(filePath, fileExtension); - } - - - private void createStoragePath(String path, String extension) { - try { - storageFile = Paths.get(path + extension); - } catch (InvalidPathException e) { - throw e; - } catch (NullPointerException e) { - throw e; // TODO: Test how to cause this, and make appropriate error message if not already provided. - } - } - - /** - * Defines the file extension to use when creating the storage file. This must be in the form ".". - * @return The file extension for the storage file - */ - protected abstract String defineFileExtension(); - - public abstract void store(String key, String storageType, T value); // TODO: Consider wiping file on first storage attempt - public abstract StorageValue load(String key); -} diff --git a/src/main/java/storage/storageMethods/StringStorage.java b/src/main/java/storage/storageMethods/StringStorage.java deleted file mode 100644 index 5585e2f..0000000 --- a/src/main/java/storage/storageMethods/StringStorage.java +++ /dev/null @@ -1,58 +0,0 @@ -package storage.storageMethods; - -import java.io.*; -import java.nio.file.Files; -import java.util.*; -import java.util.stream.Stream; - -import storage.FileOperations; -import storage.helper_objects.DuplicateKeyException; -import storage.storageValues.*; - -public class StringStorage extends StorageMethod { - - protected static final String KEY_VALUE_SEPERATOR = " : "; - - boolean storageUsed = false; - List existingKeys = new ArrayList(); - - @Override - protected String defineFileExtension() { - return ".storage.txt"; - } - - @Override - public void store(String key, String storageType, String value) { - if (existingKeys.contains(key)) throw new DuplicateKeyException(key); - - if (!storageUsed) { - if (!FileOperations.fileExists(storageFile)) - FileOperations.createFile(storageFile); - else - FileOperations.eraseFileContents(storageFile); - } - - if (key.contains("KEY_VALUE_SEPERATOR")) throw new IllegalArgumentException("The character sequence \'" + KEY_VALUE_SEPERATOR + "\' may not appear within a key"); - if (key.contains("\n")) throw new IllegalArgumentException("Newline characters may not appear within a key"); - - FileOperations.appendLine(storageFile, key + KEY_VALUE_SEPERATOR + value); - - storageUsed = true; - existingKeys.add(key); - } - - @Override - public StorageValue load(String key) { - try (Stream stream = Files.lines(storageFile)) { - List keyLines = stream.filter(line -> line.startsWith(key)).toList(); - String line = keyLines.get(0); - - String value = line.split(KEY_VALUE_SEPERATOR, 2)[1]; - return new StringStorageValue(value); - } - catch (IOException e) { - throw new UncheckedIOException("The file " + storageFile.toString() + "could not be appended to.", e); - } - } - -} diff --git a/src/main/java/storage/valueFormatters/StringStorage.java b/src/main/java/storage/valueFormatters/StringStorage.java new file mode 100644 index 0000000..8b44de3 --- /dev/null +++ b/src/main/java/storage/valueFormatters/StringStorage.java @@ -0,0 +1,31 @@ +package storage.valueFormatters; + +import java.io.*; +import java.nio.file.Files; +import java.util.*; +import java.util.stream.Stream; + +import storage.FileOperations; +import storage.helper_objects.DuplicateKeyException; +import storage.storageValues.*; + +public class StringStorage implements ValueFormatter { + + protected static final String KEY_VALUE_SEPERATOR = " : "; + + boolean storageUsed = false; + List existingKeys = new ArrayList(); + + @Override + public String format(StorageValue value) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'format'"); + } + + @Override + public StorageValue parse(String formattedData) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'parse'"); + } + +} diff --git a/src/main/java/storage/valueFormatters/ValueFormatter.java b/src/main/java/storage/valueFormatters/ValueFormatter.java new file mode 100644 index 0000000..e01819b --- /dev/null +++ b/src/main/java/storage/valueFormatters/ValueFormatter.java @@ -0,0 +1,8 @@ +package storage.valueFormatters; + +import storage.storageValues.StorageValue; + +public interface ValueFormatter { + public F format(StorageValue value); + public StorageValue parse(F formattedData); +} From ec2638e6343472db48efe3e6876eac5aab201b26 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 24 Jan 2025 22:27:14 +0000 Subject: [PATCH 012/162] StringFileEditor reading contents --- .../storage/fileEditors/StringFileEditor.java | 27 +++++++++++++++++++ .../storage/fileEditors/StringFileWriter.java | 23 ---------------- 2 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 src/main/java/storage/fileEditors/StringFileEditor.java delete mode 100644 src/main/java/storage/fileEditors/StringFileWriter.java diff --git a/src/main/java/storage/fileEditors/StringFileEditor.java b/src/main/java/storage/fileEditors/StringFileEditor.java new file mode 100644 index 0000000..81196db --- /dev/null +++ b/src/main/java/storage/fileEditors/StringFileEditor.java @@ -0,0 +1,27 @@ +package storage.fileEditors; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.nio.file.*; + +public class StringFileEditor extends FileEditor { + + @Override + public void store(String path, String contents) throws UncheckedIOException { + try { + Files.writeString(Paths.get(path), contents); + } catch (IOException e) { + throw new UncheckedIOException("Failed to store content to \"" + path + "\"", e); + } + } + + @Override + public String readFrom(String path) throws UncheckedIOException { + try { + return Files.readString(Paths.get(path), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new UncheckedIOException("Failed to read the contents from \"" + path + "\"", e); + } + } + +} diff --git a/src/main/java/storage/fileEditors/StringFileWriter.java b/src/main/java/storage/fileEditors/StringFileWriter.java deleted file mode 100644 index 04c4c78..0000000 --- a/src/main/java/storage/fileEditors/StringFileWriter.java +++ /dev/null @@ -1,23 +0,0 @@ -package storage.fileEditors; - -import java.io.*; -import java.nio.file.*; - -public class StringFileWriter extends FileEditor { - - @Override - public void store(String path, String contents) { - try { - Files.writeString(Paths.get(path), contents); - } catch (IOException e) { - new UncheckedIOException("Failed to store content to \"" + path + "\"", e); - } - } - - @Override - public String readFrom(String path) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'readFrom'"); - } - -} From 19ad36c4956e92afe6f1adff8417127836f1a4ad Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 24 Jan 2025 23:01:56 +0000 Subject: [PATCH 013/162] ValueToStringFormatter --- .../{StringStorage.java => ValueToStringFormatter.java} | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) rename src/main/java/storage/valueFormatters/{StringStorage.java => ValueToStringFormatter.java} (74%) diff --git a/src/main/java/storage/valueFormatters/StringStorage.java b/src/main/java/storage/valueFormatters/ValueToStringFormatter.java similarity index 74% rename from src/main/java/storage/valueFormatters/StringStorage.java rename to src/main/java/storage/valueFormatters/ValueToStringFormatter.java index 8b44de3..5f15934 100644 --- a/src/main/java/storage/valueFormatters/StringStorage.java +++ b/src/main/java/storage/valueFormatters/ValueToStringFormatter.java @@ -1,15 +1,9 @@ package storage.valueFormatters; -import java.io.*; -import java.nio.file.Files; import java.util.*; -import java.util.stream.Stream; - -import storage.FileOperations; -import storage.helper_objects.DuplicateKeyException; import storage.storageValues.*; -public class StringStorage implements ValueFormatter { +public class ValueToStringFormatter implements ValueFormatter { protected static final String KEY_VALUE_SEPERATOR = " : "; From 4b8672b08851d50de79dc7735984bec209a0e525 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 30 Jan 2025 23:46:06 +0000 Subject: [PATCH 014/162] Formatter exceptions and start of ValueToStringFormatter --- .../helper_objects/DuplicateKeyException.java | 3 ++- .../UnsupportedValueException.java | 15 ++++++++++- .../ValueToStringFormatter.java | 25 ++++++++++++++----- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/main/java/storage/helper_objects/DuplicateKeyException.java b/src/main/java/storage/helper_objects/DuplicateKeyException.java index 541a380..8b0e8ea 100644 --- a/src/main/java/storage/helper_objects/DuplicateKeyException.java +++ b/src/main/java/storage/helper_objects/DuplicateKeyException.java @@ -1,8 +1,9 @@ package storage.helper_objects; public class DuplicateKeyException extends RuntimeException { - + public DuplicateKeyException(T key) { super("Duplicated definition of the key \'" + key.toString() + " was provided."); } + } diff --git a/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java b/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java index 6e08c63..602ea22 100644 --- a/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java +++ b/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java @@ -1,5 +1,18 @@ package storage.storageValueAdapters; +import storage.storageValues.StorageValue; + public class UnsupportedValueException extends RuntimeException { -} + public UnsupportedValueException(StorageValue value) { + super(value.getClass().toString() + " is not supported by this formatter."); + } + + public UnsupportedValueException() { + super( + "The input could not be parsed by this formatter.\n" + + "If the data was intended for this formatter, the data may be malformed." + + "Otherwise, Try a different formatter or develop a custom formatter for this data." + ); + } +} \ No newline at end of file diff --git a/src/main/java/storage/valueFormatters/ValueToStringFormatter.java b/src/main/java/storage/valueFormatters/ValueToStringFormatter.java index 5f15934..9fc1d7d 100644 --- a/src/main/java/storage/valueFormatters/ValueToStringFormatter.java +++ b/src/main/java/storage/valueFormatters/ValueToStringFormatter.java @@ -1,6 +1,8 @@ package storage.valueFormatters; import java.util.*; + +import storage.storageValueAdapters.UnsupportedValueException; import storage.storageValues.*; public class ValueToStringFormatter implements ValueFormatter { @@ -11,15 +13,26 @@ public class ValueToStringFormatter implements ValueFormatter { List existingKeys = new ArrayList(); @Override - public String format(StorageValue value) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'format'"); + public String format(StorageValue value) throws UnsupportedValueException { + if (value instanceof StringStorageValue) return formatValue((StringStorageValue)value); + if (value instanceof IntegerStorageValue) return formatValue((IntegerStorageValue)value); + //TODO: Add more value types and ensure types are differentiatable from their stored formats + throw new UnsupportedValueException(value); } @Override - public StorageValue parse(String formattedData) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'parse'"); + public StorageValue parse(String formattedData) throws UnsupportedValueException { + //TODO + throw new UnsupportedValueException(); + } + + + private String formatValue(StringStorageValue value) { + return value.getValue(); + } + + private String formatValue(IntegerStorageValue value) { + return String.valueOf(value.getValue()); } } From 74df7bf9509a26ebb2f06b10ddf826f895b70130 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 22 Mar 2025 13:32:54 +0000 Subject: [PATCH 015/162] Fixed interface usage in storage diagram --- docs/diagrams/Storage.drawio.svg | 1128 ++++++++++++++++-------------- 1 file changed, 615 insertions(+), 513 deletions(-) diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index e20d689..c540769 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,579 +1,681 @@ - + - - - - -
-
-
- Storable <I> -
-
-
-
- - Storable <... - -
-
- - - - - - -
-
-
- Storage Values -
-
-
-
- - Storage Values - -
-
- - - - -
-
-
- StorageValue<T> -
- <A> + + + + + + + +
+
+
+ Storable <I> +
-
- - - StorageValue<T>... - - - - - - - -
-
-
- StringStorageValue + + + Storable <... + + + + + + + + + + + + + +
+
+
+ Storage Values +
-
- - - StringStorageValue - - - - - - - - -
-
-
- Extends + + + Storage Values + + + + + + + + + + + +
+
+
+ StorageValue<T> +
+ <A> +
-
- - - Extends - - - - - - - - - - -
-
-
- Value Formatters + + + StorageValue<T>... + + + + + + + + + + + +
+
+
+ StringStorageValue +
-
- - - Value Formatters - - - - - - - -
-
-
- ValueFormatter<T> -
- <I> + + + StringStorageValue + + + + + + + + + + + + +
+
+
+ Extends +
-
- - - ValueFormatter<T>... - - - - - - - -
-
-
- ValueToStringFormatter + + + Extends + + + + + + + + + + + + + + + + +
+
+
+ Value Formatters +
-
- - - ValueToStringFormatter - - - - - - - - -
-
-
- Extends + + + Value Formatters + + + + + + + + + + + +
+
+
+ ValueFormatter<T> +
+ <I> +
-
- - - Extends - - - - - - - -
-
-
- Loadable <I> + + + ValueFormatter<T>... + + + + + + + + + + + +
+
+
+ ValueToStringFormatter +
-
- - - Loadable <... - - - - - - - - -
-
-
- Produces a set of + + + ValueToStringFormatter + + + + + + + + + + + + +
+
+
+ Extends +
-
- - - Produces a set of - - - - - - - -
-
-
- Compiler Component + + + Extends + + + + + + + + + + + +
+
+
+ Loadable <I> +
-
- - - Compiler Comp... - - - - - - - - -
-
-
- Extends + + + Loadable <... + + + + + + + + + + + + +
+
+
+ Produces a set of +
-
- - - Extends - - - - - - - - -
-
-
- Extends + + + Produces a set of + + + + + + + + + + + +
+
+
+ Compiler Component +
-
- - - Extends - - - - - - - - - -
-
-
- Storage Value Adapters + + + Compiler Comp... + + + + + + + + + + + + + +
+
+
+ Storage Value Adapters +
-
- - - Storage Value Adapters - - - - - - - -
-
-
- StorageValueAdapter <I> + + + Storage Value Adapters + + + + + + + + + + + +
+
+
+ StorageValueAdapter <I> +
-
- - - StorageValueAdapter <... - - - - - - - -
-
-
- StringValueToString + + + StorageValueAdapter <... + + + + + + + + + + + +
+
+
+ StringValueToString +
-
- - - StringValueToString - - - - - - - -
-
-
- UnsupportedValueException + + + StringValueToString + + + + + + + + + + + +
+
+
+ UnsupportedValueException +
-
- - - UnsupportedValueException - - - - - - - - - - -
-
-
- Passed into + + + UnsupportedValueException + + + + + + + + + + + + + + + + +
+
+
+ Passed into +
-
- - - Passed into - - - - - - - -
-
-
- RuntimeException + + + Passed into + + + + + + + + + + + +
+
+
+ RuntimeException +
-
- - - RuntimeException - - - - - - - - -
-
-
- Extends + + + RuntimeException + + + + + + + + + + + + +
+
+
+ Extends +
-
- - - Extends - - - - - - - - - - -
-
-
- Throws + + + Extends + + + + + + + + + + + + + + + + +
+
+
+ Throws +
-
- - - Throws - - - - - - - - -
-
-
- Storage File + + + Throws + + + + + + + + + + + + +
+
+
+ Storage File +
-
- - - Storage File - - - - - - - - -
-
-
- Produces + + + Storage File + + + + + + + + + + + + +
+
+
+ Produces +
-
- - - Produces - - - - - - - - - -
-
-
- Storage Representation + + + Produces + + + + + + + + + + + + + + + +
+
+
+ Storage Representation +
-
- - - Storage Represen... - - - - - - - - - -
-
-
- File Editors + + + Storage Represen... + + + + + + + + + + + + + +
+
+
+ File Editors +
-
- - - File Editors - - - - - - - -
-
-
- FileWriter<T> -
- <I> + + + File Editors + + + + + + + + + + + +
+
+
+ FileWriter<T> +
+ <I> +
-
- - - FileWriter<T>... - - - - - - - -
-
-
- StringFileWriter + + + FileWriter<T>... + + + + + + + + + + + +
+
+
+ StringFileWriter +
-
- - - StringFileWriter - - - - - - - -
-
-
- FileReader<T> -
- <I> + + + StringFileWriter + + + + + + + + + + + +
+
+
+ FileReader<T> +
+ <I> +
-
- - - FileReader<T>... - - - - - - - -
-
-
- FileEditor<T> -
- <A> + + + FileReader<T>... + + + + + + + + + + + +
+
+
+ FileEditor<T> +
+ <A> +
-
- - - FileEditor<T>... - - - - - - - - -
-
-
- Extends + + + FileEditor<T>... + + + + + + + + + + + + +
+
+
+ Extends +
-
- - - Extends - - - - - - - - - + + + Extends + + + + + + + + + + + + + + + + + + + + + + + + - + Text is not SVG - cannot display From 153ea79c350e057e69052c8dfcf2fa6c441be5c5 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 22 Mar 2025 15:20:26 +0000 Subject: [PATCH 016/162] Small clarity refactor in build.gradle --- build.gradle | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index fa02c46..9ebc291 100644 --- a/build.gradle +++ b/build.gradle @@ -46,16 +46,18 @@ tasks.named('test') { events = [TestLogEvent.STARTED, TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.STANDARD_ERROR, TestLogEvent.STANDARD_OUT] exceptionFormat = TestExceptionFormat.FULL } + info.events = debug.events info.exceptionFormat = debug.exceptionFormat afterSuite { desc, result -> - if (!desc.parent) { - def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)" - def startItem = '| ', endItem = ' |' - def repeatLength = startItem.length() + output.length() + endItem.length() - println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength)) - } + if (desc.parent) return + + def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)" + def startItem = '| ', endItem = ' |' + def repeatLength = startItem.length() + output.length() + endItem.length() + + println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength)) } } } From fcd291b0defcad93cc209f62f38abca87e15187c Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 30 Mar 2025 14:50:00 +0100 Subject: [PATCH 017/162] StorageValue .equals and tests --- .../storage/storageValues/StorageValue.java | 11 ++++ .../storageValues/StorageValueTests.java | 54 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/test/java/storage/storageValues/StorageValueTests.java diff --git a/src/main/java/storage/storageValues/StorageValue.java b/src/main/java/storage/storageValues/StorageValue.java index 580ceb4..07500ae 100644 --- a/src/main/java/storage/storageValues/StorageValue.java +++ b/src/main/java/storage/storageValues/StorageValue.java @@ -10,4 +10,15 @@ public StorageValue(T value) { public T getValue() { return value; } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + + StorageValue other = (StorageValue) obj; + if (value == null) return other.value == null; + return value.equals(other.value); + } } diff --git a/src/test/java/storage/storageValues/StorageValueTests.java b/src/test/java/storage/storageValues/StorageValueTests.java new file mode 100644 index 0000000..2daaf34 --- /dev/null +++ b/src/test/java/storage/storageValues/StorageValueTests.java @@ -0,0 +1,54 @@ +package storage.storageValues; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +public class StorageValueTests { + + @Test + public void nonEquality() { + String strValue = "0"; + Integer intValue = Integer.parseInt(strValue); + + StringStorageValue strStorage = new StringStorageValue(strValue); + IntegerStorageValue intStorage = new IntegerStorageValue(intValue); + + assertNotEquals(strStorage, intStorage); + } + + @Test + public void equality() { + String strValue = "0"; + Integer intValue = Integer.parseInt(strValue); + + StringStorageValue strStorage1 = new StringStorageValue(strValue); + IntegerStorageValue intStorage1 = new IntegerStorageValue(intValue); + + StringStorageValue strStorage2 = new StringStorageValue(strValue); + IntegerStorageValue intStorage2 = new IntegerStorageValue(intValue); + + assertEquals(strStorage1, strStorage2); + assertEquals(intStorage1, intStorage2); + } + + @Test + public void nullNonEquality() { + String strValue = null; + Integer intValue = null; + + StringStorageValue strStorage = new StringStorageValue(strValue); + IntegerStorageValue intStorage = new IntegerStorageValue(intValue); + + assertNotEquals(strStorage, intStorage); + } + + @Test + public void nullEquality() { + String strValue = null; + + StringStorageValue strStorage1 = new StringStorageValue(strValue); + StringStorageValue strStorage2 = new StringStorageValue(strValue); + + assertEquals(strStorage1, strStorage2); + } +} From fc401407f55e5ef4d1cb518dff5f82b457ad97fa Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 31 Mar 2025 00:11:57 +0100 Subject: [PATCH 018/162] ValueToStringFormatter beginning --- src/main/java/helper_objects/ValueEnum.java | 5 ++ .../storageValues/MapStorageValue.java | 4 +- .../valueFormatters/ValueFormatter.java | 5 +- .../ValueToStringFormatter.java | 88 ++++++++++++++++++- .../ValueToStringFormatterTests.java | 69 +++++++++++++++ 5 files changed, 164 insertions(+), 7 deletions(-) create mode 100644 src/main/java/helper_objects/ValueEnum.java create mode 100644 src/test/java/storage/valueFormatters/ValueToStringFormatterTests.java diff --git a/src/main/java/helper_objects/ValueEnum.java b/src/main/java/helper_objects/ValueEnum.java new file mode 100644 index 0000000..74baf21 --- /dev/null +++ b/src/main/java/helper_objects/ValueEnum.java @@ -0,0 +1,5 @@ +package helper_objects; + +public interface ValueEnum { + public T getValue(); +} diff --git a/src/main/java/storage/storageValues/MapStorageValue.java b/src/main/java/storage/storageValues/MapStorageValue.java index d4a6f13..2388bf8 100644 --- a/src/main/java/storage/storageValues/MapStorageValue.java +++ b/src/main/java/storage/storageValues/MapStorageValue.java @@ -2,9 +2,9 @@ import java.util.Map; -public class MapStorageValue extends StorageValue>> { +public class MapStorageValue extends StorageValue>> { - public MapStorageValue(Map> map) { + public MapStorageValue(Map> map) { super(map); } diff --git a/src/main/java/storage/valueFormatters/ValueFormatter.java b/src/main/java/storage/valueFormatters/ValueFormatter.java index e01819b..4442687 100644 --- a/src/main/java/storage/valueFormatters/ValueFormatter.java +++ b/src/main/java/storage/valueFormatters/ValueFormatter.java @@ -1,8 +1,9 @@ package storage.valueFormatters; +import storage.storageValueAdapters.UnsupportedValueException; import storage.storageValues.StorageValue; public interface ValueFormatter { - public F format(StorageValue value); - public StorageValue parse(F formattedData); + public F format(StorageValue value) throws UnsupportedValueException; + public StorageValue parse(F formattedData) throws UnsupportedValueException; } diff --git a/src/main/java/storage/valueFormatters/ValueToStringFormatter.java b/src/main/java/storage/valueFormatters/ValueToStringFormatter.java index 9fc1d7d..7c328ab 100644 --- a/src/main/java/storage/valueFormatters/ValueToStringFormatter.java +++ b/src/main/java/storage/valueFormatters/ValueToStringFormatter.java @@ -1,13 +1,38 @@ package storage.valueFormatters; import java.util.*; +import java.util.Map.Entry; import storage.storageValueAdapters.UnsupportedValueException; import storage.storageValues.*; +import helper_objects.ValueEnum; public class ValueToStringFormatter implements ValueFormatter { protected static final String KEY_VALUE_SEPERATOR = " : "; + protected static final String INDENT = " "; + + protected static enum PREFIXES implements ValueEnum { + STRING("str:"), + INTEGER("int:"), + MAP("map:"); + + private String value; + + private PREFIXES(String value) { + this.value = value; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } + } boolean storageUsed = false; List existingKeys = new ArrayList(); @@ -16,23 +41,80 @@ public class ValueToStringFormatter implements ValueFormatter { public String format(StorageValue value) throws UnsupportedValueException { if (value instanceof StringStorageValue) return formatValue((StringStorageValue)value); if (value instanceof IntegerStorageValue) return formatValue((IntegerStorageValue)value); + if (value instanceof MapStorageValue) return formatValue((MapStorageValue)value); + //TODO: Add more value types and ensure types are differentiatable from their stored formats throw new UnsupportedValueException(value); } @Override public StorageValue parse(String formattedData) throws UnsupportedValueException { - //TODO + if (formattedData.startsWith(PREFIXES.STRING.getValue())) return parseStringFormat(formattedData); + if (formattedData.startsWith(PREFIXES.INTEGER.getValue())) return parseIntegerFormat(formattedData); + if (formattedData.startsWith(PREFIXES.MAP.getValue())) return parseMapFormat(formattedData); + + //TODO: Add more value types throw new UnsupportedValueException(); } private String formatValue(StringStorageValue value) { - return value.getValue(); + String formattedString = PREFIXES.STRING.getValue(); + formattedString += value.getValue().replace("\\", "\\\\"); + + return formattedString; + } + + private StringStorageValue parseStringFormat(String formattedData) { + formattedData = formattedData.replaceFirst(PREFIXES.STRING.getValue(), ""); + formattedData = formattedData.replace("\\\\", "\\"); + return new StringStorageValue(formattedData); } private String formatValue(IntegerStorageValue value) { - return String.valueOf(value.getValue()); + return PREFIXES.INTEGER + String.valueOf(value.getValue()); + } + + private IntegerStorageValue parseIntegerFormat(String formattedData) { + formattedData = formattedData.replaceFirst(PREFIXES.INTEGER.getValue(), ""); + return new IntegerStorageValue(Integer.parseInt(formattedData)); } + private String formatValue(MapStorageValue value) { + Set>> mapEntries = value.getValue().entrySet(); + if (mapEntries.isEmpty()) return "{}"; + + String out = PREFIXES.MAP + "{\n"; + + for (Entry> entry : mapEntries) { + out += INDENT + entry.getKey() + ":" + entry.getValue() + ",\n"; //TODO: Test for values containing "",\n" + } + + out = out.substring(0, out.length() - 3); //Remove trailing ",\n" + + return out + "}"; + } + + private MapStorageValue parseMapFormat(String formattedData) { + formattedData = formattedData.replaceFirst(PREFIXES.MAP.getValue(), ""); + + if (formattedData.equals("{}") || formattedData.equals("{\n}")) + return new MapStorageValue(Map.of()); + + formattedData = formattedData.replaceFirst(PREFIXES.MAP.getValue() + "{\n", ""); + formattedData = formattedData.substring(0, formattedData.length() - 2); // Remove ending "}" + + Map> map = new HashMap<>(); + + for (String entry : formattedData.split(",\n")) { + String[] parts = entry.split(":", 2); + + map.put( + parts[0], + this.parseMapFormat(parts[1]) + ); + } + + return new MapStorageValue(map); + } } diff --git a/src/test/java/storage/valueFormatters/ValueToStringFormatterTests.java b/src/test/java/storage/valueFormatters/ValueToStringFormatterTests.java new file mode 100644 index 0000000..cdc85b0 --- /dev/null +++ b/src/test/java/storage/valueFormatters/ValueToStringFormatterTests.java @@ -0,0 +1,69 @@ +package storage.valueFormatters; +import static org.junit.jupiter.api.Assertions.*; + +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import storage.storageValueAdapters.UnsupportedValueException; +import storage.storageValues.*; + +public class ValueToStringFormatterTests { + + @Test + public void parseFormattedString() { + String str = "Java"; + String formattedString = "str:" + str; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue = valueFormatter.parse(formattedString); + + StringStorageValue expectedValue = new StringStorageValue(str); + assertEquals(expectedValue, actualValue); + } + + @Test + public void parseUnformattedString() { + String str = "Java"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + assertThrows(UnsupportedValueException.class, () -> valueFormatter.parse(str)); + } + + @Test + public void parseFormattedInteger() { + Integer integer = 10; + String formattedString = "int:" + Integer.toString(integer); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue = valueFormatter.parse(formattedString); + + IntegerStorageValue expectedValue = new IntegerStorageValue(10); + assertEquals(expectedValue, actualValue); + } + + @Test + public void parseUnformattedInteger() { + String str = "10"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + assertThrows(UnsupportedValueException.class, () -> valueFormatter.parse(str)); + } + + @Test + public void parseFormattedEmptyMap() { + String formattedString1 = "map:{}"; + String formattedString2 = "map:{\n}"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + StorageValue actualValue2 = valueFormatter.parse(formattedString2); + + MapStorageValue expectedValue = new MapStorageValue(Map.of()); + assertEquals(expectedValue, actualValue1); + assertEquals(expectedValue, actualValue2); + } + + //TODO: Test MapStorageValue with various contents (including nested maps) + //TODO: Fomatting of StorageValues +} From aa4aa44fb9b6b8a7038139329bd9e3f198b15d66 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 31 Mar 2025 19:02:50 +0100 Subject: [PATCH 019/162] Folder renaming for consistency --- src/main/java/storage/StorageData.java | 3 ++- .../storage/{fileEditors => file_editors}/FileEditor.java | 2 +- .../storage/{fileEditors => file_editors}/FileReader.java | 2 +- .../storage/{fileEditors => file_editors}/FileWriter.java | 2 +- .../{fileEditors => file_editors}/StringFileEditor.java | 2 +- .../StorageValueAdapter.java | 4 ++-- .../UnsupportedValueException.java | 4 ++-- .../IntegerStorageValue.java | 2 +- .../MapStorageValue.java | 2 +- .../{storageValues => storage_values}/StorageValue.java | 2 +- .../StringStorageValue.java | 2 +- .../ValueFormatter.java | 6 +++--- .../ValueToStringFormatter.java | 6 +++--- .../StorageValueTests.java | 5 ++++- .../ValueToStringFormatterTests.java | 8 +++++--- 15 files changed, 29 insertions(+), 23 deletions(-) rename src/main/java/storage/{fileEditors => file_editors}/FileEditor.java (94%) rename src/main/java/storage/{fileEditors => file_editors}/FileReader.java (72%) rename src/main/java/storage/{fileEditors => file_editors}/FileWriter.java (75%) rename src/main/java/storage/{fileEditors => file_editors}/StringFileEditor.java (96%) rename src/main/java/storage/{storageValueAdapters => storage_value_adapters}/StorageValueAdapter.java (77%) rename src/main/java/storage/{storageValueAdapters => storage_value_adapters}/UnsupportedValueException.java (86%) rename src/main/java/storage/{storageValues => storage_values}/IntegerStorageValue.java (83%) rename src/main/java/storage/{storageValues => storage_values}/MapStorageValue.java (86%) rename src/main/java/storage/{storageValues => storage_values}/StorageValue.java (94%) rename src/main/java/storage/{storageValues => storage_values}/StringStorageValue.java (82%) rename src/main/java/storage/{valueFormatters => value_formatters}/ValueFormatter.java (58%) rename src/main/java/storage/{valueFormatters => value_formatters}/ValueToStringFormatter.java (96%) rename src/test/java/storage/{storageValues => storage_values}/StorageValueTests.java (92%) rename src/test/java/storage/{valueFormatters => value_formatters}/ValueToStringFormatterTests.java (90%) diff --git a/src/main/java/storage/StorageData.java b/src/main/java/storage/StorageData.java index 389ae86..cd96cdd 100644 --- a/src/main/java/storage/StorageData.java +++ b/src/main/java/storage/StorageData.java @@ -1,7 +1,8 @@ package storage; import java.util.HashMap; -import storage.storageValues.StorageValue; + +import storage.storage_values.StorageValue; /** * A memento/storage object for Storable objects diff --git a/src/main/java/storage/fileEditors/FileEditor.java b/src/main/java/storage/file_editors/FileEditor.java similarity index 94% rename from src/main/java/storage/fileEditors/FileEditor.java rename to src/main/java/storage/file_editors/FileEditor.java index aedf218..fa6820c 100644 --- a/src/main/java/storage/fileEditors/FileEditor.java +++ b/src/main/java/storage/file_editors/FileEditor.java @@ -1,4 +1,4 @@ -package storage.fileEditors; +package storage.file_editors; import java.io.File; import java.nio.file.Path; diff --git a/src/main/java/storage/fileEditors/FileReader.java b/src/main/java/storage/file_editors/FileReader.java similarity index 72% rename from src/main/java/storage/fileEditors/FileReader.java rename to src/main/java/storage/file_editors/FileReader.java index bf3c9c4..a5fff65 100644 --- a/src/main/java/storage/fileEditors/FileReader.java +++ b/src/main/java/storage/file_editors/FileReader.java @@ -1,4 +1,4 @@ -package storage.fileEditors; +package storage.file_editors; public interface FileReader { public abstract T readFrom(String path); diff --git a/src/main/java/storage/fileEditors/FileWriter.java b/src/main/java/storage/file_editors/FileWriter.java similarity index 75% rename from src/main/java/storage/fileEditors/FileWriter.java rename to src/main/java/storage/file_editors/FileWriter.java index a3263b3..817e089 100644 --- a/src/main/java/storage/fileEditors/FileWriter.java +++ b/src/main/java/storage/file_editors/FileWriter.java @@ -1,4 +1,4 @@ -package storage.fileEditors; +package storage.file_editors; public interface FileWriter { public abstract void store(String path, T contents); diff --git a/src/main/java/storage/fileEditors/StringFileEditor.java b/src/main/java/storage/file_editors/StringFileEditor.java similarity index 96% rename from src/main/java/storage/fileEditors/StringFileEditor.java rename to src/main/java/storage/file_editors/StringFileEditor.java index 81196db..bf92208 100644 --- a/src/main/java/storage/fileEditors/StringFileEditor.java +++ b/src/main/java/storage/file_editors/StringFileEditor.java @@ -1,4 +1,4 @@ -package storage.fileEditors; +package storage.file_editors; import java.io.*; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/storage/storageValueAdapters/StorageValueAdapter.java b/src/main/java/storage/storage_value_adapters/StorageValueAdapter.java similarity index 77% rename from src/main/java/storage/storageValueAdapters/StorageValueAdapter.java rename to src/main/java/storage/storage_value_adapters/StorageValueAdapter.java index 03d23e3..d9e70cf 100644 --- a/src/main/java/storage/storageValueAdapters/StorageValueAdapter.java +++ b/src/main/java/storage/storage_value_adapters/StorageValueAdapter.java @@ -1,6 +1,6 @@ -package storage.storageValueAdapters; +package storage.storage_value_adapters; -import storage.storageValues.StorageValue; +import storage.storage_values.StorageValue; /** * An interface that defines an adapter converting StorageValues to a chosen representation for use within a StorageMethod diff --git a/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java b/src/main/java/storage/storage_value_adapters/UnsupportedValueException.java similarity index 86% rename from src/main/java/storage/storageValueAdapters/UnsupportedValueException.java rename to src/main/java/storage/storage_value_adapters/UnsupportedValueException.java index 602ea22..a0fe439 100644 --- a/src/main/java/storage/storageValueAdapters/UnsupportedValueException.java +++ b/src/main/java/storage/storage_value_adapters/UnsupportedValueException.java @@ -1,6 +1,6 @@ -package storage.storageValueAdapters; +package storage.storage_value_adapters; -import storage.storageValues.StorageValue; +import storage.storage_values.StorageValue; public class UnsupportedValueException extends RuntimeException { diff --git a/src/main/java/storage/storageValues/IntegerStorageValue.java b/src/main/java/storage/storage_values/IntegerStorageValue.java similarity index 83% rename from src/main/java/storage/storageValues/IntegerStorageValue.java rename to src/main/java/storage/storage_values/IntegerStorageValue.java index f556e6d..de49b99 100644 --- a/src/main/java/storage/storageValues/IntegerStorageValue.java +++ b/src/main/java/storage/storage_values/IntegerStorageValue.java @@ -1,4 +1,4 @@ -package storage.storageValues; +package storage.storage_values; public class IntegerStorageValue extends StorageValue { diff --git a/src/main/java/storage/storageValues/MapStorageValue.java b/src/main/java/storage/storage_values/MapStorageValue.java similarity index 86% rename from src/main/java/storage/storageValues/MapStorageValue.java rename to src/main/java/storage/storage_values/MapStorageValue.java index 2388bf8..fe61df9 100644 --- a/src/main/java/storage/storageValues/MapStorageValue.java +++ b/src/main/java/storage/storage_values/MapStorageValue.java @@ -1,4 +1,4 @@ -package storage.storageValues; +package storage.storage_values; import java.util.Map; diff --git a/src/main/java/storage/storageValues/StorageValue.java b/src/main/java/storage/storage_values/StorageValue.java similarity index 94% rename from src/main/java/storage/storageValues/StorageValue.java rename to src/main/java/storage/storage_values/StorageValue.java index 07500ae..685f820 100644 --- a/src/main/java/storage/storageValues/StorageValue.java +++ b/src/main/java/storage/storage_values/StorageValue.java @@ -1,4 +1,4 @@ -package storage.storageValues; +package storage.storage_values; public abstract class StorageValue { private T value; diff --git a/src/main/java/storage/storageValues/StringStorageValue.java b/src/main/java/storage/storage_values/StringStorageValue.java similarity index 82% rename from src/main/java/storage/storageValues/StringStorageValue.java rename to src/main/java/storage/storage_values/StringStorageValue.java index 528364a..9f04ca3 100644 --- a/src/main/java/storage/storageValues/StringStorageValue.java +++ b/src/main/java/storage/storage_values/StringStorageValue.java @@ -1,4 +1,4 @@ -package storage.storageValues; +package storage.storage_values; public class StringStorageValue extends StorageValue { diff --git a/src/main/java/storage/valueFormatters/ValueFormatter.java b/src/main/java/storage/value_formatters/ValueFormatter.java similarity index 58% rename from src/main/java/storage/valueFormatters/ValueFormatter.java rename to src/main/java/storage/value_formatters/ValueFormatter.java index 4442687..3668303 100644 --- a/src/main/java/storage/valueFormatters/ValueFormatter.java +++ b/src/main/java/storage/value_formatters/ValueFormatter.java @@ -1,7 +1,7 @@ -package storage.valueFormatters; +package storage.value_formatters; -import storage.storageValueAdapters.UnsupportedValueException; -import storage.storageValues.StorageValue; +import storage.storage_value_adapters.UnsupportedValueException; +import storage.storage_values.StorageValue; public interface ValueFormatter { public F format(StorageValue value) throws UnsupportedValueException; diff --git a/src/main/java/storage/valueFormatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java similarity index 96% rename from src/main/java/storage/valueFormatters/ValueToStringFormatter.java rename to src/main/java/storage/value_formatters/ValueToStringFormatter.java index 7c328ab..ccaa60f 100644 --- a/src/main/java/storage/valueFormatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -1,10 +1,10 @@ -package storage.valueFormatters; +package storage.value_formatters; import java.util.*; import java.util.Map.Entry; -import storage.storageValueAdapters.UnsupportedValueException; -import storage.storageValues.*; +import storage.storage_value_adapters.UnsupportedValueException; +import storage.storage_values.*; import helper_objects.ValueEnum; public class ValueToStringFormatter implements ValueFormatter { diff --git a/src/test/java/storage/storageValues/StorageValueTests.java b/src/test/java/storage/storage_values/StorageValueTests.java similarity index 92% rename from src/test/java/storage/storageValues/StorageValueTests.java rename to src/test/java/storage/storage_values/StorageValueTests.java index 2daaf34..ff395cd 100644 --- a/src/test/java/storage/storageValues/StorageValueTests.java +++ b/src/test/java/storage/storage_values/StorageValueTests.java @@ -1,8 +1,11 @@ -package storage.storageValues; +package storage.storage_values; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; +import storage.storage_values.IntegerStorageValue; +import storage.storage_values.StringStorageValue; + public class StorageValueTests { @Test diff --git a/src/test/java/storage/valueFormatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java similarity index 90% rename from src/test/java/storage/valueFormatters/ValueToStringFormatterTests.java rename to src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index cdc85b0..692ac7e 100644 --- a/src/test/java/storage/valueFormatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -1,12 +1,14 @@ -package storage.valueFormatters; +package storage.value_formatters; import static org.junit.jupiter.api.Assertions.*; import java.util.Map; import org.junit.jupiter.api.Test; -import storage.storageValueAdapters.UnsupportedValueException; -import storage.storageValues.*; +import storage.storage_value_adapters.UnsupportedValueException; +import storage.storage_values.*; +import storage.value_formatters.ValueFormatter; +import storage.value_formatters.ValueToStringFormatter; public class ValueToStringFormatterTests { From 0fce9413b03fcd95c7a5174b8f4b77b723f27ae3 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 3 Apr 2025 10:43:10 +0100 Subject: [PATCH 020/162] ValueToStringFormatter parsing for MapStorageValue Included .toString() for StorageValues --- .../storage_values/IntegerStorageValue.java | 4 ++++ .../storage_values/MapStorageValue.java | 16 +++++++++++++ .../storage/storage_values/StorageValue.java | 5 +++- .../storage_values/StringStorageValue.java | 5 ++++ .../ValueToStringFormatter.java | 4 ++-- .../storage_values/StorageValueTests.java | 3 --- .../ValueToStringFormatterTests.java | 24 ++++++++++++++++--- 7 files changed, 52 insertions(+), 9 deletions(-) diff --git a/src/main/java/storage/storage_values/IntegerStorageValue.java b/src/main/java/storage/storage_values/IntegerStorageValue.java index de49b99..2cc2738 100644 --- a/src/main/java/storage/storage_values/IntegerStorageValue.java +++ b/src/main/java/storage/storage_values/IntegerStorageValue.java @@ -6,4 +6,8 @@ public IntegerStorageValue(Integer integer) { super(integer); } + @Override + public String toString() { + return "IntegerStorageValue(" + this.value + ")"; + } } diff --git a/src/main/java/storage/storage_values/MapStorageValue.java b/src/main/java/storage/storage_values/MapStorageValue.java index fe61df9..456cb7f 100644 --- a/src/main/java/storage/storage_values/MapStorageValue.java +++ b/src/main/java/storage/storage_values/MapStorageValue.java @@ -1,11 +1,27 @@ package storage.storage_values; import java.util.Map; +import java.util.Map.Entry; public class MapStorageValue extends StorageValue>> { public MapStorageValue(Map> map) { super(map); } + + @Override + public String toString() { + String msg = "MapStorageValue({"; + + for (Entry> entries : this.value.entrySet()) { + msg += entries.getKey(); + msg += ":"; + msg += entries.getValue().toString() + ", "; + } + + msg.substring(0, msg.length() - 3); // Remove ending ", " + + return msg + "})"; + } } \ No newline at end of file diff --git a/src/main/java/storage/storage_values/StorageValue.java b/src/main/java/storage/storage_values/StorageValue.java index 685f820..24865f0 100644 --- a/src/main/java/storage/storage_values/StorageValue.java +++ b/src/main/java/storage/storage_values/StorageValue.java @@ -1,7 +1,7 @@ package storage.storage_values; public abstract class StorageValue { - private T value; + protected T value; public StorageValue(T value) { this.value = value; @@ -11,6 +11,9 @@ public T getValue() { return value; } + @Override + public abstract String toString(); + @Override public boolean equals(Object obj) { if (this == obj) return true; diff --git a/src/main/java/storage/storage_values/StringStorageValue.java b/src/main/java/storage/storage_values/StringStorageValue.java index 9f04ca3..9dd5634 100644 --- a/src/main/java/storage/storage_values/StringStorageValue.java +++ b/src/main/java/storage/storage_values/StringStorageValue.java @@ -5,5 +5,10 @@ public class StringStorageValue extends StorageValue { public StringStorageValue(String string) { super(string); } + + @Override + public String toString() { + return "StringStorageValue(" + this.value + ")"; + } } diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index ccaa60f..fd0f495 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -101,7 +101,7 @@ private MapStorageValue parseMapFormat(String formattedData) { if (formattedData.equals("{}") || formattedData.equals("{\n}")) return new MapStorageValue(Map.of()); - formattedData = formattedData.replaceFirst(PREFIXES.MAP.getValue() + "{\n", ""); + formattedData = formattedData.replaceFirst("\\{\n", ""); formattedData = formattedData.substring(0, formattedData.length() - 2); // Remove ending "}" Map> map = new HashMap<>(); @@ -111,7 +111,7 @@ private MapStorageValue parseMapFormat(String formattedData) { map.put( parts[0], - this.parseMapFormat(parts[1]) + this.parse(parts[1]) ); } diff --git a/src/test/java/storage/storage_values/StorageValueTests.java b/src/test/java/storage/storage_values/StorageValueTests.java index ff395cd..522e879 100644 --- a/src/test/java/storage/storage_values/StorageValueTests.java +++ b/src/test/java/storage/storage_values/StorageValueTests.java @@ -3,9 +3,6 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import storage.storage_values.IntegerStorageValue; -import storage.storage_values.StringStorageValue; - public class StorageValueTests { @Test diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index 692ac7e..5630465 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -2,13 +2,12 @@ import static org.junit.jupiter.api.Assertions.*; import java.util.Map; - import org.junit.jupiter.api.Test; +import helper_objects.NotEmptyTuple; +import helper_objects.Tuple; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.*; -import storage.value_formatters.ValueFormatter; -import storage.value_formatters.ValueToStringFormatter; public class ValueToStringFormatterTests { @@ -66,6 +65,25 @@ public void parseFormattedEmptyMap() { assertEquals(expectedValue, actualValue2); } + @Test + public void parseFormattedSimpleMap() { + Tuple testString = new NotEmptyTuple<>("testStringKey", "testString"); + Tuple testInt = new NotEmptyTuple<>("testintKey", 30); + String formattedString1 = "map:{\n" + + testString.value1() + ":str:" + testString.value2() + ",\n" + + testInt.value1() + ":int:" + testInt.value2() + "\n"+ + "}"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + + MapStorageValue expectedValue = new MapStorageValue(Map.ofEntries( + Map.entry(testString.value1(), new StringStorageValue(testString.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + )); + assertEquals(expectedValue, actualValue1); + } + //TODO: Test MapStorageValue with various contents (including nested maps) //TODO: Fomatting of StorageValues } From a221ef1de1a9567b329301c9cdc623ed9413ac21 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 3 Apr 2025 10:43:10 +0100 Subject: [PATCH 021/162] ValueToStringFormatter parsing for MapStorageValue Included .toString() for StorageValues --- .../storage_values/IntegerStorageValue.java | 4 ++++ .../storage_values/MapStorageValue.java | 16 +++++++++++++ .../storage/storage_values/StorageValue.java | 5 +++- .../storage_values/StringStorageValue.java | 5 ++++ .../ValueToStringFormatter.java | 9 +++++-- .../storage_values/StorageValueTests.java | 3 --- .../ValueToStringFormatterTests.java | 24 ++++++++++++++++--- 7 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/main/java/storage/storage_values/IntegerStorageValue.java b/src/main/java/storage/storage_values/IntegerStorageValue.java index de49b99..2cc2738 100644 --- a/src/main/java/storage/storage_values/IntegerStorageValue.java +++ b/src/main/java/storage/storage_values/IntegerStorageValue.java @@ -6,4 +6,8 @@ public IntegerStorageValue(Integer integer) { super(integer); } + @Override + public String toString() { + return "IntegerStorageValue(" + this.value + ")"; + } } diff --git a/src/main/java/storage/storage_values/MapStorageValue.java b/src/main/java/storage/storage_values/MapStorageValue.java index fe61df9..456cb7f 100644 --- a/src/main/java/storage/storage_values/MapStorageValue.java +++ b/src/main/java/storage/storage_values/MapStorageValue.java @@ -1,11 +1,27 @@ package storage.storage_values; import java.util.Map; +import java.util.Map.Entry; public class MapStorageValue extends StorageValue>> { public MapStorageValue(Map> map) { super(map); } + + @Override + public String toString() { + String msg = "MapStorageValue({"; + + for (Entry> entries : this.value.entrySet()) { + msg += entries.getKey(); + msg += ":"; + msg += entries.getValue().toString() + ", "; + } + + msg.substring(0, msg.length() - 3); // Remove ending ", " + + return msg + "})"; + } } \ No newline at end of file diff --git a/src/main/java/storage/storage_values/StorageValue.java b/src/main/java/storage/storage_values/StorageValue.java index 685f820..24865f0 100644 --- a/src/main/java/storage/storage_values/StorageValue.java +++ b/src/main/java/storage/storage_values/StorageValue.java @@ -1,7 +1,7 @@ package storage.storage_values; public abstract class StorageValue { - private T value; + protected T value; public StorageValue(T value) { this.value = value; @@ -11,6 +11,9 @@ public T getValue() { return value; } + @Override + public abstract String toString(); + @Override public boolean equals(Object obj) { if (this == obj) return true; diff --git a/src/main/java/storage/storage_values/StringStorageValue.java b/src/main/java/storage/storage_values/StringStorageValue.java index 9f04ca3..9dd5634 100644 --- a/src/main/java/storage/storage_values/StringStorageValue.java +++ b/src/main/java/storage/storage_values/StringStorageValue.java @@ -5,5 +5,10 @@ public class StringStorageValue extends StorageValue { public StringStorageValue(String string) { super(string); } + + @Override + public String toString() { + return "StringStorageValue(" + this.value + ")"; + } } diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index ccaa60f..0756878 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -95,13 +95,18 @@ private String formatValue(MapStorageValue value) { return out + "}"; } + /** + * Note: Map values cannot contain ",\n" + * @param formattedData + * @return + */ private MapStorageValue parseMapFormat(String formattedData) { formattedData = formattedData.replaceFirst(PREFIXES.MAP.getValue(), ""); if (formattedData.equals("{}") || formattedData.equals("{\n}")) return new MapStorageValue(Map.of()); - formattedData = formattedData.replaceFirst(PREFIXES.MAP.getValue() + "{\n", ""); + formattedData = formattedData.replaceFirst("\\{\n", ""); formattedData = formattedData.substring(0, formattedData.length() - 2); // Remove ending "}" Map> map = new HashMap<>(); @@ -111,7 +116,7 @@ private MapStorageValue parseMapFormat(String formattedData) { map.put( parts[0], - this.parseMapFormat(parts[1]) + this.parse(parts[1]) ); } diff --git a/src/test/java/storage/storage_values/StorageValueTests.java b/src/test/java/storage/storage_values/StorageValueTests.java index ff395cd..522e879 100644 --- a/src/test/java/storage/storage_values/StorageValueTests.java +++ b/src/test/java/storage/storage_values/StorageValueTests.java @@ -3,9 +3,6 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import storage.storage_values.IntegerStorageValue; -import storage.storage_values.StringStorageValue; - public class StorageValueTests { @Test diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index 692ac7e..5630465 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -2,13 +2,12 @@ import static org.junit.jupiter.api.Assertions.*; import java.util.Map; - import org.junit.jupiter.api.Test; +import helper_objects.NotEmptyTuple; +import helper_objects.Tuple; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.*; -import storage.value_formatters.ValueFormatter; -import storage.value_formatters.ValueToStringFormatter; public class ValueToStringFormatterTests { @@ -66,6 +65,25 @@ public void parseFormattedEmptyMap() { assertEquals(expectedValue, actualValue2); } + @Test + public void parseFormattedSimpleMap() { + Tuple testString = new NotEmptyTuple<>("testStringKey", "testString"); + Tuple testInt = new NotEmptyTuple<>("testintKey", 30); + String formattedString1 = "map:{\n" + + testString.value1() + ":str:" + testString.value2() + ",\n" + + testInt.value1() + ":int:" + testInt.value2() + "\n"+ + "}"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + + MapStorageValue expectedValue = new MapStorageValue(Map.ofEntries( + Map.entry(testString.value1(), new StringStorageValue(testString.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + )); + assertEquals(expectedValue, actualValue1); + } + //TODO: Test MapStorageValue with various contents (including nested maps) //TODO: Fomatting of StorageValues } From 1becee743421aa267eab4de0f731d9689124cc5a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 18 May 2025 20:16:59 +0100 Subject: [PATCH 022/162] ValueToStringFormatter rework Changed format to more closely resemble JSON --- .../ValueToStringFormatter.java | 89 ++++++++----------- .../ValueToStringFormatterTests.java | 54 +++++++---- 2 files changed, 73 insertions(+), 70 deletions(-) diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index 0756878..0ff11e1 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -2,40 +2,17 @@ import java.util.*; import java.util.Map.Entry; +import java.util.regex.*; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.*; -import helper_objects.ValueEnum; public class ValueToStringFormatter implements ValueFormatter { protected static final String KEY_VALUE_SEPERATOR = " : "; protected static final String INDENT = " "; - protected static enum PREFIXES implements ValueEnum { - STRING("str:"), - INTEGER("int:"), - MAP("map:"); - - private String value; - - private PREFIXES(String value) { - this.value = value; - } - - @Override - public String getValue() { - return value; - } - - @Override - public String toString() { - return value; - } - } - - boolean storageUsed = false; - List existingKeys = new ArrayList(); + protected static final String ANY_WHITESPACE = "[\n\t ]*"; @Override public String format(StorageValue value) throws UnsupportedValueException { @@ -49,9 +26,9 @@ public String format(StorageValue value) throws UnsupportedValueException { @Override public StorageValue parse(String formattedData) throws UnsupportedValueException { - if (formattedData.startsWith(PREFIXES.STRING.getValue())) return parseStringFormat(formattedData); - if (formattedData.startsWith(PREFIXES.INTEGER.getValue())) return parseIntegerFormat(formattedData); - if (formattedData.startsWith(PREFIXES.MAP.getValue())) return parseMapFormat(formattedData); + if (formattedData.startsWith("\"")) return parseStringFormat(formattedData); + if (formattedData.matches("[0-9]+.*")) return parseIntegerFormat(formattedData); + if (formattedData.startsWith("{")) return parseMapFormat(formattedData); //TODO: Add more value types throw new UnsupportedValueException(); @@ -59,67 +36,71 @@ public StorageValue parse(String formattedData) throws UnsupportedValueExcept private String formatValue(StringStorageValue value) { - String formattedString = PREFIXES.STRING.getValue(); - formattedString += value.getValue().replace("\\", "\\\\"); - - return formattedString; + return "\"" + + value.getValue().replace("\"", "\\\"").replace("\\", "\\\\") + + "\""; } private StringStorageValue parseStringFormat(String formattedData) { - formattedData = formattedData.replaceFirst(PREFIXES.STRING.getValue(), ""); + if (!formattedData.endsWith("\"")) throw new RuntimeException("The string " + formattedData + " must end with \""); + + formattedData = formattedData.substring(1, formattedData.length() - 1); formattedData = formattedData.replace("\\\\", "\\"); + return new StringStorageValue(formattedData); } private String formatValue(IntegerStorageValue value) { - return PREFIXES.INTEGER + String.valueOf(value.getValue()); + return String.valueOf(value.getValue()); } private IntegerStorageValue parseIntegerFormat(String formattedData) { - formattedData = formattedData.replaceFirst(PREFIXES.INTEGER.getValue(), ""); return new IntegerStorageValue(Integer.parseInt(formattedData)); } private String formatValue(MapStorageValue value) { + String out = ""; Set>> mapEntries = value.getValue().entrySet(); - if (mapEntries.isEmpty()) return "{}"; - String out = PREFIXES.MAP + "{\n"; + if (mapEntries.isEmpty()) return "{}"; for (Entry> entry : mapEntries) { - out += INDENT + entry.getKey() + ":" + entry.getValue() + ",\n"; //TODO: Test for values containing "",\n" + out += "\"" + entry.getKey() + ":" + entry.getValue() + ",\n"; } out = out.substring(0, out.length() - 3); //Remove trailing ",\n" - return out + "}"; + return "{\n" + indent(out) + "\n}"; } - /** - * Note: Map values cannot contain ",\n" - * @param formattedData - * @return - */ private MapStorageValue parseMapFormat(String formattedData) { - formattedData = formattedData.replaceFirst(PREFIXES.MAP.getValue(), ""); - - if (formattedData.equals("{}") || formattedData.equals("{\n}")) - return new MapStorageValue(Map.of()); + if (!formattedData.endsWith("}")) throw new RuntimeException("The map " + formattedData + " must end with }"); + if (formattedData.matches("\\{" + ANY_WHITESPACE + "\\}")) return new MapStorageValue(Map.of()); - formattedData = formattedData.replaceFirst("\\{\n", ""); - formattedData = formattedData.substring(0, formattedData.length() - 2); // Remove ending "}" + formattedData = formattedData.substring(1, formattedData.length() - 1); + formattedData = formattedData.strip(); Map> map = new HashMap<>(); - for (String entry : formattedData.split(",\n")) { - String[] parts = entry.split(":", 2); + Pattern entryPattern = Pattern.compile( + "\\\"(?[a-zA-Z0-9_\\-]*?)\\\"" + ANY_WHITESPACE + ":" + ANY_WHITESPACE + "(?\\{.*\\}|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", + Pattern.DOTALL | Pattern.MULTILINE + ); + Matcher entryMatcher = entryPattern.matcher(formattedData); + while (entryMatcher.find()) { map.put( - parts[0], - this.parse(parts[1]) + entryMatcher.group("key"), + parse(entryMatcher.group("value")) ); } return new MapStorageValue(map); } + + private String indent(String string) { + return INDENT + string.replace("\n", INDENT); + } + + protected record ValueFormat(String startDelimiter, String internalRegex, String endDelimiter) {} } diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index 5630465..bd89b2d 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -11,10 +11,12 @@ public class ValueToStringFormatterTests { + //TODO: Rework for JSON-like map, string, and int formats + @Test public void parseFormattedString() { String str = "Java"; - String formattedString = "str:" + str; + String formattedString = "\"" + str + "\""; ValueFormatter valueFormatter = new ValueToStringFormatter(); StorageValue actualValue = valueFormatter.parse(formattedString); @@ -34,7 +36,7 @@ public void parseUnformattedString() { @Test public void parseFormattedInteger() { Integer integer = 10; - String formattedString = "int:" + Integer.toString(integer); + String formattedString = Integer.toString(integer); ValueFormatter valueFormatter = new ValueToStringFormatter(); StorageValue actualValue = valueFormatter.parse(formattedString); @@ -43,18 +45,10 @@ public void parseFormattedInteger() { assertEquals(expectedValue, actualValue); } - @Test - public void parseUnformattedInteger() { - String str = "10"; - ValueFormatter valueFormatter = new ValueToStringFormatter(); - - assertThrows(UnsupportedValueException.class, () -> valueFormatter.parse(str)); - } - @Test public void parseFormattedEmptyMap() { - String formattedString1 = "map:{}"; - String formattedString2 = "map:{\n}"; + String formattedString1 = "{}"; + String formattedString2 = "{\n}"; ValueFormatter valueFormatter = new ValueToStringFormatter(); StorageValue actualValue1 = valueFormatter.parse(formattedString1); @@ -68,10 +62,10 @@ public void parseFormattedEmptyMap() { @Test public void parseFormattedSimpleMap() { Tuple testString = new NotEmptyTuple<>("testStringKey", "testString"); - Tuple testInt = new NotEmptyTuple<>("testintKey", 30); - String formattedString1 = "map:{\n" + - testString.value1() + ":str:" + testString.value2() + ",\n" + - testInt.value1() + ":int:" + testInt.value2() + "\n"+ + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + String formattedString1 = "{\n" + + " \"" + testString.value1() + "\":\"" + testString.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + "}"; ValueFormatter valueFormatter = new ValueToStringFormatter(); @@ -84,6 +78,34 @@ public void parseFormattedSimpleMap() { assertEquals(expectedValue, actualValue1); } + @Test + public void nestedMap() { + Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); + Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + String formattedString1 = "{\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + + MapStorageValue expectedValue = new MapStorageValue(Map.ofEntries( + Map.entry("innerMap", new MapStorageValue(Map.ofEntries( + Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + ))), + Map.entry(testString2.value1(), new StringStorageValue(testString2.value2())) + )); + assertEquals(expectedValue, actualValue1); + } + + //TODO: Test case where map keys are missing surrounding quotes + //TODO: Test MapStorageValue with various contents (including nested maps) //TODO: Fomatting of StorageValues } From de84f61685c403ec7e0f74e1116ddd6ab1b6ae61 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 18 May 2025 20:18:01 +0100 Subject: [PATCH 023/162] Minor non functionality edits --- docs/diagrams/Storage.drawio.svg | 6 +++--- src/test/java/code_generation/BasicCodeGeneratorTests.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index c540769..97793f0 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,4 +1,4 @@ - + @@ -365,7 +365,7 @@ -
+
Passed into @@ -373,7 +373,7 @@
- + Passed into diff --git a/src/test/java/code_generation/BasicCodeGeneratorTests.java b/src/test/java/code_generation/BasicCodeGeneratorTests.java index f487b47..1722b28 100644 --- a/src/test/java/code_generation/BasicCodeGeneratorTests.java +++ b/src/test/java/code_generation/BasicCodeGeneratorTests.java @@ -1,4 +1,5 @@ package code_generation; + import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; @@ -7,8 +8,7 @@ import grammar_objects.RuleConvertor; import syntax_analysis.parsing.ParseState; import test_aids.*; -import test_aids.test_grammars.BasicIdentifierTestGrammar; -import test_aids.test_grammars.SmallTestGrammar; +import test_aids.test_grammars.*; public class BasicCodeGeneratorTests { From e54039c300605a5a654709fc971be723adb4db9f Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 18 May 2025 22:28:07 +0100 Subject: [PATCH 024/162] Formatting tests for ValueToStringFormatter --- .../ValueToStringFormatter.java | 32 ++-- .../ValueToStringFormatterTests.java | 139 ++++++++++++++++-- 2 files changed, 146 insertions(+), 25 deletions(-) diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index 0ff11e1..eca4ff5 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -7,11 +7,13 @@ import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.*; +/** + * A simple and limited ValueFormatter, not intended for storage of complex data + * Parses and produces strings in the form { "entry1":value1, ..., "entryN":value } + */ public class ValueToStringFormatter implements ValueFormatter { - protected static final String KEY_VALUE_SEPERATOR = " : "; - protected static final String INDENT = " "; - + protected static final String INDENT = " "; protected static final String ANY_WHITESPACE = "[\n\t ]*"; @Override @@ -20,10 +22,16 @@ public String format(StorageValue value) throws UnsupportedValueException { if (value instanceof IntegerStorageValue) return formatValue((IntegerStorageValue)value); if (value instanceof MapStorageValue) return formatValue((MapStorageValue)value); - //TODO: Add more value types and ensure types are differentiatable from their stored formats + //TODO: Add more value types and ensure types are differentiable from their stored formats throw new UnsupportedValueException(value); } + /** + * Produces a StorageValue representation of the provided data. + * Note: Errors will not be thrown for incorrect values, ensure the input data is correctly formed. + * @param formattedData The formatted data to be parsed. + * @return The StorageValue representation of the input data. + */ @Override public StorageValue parse(String formattedData) throws UnsupportedValueException { if (formattedData.startsWith("\"")) return parseStringFormat(formattedData); @@ -65,10 +73,10 @@ private String formatValue(MapStorageValue value) { if (mapEntries.isEmpty()) return "{}"; for (Entry> entry : mapEntries) { - out += "\"" + entry.getKey() + ":" + entry.getValue() + ",\n"; + out += "\"" + entry.getKey() + "\":" + format(entry.getValue()) + ",\n"; } - out = out.substring(0, out.length() - 3); //Remove trailing ",\n" + out = out.substring(0, out.length() - 2); //Remove trailing ",\n" return "{\n" + indent(out) + "\n}"; } @@ -82,11 +90,11 @@ private MapStorageValue parseMapFormat(String formattedData) { Map> map = new HashMap<>(); - Pattern entryPattern = Pattern.compile( - "\\\"(?[a-zA-Z0-9_\\-]*?)\\\"" + ANY_WHITESPACE + ":" + ANY_WHITESPACE + "(?\\{.*\\}|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", - Pattern.DOTALL | Pattern.MULTILINE - ); - Matcher entryMatcher = entryPattern.matcher(formattedData); + Matcher entryMatcher = Pattern.compile( + "\\\"(?[a-zA-Z0-9_\\-]*?)\\\"" + ANY_WHITESPACE + ":" + ANY_WHITESPACE + "(?\\{.*\\}|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", + Pattern.DOTALL | Pattern.MULTILINE + ) + .matcher(formattedData); while (entryMatcher.find()) { map.put( @@ -99,7 +107,7 @@ private MapStorageValue parseMapFormat(String formattedData) { } private String indent(String string) { - return INDENT + string.replace("\n", INDENT); + return INDENT + string.replace("\n", "\n" + INDENT); } protected record ValueFormat(String startDelimiter, String internalRegex, String endDelimiter) {} diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index bd89b2d..d069035 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -1,6 +1,7 @@ package storage.value_formatters; import static org.junit.jupiter.api.Assertions.*; +import java.util.List; import java.util.Map; import org.junit.jupiter.api.Test; @@ -10,8 +11,8 @@ import storage.storage_values.*; public class ValueToStringFormatterTests { - - //TODO: Rework for JSON-like map, string, and int formats + + //NOTE: No exceptions for incorrectly formatted data were made. This will be left to more sophisticated ValueFormatters @Test public void parseFormattedString() { @@ -64,8 +65,8 @@ public void parseFormattedSimpleMap() { Tuple testString = new NotEmptyTuple<>("testStringKey", "testString"); Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); String formattedString1 = "{\n" + - " \"" + testString.value1() + "\":\"" + testString.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " \"" + testString.value1() + "\":\"" + testString.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + "}"; ValueFormatter valueFormatter = new ValueToStringFormatter(); @@ -79,16 +80,16 @@ public void parseFormattedSimpleMap() { } @Test - public void nestedMap() { + public void parseNestedMap() { Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); String formattedString1 = "{\n" + - " \"innerMap\":{\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + - " },\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + "}"; ValueFormatter valueFormatter = new ValueToStringFormatter(); @@ -104,8 +105,120 @@ public void nestedMap() { assertEquals(expectedValue, actualValue1); } - //TODO: Test case where map keys are missing surrounding quotes - - //TODO: Test MapStorageValue with various contents (including nested maps) //TODO: Fomatting of StorageValues + + @Test + public void formatString() { + String str = "Java"; + StringStorageValue stringValue = new StringStorageValue(str); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(stringValue); + + String expectedValue = "\"" + str + "\""; + assertEquals(expectedValue, actualValue); + } + + @Test + public void formatInteger() { + Integer integer = 10; + IntegerStorageValue integerValue = new IntegerStorageValue(10); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(integerValue); + + String expectedValue = Integer.toString(integer); + assertEquals(expectedValue, actualValue); + } + + @Test + public void formatEmptyMap() { + MapStorageValue mapValue = new MapStorageValue(Map.of()); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + String expectedValue = "{}"; + assertEquals(expectedValue, actualValue); + } + + @Test + public void formatSimpleMap() { + Tuple testString = new NotEmptyTuple<>("testStringKey", "testString"); + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( + Map.entry(testString.value1(), new StringStorageValue(testString.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + )); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + assertTrue(List.of( + "{\n" + + " \"" + testString.value1() + "\":\"" + testString.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + "}", + + "{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString.value1() + "\":\"" + testString.value2() + "\"\n" + + "}" + ) + .contains(actualValue) + ); + } + + @Test + public void formatNestedMap() { + Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); + Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( + Map.entry("innerMap", new MapStorageValue(Map.ofEntries( + Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + ))), + Map.entry(testString2.value1(), new StringStorageValue(testString2.value2())) + )); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + assertTrue(List.of( + "{\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}", + + "{\n" + + " \"innerMap\":{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}", + + "{\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " }\n" + + "}", + + "{\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + + " \"innerMap\":{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + + " }\n" + + "}" + ) + .contains(actualValue) + ); + } } From 6418e21924152b2813f0f93ef3b92989c1d6ff35 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 25 Nov 2025 20:27:30 +0000 Subject: [PATCH 025/162] Storage builder dynamic value handling --- src/main/java/storage/FileOperations.java | 68 ------- src/main/java/storage/Loadable.java | 4 +- src/main/java/storage/Storable.java | 4 +- src/main/java/storage/Storage.java | 190 ++++++++++++++++++ src/main/java/storage/StorageData.java | 10 - src/main/java/storage/TypeToken.java | 25 +++ .../helper_objects/DuplicateKeyException.java | 9 - 7 files changed, 221 insertions(+), 89 deletions(-) delete mode 100644 src/main/java/storage/FileOperations.java create mode 100644 src/main/java/storage/Storage.java delete mode 100644 src/main/java/storage/StorageData.java create mode 100644 src/main/java/storage/TypeToken.java delete mode 100644 src/main/java/storage/helper_objects/DuplicateKeyException.java diff --git a/src/main/java/storage/FileOperations.java b/src/main/java/storage/FileOperations.java deleted file mode 100644 index cf2d095..0000000 --- a/src/main/java/storage/FileOperations.java +++ /dev/null @@ -1,68 +0,0 @@ -package storage; - -import java.io.*; -import java.nio.file.*; - -public class FileOperations { - - /** - * Eases the contents of the provided file - * @param path The path of the file to be cleared. - * @throws UncheckedIOException The provided file could not be cleared. - */ - public static void eraseFileContents(Path path) throws UncheckedIOException { - try { - Files.newBufferedWriter(path , StandardOpenOption.TRUNCATE_EXISTING); - } catch (IOException e) { - throw new UncheckedIOException("The file " + path.toString() + "could not be cleared.", e); - } - } - - /** - * Checks if the file at the path provided exists - * @param path The path of the file. - * @return The existance of the specified file. - */ - public static boolean fileExists(Path path) { - return Files.exists(path); - } - - /** - * Creates a file for the provided path - * @param path The path of the file to be created. - */ - public static void createFile(Path path) { - try { - Files.createFile(path); - } catch (IOException e) { - throw new UncheckedIOException("The file " + path.toString() + "could not be created.", e); - } - } - - /** - * Deletes the file at the provided path - * @param path The path of the file to be deleted. - */ - public static void deleteFile(Path path) { - try { - Files.delete(path); - } catch (IOException e) { - throw new UncheckedIOException("The file " + path.toString() + "could not be deleted.", e); - } - } - - /** - * Appends a new line to the specified file with the given contents - * @param path The path of the file to be edited. - * @param line The contents to be added on the line. - */ - public static void appendLine(Path path, String line) { - line = line + "\n"; - - try (FileOutputStream fos = new FileOutputStream(path.toFile(), true);) { - fos.write(line.getBytes()); - } catch (IOException e) { - throw new UncheckedIOException("The file " + path.toString() + "could not be appended to.", e); - } - } -} diff --git a/src/main/java/storage/Loadable.java b/src/main/java/storage/Loadable.java index 025ebe4..493d87e 100644 --- a/src/main/java/storage/Loadable.java +++ b/src/main/java/storage/Loadable.java @@ -1,7 +1,9 @@ package storage; +import storage.storage_values.StorageValue; + public interface Loadable { - public void load(StorageData data); + public void load(StorageValue data); } diff --git a/src/main/java/storage/Storable.java b/src/main/java/storage/Storable.java index a6b3c1c..083c0bb 100644 --- a/src/main/java/storage/Storable.java +++ b/src/main/java/storage/Storable.java @@ -1,7 +1,9 @@ package storage; +import storage.storage_values.StorageValue; + public interface Storable { - public StorageData getStorageRepresentation(); + public StorageValue getStorageRepresentation(); } diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java new file mode 100644 index 0000000..5d27406 --- /dev/null +++ b/src/main/java/storage/Storage.java @@ -0,0 +1,190 @@ +package storage; + +import java.io.*; + +import storage.file_editors.*; +import storage.file_editors.FileWriter; +import storage.file_editors.FileReader; +import storage.storage_value_adapters.UnsupportedValueException; +import storage.storage_values.StorageValue; +import storage.value_formatters.*; + +/** + * A utility class for storage of compiler components. + */ +public class Storage { + + public String targetFilepath = "." + File.separator + "compilerthis.txt"; + public ChosenFormatter formatter = new ChosenFormatter<>(new ValueToStringFormatter()); + public FileWriter fileWriter = new StringFileEditor(); + public FileReader fileReader = new StringFileEditor(); + + //#region Constructors + + public Storage() {} + + //#endregion + + //#region Configuration + + public Storage setAbsoluteTargetPath(String filepath) { + targetFilepath = filepath; + return this; + } + + public Storage setRelativeTargetPath(String filepath) { + targetFilepath = "./" + filepath; + return this; + } + + public Storage setFormatter(ValueFormatter formatter) { + this.formatter = new ChosenFormatter(formatter); + return this; + } + + public Storage setFileWriter(FileWriter fileWriter) { + this.fileWriter = fileWriter; + return this; + } + + public Storage setFileReader(FileReader fileReader) { + this.fileReader = fileReader; + return this; + } + + public Storage setFileEditor(FileEditor fileEditor) { + this.fileWriter = fileEditor; + this.fileReader = fileEditor; + return this; + } + + //#endregion + + //#region StreamStorage + + /** + * + * @param storageObject + * @param formatter Only set for execution of this function. Use setFormatter to use this for multiple executions. + * @param outputStream + * @throws UncheckedIOException + */ + public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UncheckedIOException { + try (ObjectOutputStream writer = new ObjectOutputStream(outputStream)) { + writer.writeObject( + formatter.format(storageObject.getStorageRepresentation()) + ); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + public void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws UncheckedIOException { + convertAndLoadInto(objectToLoad, formatter, inputStream); + } + + public void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException { + Class expectedValueType = TypeToken.instantiate().getContainedClass(); + + try (ObjectInputStream reader = new ObjectInputStream(inputStream)) { + objectToLoad.load( + formatter.parse(expectedValueType.cast(reader.readObject())) + ); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + catch (UnsupportedValueException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + public void store(Storable storageObject, OutputStream outputStream) throws UncheckedIOException, RuntimeException { + convertAndStore(storageObject, formatter, outputStream); + } + + public StorageValue load(InputStream inputStream) { + Class expectedValueType = TypeToken.instantiate().getContainedClass(); + + try (ObjectInputStream reader = new ObjectInputStream(inputStream)) { + return formatter.parse(expectedValueType.cast(reader.readObject())); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + catch (UnsupportedValueException | ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + //#endregion + + //#region FileStorage + + public void store(Storable storageObject) { + store(storageObject.getStorageRepresentation()); + } + + public void store(Storable storageObject, String filePath) throws UncheckedIOException, RuntimeException { + try (FileOutputStream fileStream = new FileOutputStream(filePath)) { + convertAndStore(storageObject, formatter, fileStream); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + @SuppressWarnings("unchecked") + public void store(StorageValue storageObject) { + FileWriter fileWriter; + ValueFormatter formatter; + + try { + fileWriter = (FileWriter)this.fileWriter; + formatter = (ValueFormatter)this.formatter; + } + catch (ClassCastException e) { + throw e; + } + + fileWriter.store( + targetFilepath, + formatter.format(storageObject) + ); + } + + public void loadInto(Loadable targetObject) { + targetObject.load(load()); + } + + public StorageValue load() { + return formatter.parse(fileReader.readFrom(targetFilepath)); + } + + //#endregion + + //#region ComponentWrappers + + private class ChosenFormatter implements ValueFormatter { + ValueFormatter innerFormatter; + Class format; + + public ChosenFormatter(ValueFormatter formatter) { + innerFormatter = formatter; + } + + @Override + public F format(StorageValue value) throws UnsupportedValueException { + return innerFormatter.format(value); + } + + @Override + public StorageValue parse(Object formattedData) throws UnsupportedValueException { + return innerFormatter.parse(format.cast(formattedData)); + } + + } + + //#endregion +} diff --git a/src/main/java/storage/StorageData.java b/src/main/java/storage/StorageData.java deleted file mode 100644 index cd96cdd..0000000 --- a/src/main/java/storage/StorageData.java +++ /dev/null @@ -1,10 +0,0 @@ -package storage; - -import java.util.HashMap; - -import storage.storage_values.StorageValue; - -/** - * A memento/storage object for Storable objects - */ -public class StorageData extends HashMap> {} diff --git a/src/main/java/storage/TypeToken.java b/src/main/java/storage/TypeToken.java new file mode 100644 index 0000000..6845920 --- /dev/null +++ b/src/main/java/storage/TypeToken.java @@ -0,0 +1,25 @@ +package storage; + +import java.lang.reflect.*; + +public abstract class TypeToken { + private Type type; + + private TypeToken(){ + Type superClass = getClass().getGenericSuperclass(); + this.type = ((ParameterizedType) superClass).getActualTypeArguments()[0]; + } + + public Type getType() { + return type; + } + + @SuppressWarnings("unchecked") + public Class getContainedClass() { + return (Class) type.getClass(); + } + + public static TypeToken instantiate() { + return new TypeToken() {}; + } +} diff --git a/src/main/java/storage/helper_objects/DuplicateKeyException.java b/src/main/java/storage/helper_objects/DuplicateKeyException.java deleted file mode 100644 index 8b0e8ea..0000000 --- a/src/main/java/storage/helper_objects/DuplicateKeyException.java +++ /dev/null @@ -1,9 +0,0 @@ -package storage.helper_objects; - -public class DuplicateKeyException extends RuntimeException { - - public DuplicateKeyException(T key) { - super("Duplicated definition of the key \'" + key.toString() + " was provided."); - } - -} From 032792aa7cd0aec0e747460383f53f7b27f2073f Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 28 Nov 2025 01:00:36 +0000 Subject: [PATCH 026/162] Storage test class --- src/main/java/storage/Storage.java | 8 +-- src/test/java/storage/StorageTests.java | 70 +++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 src/test/java/storage/StorageTests.java diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 5d27406..f2f2f91 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -14,10 +14,10 @@ */ public class Storage { - public String targetFilepath = "." + File.separator + "compilerthis.txt"; - public ChosenFormatter formatter = new ChosenFormatter<>(new ValueToStringFormatter()); - public FileWriter fileWriter = new StringFileEditor(); - public FileReader fileReader = new StringFileEditor(); + private String targetFilepath = "." + File.separator + "compilerthis.txt"; + private ChosenFormatter formatter = new ChosenFormatter<>(new ValueToStringFormatter()); + private FileWriter fileWriter = new StringFileEditor(); + private FileReader fileReader = new StringFileEditor(); //#region Constructors diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java new file mode 100644 index 0000000..1e08c83 --- /dev/null +++ b/src/test/java/storage/StorageTests.java @@ -0,0 +1,70 @@ +package storage; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.lang.annotation.*; +import java.nio.file.*; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.extension.*; +import org.junit.jupiter.api.io.TempDir; + +@ExtendWith(StorageTests.UseTestFileExtension.class) +public class StorageTests { + + @TempDir + Path storageTestPath; + + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + protected @interface UseTestFile {} + + public static class UseTestFileExtension implements ParameterResolver { + @Override + public boolean supportsParameter(ParameterContext pc, ExtensionContext ec) { + return ec + .getTestMethod() + .get() + .isAnnotationPresent(UseTestFile.class); + } + + @Override + public Path resolveParameter(ParameterContext pc, ExtensionContext ec) { + try { + StorageTests testInstance = (StorageTests) ec.getRequiredTestInstance(); + Path tempDir = testInstance.storageTestPath; + return createTestFile(tempDir); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + protected Path createTestFile(Path tempDir) throws IOException { + String fileName = "testFile.txt"; + return Files.createFile(tempDir.resolve(fileName)); + } + } + + @Test + @UseTestFile + public void testMethod(Path testFile) throws IOException { + //TODO + } + + // Storage setAbsoluteTargetPath(String filepath) + // Storage setRelativeTargetPath(String filepath) + // Storage setFormatter(ValueFormatter formatter) + // Storage setFileWriter(FileWriter fileWriter) + // Storage setFileReader(FileReader fileReader) + // Storage setFileEditor(FileEditor fileEditor) + // void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UncheckedIOException + // void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws UncheckedIOException + // void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException + // void store(Storable storageObject, OutputStream outputStream) throws UncheckedIOException, RuntimeException + // StorageValue load(InputStream inputStream) + // void store(Storable storageObject) + // void store(Storable storageObject, String filePath) throws UncheckedIOException, RuntimeException + // void store(StorageValue storageObject) + // void loadInto(Loadable targetObject) + // StorageValue load() +} From c9d6dbf392205e3526da904ec525452b3a558b93 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 28 Nov 2025 22:47:53 +0000 Subject: [PATCH 027/162] Made file read/writers use Path for filepaths --- src/main/java/storage/Storage.java | 12 +++++++--- .../java/storage/file_editors/FileEditor.java | 23 +------------------ .../java/storage/file_editors/FileReader.java | 4 +++- .../java/storage/file_editors/FileWriter.java | 4 +++- .../file_editors/StringFileEditor.java | 8 +++---- 5 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index f2f2f91..cb5e3aa 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -1,6 +1,7 @@ package storage; import java.io.*; +import java.nio.file.Path; import storage.file_editors.*; import storage.file_editors.FileWriter; @@ -14,7 +15,7 @@ */ public class Storage { - private String targetFilepath = "." + File.separator + "compilerthis.txt"; + private Path targetFilepath = Path.of("." + File.separator + "compilerFile.txt"); private ChosenFormatter formatter = new ChosenFormatter<>(new ValueToStringFormatter()); private FileWriter fileWriter = new StringFileEditor(); private FileReader fileReader = new StringFileEditor(); @@ -27,13 +28,18 @@ public Storage() {} //#region Configuration - public Storage setAbsoluteTargetPath(String filepath) { + public Storage setTargetPath(Path filepath) { targetFilepath = filepath; return this; } + public Storage setAbsoluteTargetPath(String filepath) { + targetFilepath = Path.of(filepath); + return this; + } + public Storage setRelativeTargetPath(String filepath) { - targetFilepath = "./" + filepath; + targetFilepath = Path.of("." + File.separator + filepath); return this; } diff --git a/src/main/java/storage/file_editors/FileEditor.java b/src/main/java/storage/file_editors/FileEditor.java index fa6820c..4a63313 100644 --- a/src/main/java/storage/file_editors/FileEditor.java +++ b/src/main/java/storage/file_editors/FileEditor.java @@ -1,24 +1,3 @@ package storage.file_editors; -import java.io.File; -import java.nio.file.Path; - -public abstract class FileEditor implements FileReader, FileWriter { - - public T readFrom(File file) { - return readFrom(file.getAbsolutePath()); - } - - public T store(Path path) { - return readFrom(path.toString()); - } - - public void store(File file, T contents) { - store(file.getAbsolutePath(), contents); - } - - public void store(Path path, T contents) { - store(path.toString(), contents); - } - -} +public abstract class FileEditor implements FileReader, FileWriter {} diff --git a/src/main/java/storage/file_editors/FileReader.java b/src/main/java/storage/file_editors/FileReader.java index a5fff65..cfd6889 100644 --- a/src/main/java/storage/file_editors/FileReader.java +++ b/src/main/java/storage/file_editors/FileReader.java @@ -1,5 +1,7 @@ package storage.file_editors; +import java.nio.file.Path; + public interface FileReader { - public abstract T readFrom(String path); + public abstract T readFrom(Path path); } diff --git a/src/main/java/storage/file_editors/FileWriter.java b/src/main/java/storage/file_editors/FileWriter.java index 817e089..73b9fa4 100644 --- a/src/main/java/storage/file_editors/FileWriter.java +++ b/src/main/java/storage/file_editors/FileWriter.java @@ -1,5 +1,7 @@ package storage.file_editors; +import java.nio.file.Path; + public interface FileWriter { - public abstract void store(String path, T contents); + public abstract void store(Path path, T contents); } \ No newline at end of file diff --git a/src/main/java/storage/file_editors/StringFileEditor.java b/src/main/java/storage/file_editors/StringFileEditor.java index bf92208..b78adf4 100644 --- a/src/main/java/storage/file_editors/StringFileEditor.java +++ b/src/main/java/storage/file_editors/StringFileEditor.java @@ -7,18 +7,18 @@ public class StringFileEditor extends FileEditor { @Override - public void store(String path, String contents) throws UncheckedIOException { + public void store(Path path, String contents) throws UncheckedIOException { try { - Files.writeString(Paths.get(path), contents); + Files.writeString(path, contents); } catch (IOException e) { throw new UncheckedIOException("Failed to store content to \"" + path + "\"", e); } } @Override - public String readFrom(String path) throws UncheckedIOException { + public String readFrom(Path path) throws UncheckedIOException { try { - return Files.readString(Paths.get(path), StandardCharsets.UTF_8); + return Files.readString(path, StandardCharsets.UTF_8); } catch (IOException e) { throw new UncheckedIOException("Failed to read the contents from \"" + path + "\"", e); } From 4776e8b7ed0cafbef8ced0cd6e9f949190fc6ce2 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 29 Nov 2025 20:58:57 +0000 Subject: [PATCH 028/162] Storage setting path tests --- src/main/java/storage/Storage.java | 8 +++++ src/test/java/storage/StorageTests.java | 45 +++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index cb5e3aa..127c2ca 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -26,6 +26,14 @@ public Storage() {} //#endregion + //#region Getters + + public Path getTargetFilepath() { + return targetFilepath; + } + + //#endregion + //#region Configuration public Storage setTargetPath(Path filepath) { diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 1e08c83..4679593 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1,5 +1,7 @@ package storage; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.IOException; import java.io.UncheckedIOException; import java.lang.annotation.*; @@ -46,11 +48,48 @@ protected Path createTestFile(Path tempDir) throws IOException { } @Test - @UseTestFile - public void testMethod(Path testFile) throws IOException { - //TODO + public void setTargetPath() { + Path expectedPath = Path.of("./testPath"); + Storage storage = new Storage(); + + storage.setTargetPath(expectedPath); + Path actualPath = storage.getTargetFilepath(); + + assertEquals(expectedPath, actualPath); } + @Test + public void setAbsoluteTargetPath() { + Path expectedPath = Path.of("testPath"); + Storage storage = new Storage(); + + storage.setAbsoluteTargetPath(expectedPath.toString()); + Path actualPath = storage.getTargetFilepath(); + + assertEquals(expectedPath, actualPath); + } + + @Test + public void setRelativeTargetPath() { + String fileName = "testPath.txt"; + Storage storage = new Storage(); + + storage.setRelativeTargetPath(fileName); + Path actualPath = storage.getTargetFilepath(); + + Path expectedPath = Path.of("./" + fileName); + assertEquals(expectedPath, actualPath); + } + + // @Test + // @UseTestFile + // public void sampleTest(Path testFile) throws IOException { + // Storage storage = new Storage(); + + // storage.setTargetPath(testFile); + // } + + // Storage setTargetPath(Path filepath) // Storage setAbsoluteTargetPath(String filepath) // Storage setRelativeTargetPath(String filepath) // Storage setFormatter(ValueFormatter formatter) From 4d1d97e341dfb406153e6b61f66a6cb689734bdf Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 30 Nov 2025 01:32:27 +0000 Subject: [PATCH 029/162] Updated file editor components to throw IOExceptions Also added RuntimeException "throws" declarations for Storage methods --- src/main/java/storage/Storage.java | 40 ++++++++++--------- src/main/java/storage/TypeToken.java | 2 +- .../java/storage/file_editors/FileReader.java | 3 +- .../java/storage/file_editors/FileWriter.java | 3 +- .../file_editors/StringFileEditor.java | 16 ++------ src/test/java/storage/StorageTests.java | 32 ++++++++++++--- .../test_storage/TestFileEditor.java | 21 ++++++++++ .../test_storage/TestStorageValue.java | 16 ++++++++ .../test_storage/TestValueFormatter.java | 19 +++++++++ 9 files changed, 114 insertions(+), 38 deletions(-) create mode 100644 src/test/java/test_aids/test_storage/TestFileEditor.java create mode 100644 src/test/java/test_aids/test_storage/TestStorageValue.java create mode 100644 src/test/java/test_aids/test_storage/TestValueFormatter.java diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 127c2ca..394b247 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -118,7 +118,7 @@ public void store(Storable storageObject, OutputStream outputStream) throws Unch convertAndStore(storageObject, formatter, outputStream); } - public StorageValue load(InputStream inputStream) { + public StorageValue load(InputStream inputStream) throws UncheckedIOException, RuntimeException { Class expectedValueType = TypeToken.instantiate().getContainedClass(); try (ObjectInputStream reader = new ObjectInputStream(inputStream)) { @@ -136,7 +136,7 @@ public StorageValue load(InputStream inputStream) { //#region FileStorage - public void store(Storable storageObject) { + public void store(Storable storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { store(storageObject.getStorageRepresentation()); } @@ -150,30 +150,34 @@ public void store(Storable storageObject, String filePath) throws UncheckedIOExc } @SuppressWarnings("unchecked") - public void store(StorageValue storageObject) { - FileWriter fileWriter; - ValueFormatter formatter; + public void store(StorageValue storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { + TypeToken typeToken = TypeToken.instantiate(); try { - fileWriter = (FileWriter)this.fileWriter; - formatter = (ValueFormatter)this.formatter; - } - catch (ClassCastException e) { - throw e; - } + FileWriter fileWriter = (FileWriter)this.fileWriter; + ValueFormatter formatter = (ValueFormatter)this.formatter; - fileWriter.store( - targetFilepath, - formatter.format(storageObject) - ); + fileWriter.store( + targetFilepath, + formatter.format(storageObject) + ); + } catch (ClassCastException e) { + throw new RuntimeException("The type " + typeToken.getContainedClass().getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); + } catch (IOException e) { + throw new UncheckedIOException(e); + } } - public void loadInto(Loadable targetObject) { + public void loadInto(Loadable targetObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { targetObject.load(load()); } - public StorageValue load() { - return formatter.parse(fileReader.readFrom(targetFilepath)); + public StorageValue load() throws UnsupportedValueException, UncheckedIOException { + try { + return formatter.parse(fileReader.readFrom(targetFilepath)); + } catch (IOException e) { + throw new UncheckedIOException(e); + } } //#endregion diff --git a/src/main/java/storage/TypeToken.java b/src/main/java/storage/TypeToken.java index 6845920..d74cf22 100644 --- a/src/main/java/storage/TypeToken.java +++ b/src/main/java/storage/TypeToken.java @@ -5,7 +5,7 @@ public abstract class TypeToken { private Type type; - private TypeToken(){ + private TypeToken() { Type superClass = getClass().getGenericSuperclass(); this.type = ((ParameterizedType) superClass).getActualTypeArguments()[0]; } diff --git a/src/main/java/storage/file_editors/FileReader.java b/src/main/java/storage/file_editors/FileReader.java index cfd6889..ff1731c 100644 --- a/src/main/java/storage/file_editors/FileReader.java +++ b/src/main/java/storage/file_editors/FileReader.java @@ -1,7 +1,8 @@ package storage.file_editors; +import java.io.IOException; import java.nio.file.Path; public interface FileReader { - public abstract T readFrom(Path path); + public abstract T readFrom(Path path) throws IOException; } diff --git a/src/main/java/storage/file_editors/FileWriter.java b/src/main/java/storage/file_editors/FileWriter.java index 73b9fa4..cf1add2 100644 --- a/src/main/java/storage/file_editors/FileWriter.java +++ b/src/main/java/storage/file_editors/FileWriter.java @@ -1,7 +1,8 @@ package storage.file_editors; +import java.io.IOException; import java.nio.file.Path; public interface FileWriter { - public abstract void store(Path path, T contents); + public abstract void store(Path path, T contents) throws IOException; } \ No newline at end of file diff --git a/src/main/java/storage/file_editors/StringFileEditor.java b/src/main/java/storage/file_editors/StringFileEditor.java index b78adf4..a771d49 100644 --- a/src/main/java/storage/file_editors/StringFileEditor.java +++ b/src/main/java/storage/file_editors/StringFileEditor.java @@ -7,21 +7,13 @@ public class StringFileEditor extends FileEditor { @Override - public void store(Path path, String contents) throws UncheckedIOException { - try { - Files.writeString(path, contents); - } catch (IOException e) { - throw new UncheckedIOException("Failed to store content to \"" + path + "\"", e); - } + public void store(Path path, String contents) throws IOException { + Files.writeString(path, contents); } @Override - public String readFrom(Path path) throws UncheckedIOException { - try { - return Files.readString(path, StandardCharsets.UTF_8); - } catch (IOException e) { - throw new UncheckedIOException("Failed to read the contents from \"" + path + "\"", e); - } + public String readFrom(Path path) throws IOException { + return Files.readString(path, StandardCharsets.UTF_8); } } diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 4679593..99003a2 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -2,13 +2,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import java.io.IOException; -import java.io.UncheckedIOException; +import java.io.*; import java.lang.annotation.*; import java.nio.file.*; import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.*; import org.junit.jupiter.api.io.TempDir; +import test_aids.test_storage.*; +import storage.storage_values.*; @ExtendWith(StorageTests.UseTestFileExtension.class) public class StorageTests { @@ -52,9 +53,11 @@ public void setTargetPath() { Path expectedPath = Path.of("./testPath"); Storage storage = new Storage(); + storage.setTargetPath(expectedPath); Path actualPath = storage.getTargetFilepath(); + assertEquals(expectedPath, actualPath); } @@ -63,9 +66,11 @@ public void setAbsoluteTargetPath() { Path expectedPath = Path.of("testPath"); Storage storage = new Storage(); + storage.setAbsoluteTargetPath(expectedPath.toString()); Path actualPath = storage.getTargetFilepath(); + assertEquals(expectedPath, actualPath); } @@ -74,13 +79,33 @@ public void setRelativeTargetPath() { String fileName = "testPath.txt"; Storage storage = new Storage(); + storage.setRelativeTargetPath(fileName); Path actualPath = storage.getTargetFilepath(); + Path expectedPath = Path.of("./" + fileName); assertEquals(expectedPath, actualPath); } + @Test + @UseTestFile + public void store(Path testFile) throws IOException { + String expectedString = "testString"; + StorageValue storageValue = new StringStorageValue(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestFileEditor()) + .setFormatter(new TestValueFormatter()); + + + storage.store(storageValue); + String actualString = Files.readString(testFile); + + + assertEquals(expectedString, actualString); + } + // @Test // @UseTestFile // public void sampleTest(Path testFile) throws IOException { @@ -89,9 +114,6 @@ public void setRelativeTargetPath() { // storage.setTargetPath(testFile); // } - // Storage setTargetPath(Path filepath) - // Storage setAbsoluteTargetPath(String filepath) - // Storage setRelativeTargetPath(String filepath) // Storage setFormatter(ValueFormatter formatter) // Storage setFileWriter(FileWriter fileWriter) // Storage setFileReader(FileReader fileReader) diff --git a/src/test/java/test_aids/test_storage/TestFileEditor.java b/src/test/java/test_aids/test_storage/TestFileEditor.java new file mode 100644 index 0000000..8536495 --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestFileEditor.java @@ -0,0 +1,21 @@ +package test_aids.test_storage; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import storage.file_editors.FileEditor; + +public class TestFileEditor extends FileEditor { + + @Override + public Object readFrom(Path path) throws IOException { + return Files.readAllBytes(path); + } + + @Override + public void store(Path path, Object contents) throws IOException { + Files.write(path, (byte[])contents); + } + +} diff --git a/src/test/java/test_aids/test_storage/TestStorageValue.java b/src/test/java/test_aids/test_storage/TestStorageValue.java new file mode 100644 index 0000000..0562b46 --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestStorageValue.java @@ -0,0 +1,16 @@ +package test_aids.test_storage; + +import storage.storage_values.StorageValue; + +public class TestStorageValue extends StorageValue { + + public TestStorageValue(Object value) { + super(value); + } + + @Override + public String toString() { + return value.toString(); + } + +} diff --git a/src/test/java/test_aids/test_storage/TestValueFormatter.java b/src/test/java/test_aids/test_storage/TestValueFormatter.java new file mode 100644 index 0000000..a4510be --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestValueFormatter.java @@ -0,0 +1,19 @@ +package test_aids.test_storage; + +import storage.storage_value_adapters.UnsupportedValueException; +import storage.storage_values.StorageValue; +import storage.value_formatters.ValueFormatter; + +public class TestValueFormatter implements ValueFormatter { + + @Override + public Object format(StorageValue value) throws UnsupportedValueException { + return value; + } + + @Override + public StorageValue parse(Object formattedData) throws UnsupportedValueException { + return new TestStorageValue(formattedData); + } + +} From 04728e5fef2d2a0ed5c9079e7b0168465188d307 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 30 Nov 2025 18:38:14 +0000 Subject: [PATCH 030/162] Store fix --- src/main/java/storage/Storage.java | 13 +++++++++---- src/test/java/storage/StorageTests.java | 8 -------- .../java/test_aids/test_storage/TestFileEditor.java | 13 ++++++------- .../test_aids/test_storage/TestValueFormatter.java | 8 ++++---- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 394b247..00e62ae 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -153,16 +153,21 @@ public void store(Storable storageObject, String filePath) throws UncheckedIOExc public void store(StorageValue storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { TypeToken typeToken = TypeToken.instantiate(); + FileWriter fileWriter; + ValueFormatter formatter; + try { - FileWriter fileWriter = (FileWriter)this.fileWriter; - ValueFormatter formatter = (ValueFormatter)this.formatter; + fileWriter = (FileWriter)this.fileWriter; + formatter = (ValueFormatter)this.formatter; + } catch (ClassCastException e) { + throw new RuntimeException("The type " + typeToken.getContainedClass().getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); + } + try { fileWriter.store( targetFilepath, formatter.format(storageObject) ); - } catch (ClassCastException e) { - throw new RuntimeException("The type " + typeToken.getContainedClass().getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); } catch (IOException e) { throw new UncheckedIOException(e); } diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 99003a2..2936d0a 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -106,14 +106,6 @@ public void store(Path testFile) throws IOException { assertEquals(expectedString, actualString); } - // @Test - // @UseTestFile - // public void sampleTest(Path testFile) throws IOException { - // Storage storage = new Storage(); - - // storage.setTargetPath(testFile); - // } - // Storage setFormatter(ValueFormatter formatter) // Storage setFileWriter(FileWriter fileWriter) // Storage setFileReader(FileReader fileReader) diff --git a/src/test/java/test_aids/test_storage/TestFileEditor.java b/src/test/java/test_aids/test_storage/TestFileEditor.java index 8536495..bec74fe 100644 --- a/src/test/java/test_aids/test_storage/TestFileEditor.java +++ b/src/test/java/test_aids/test_storage/TestFileEditor.java @@ -1,21 +1,20 @@ package test_aids.test_storage; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; +import java.nio.file.*; import storage.file_editors.FileEditor; -public class TestFileEditor extends FileEditor { +public class TestFileEditor extends FileEditor { @Override - public Object readFrom(Path path) throws IOException { - return Files.readAllBytes(path); + public String readFrom(Path path) throws IOException { + return Files.readString(path); } @Override - public void store(Path path, Object contents) throws IOException { - Files.write(path, (byte[])contents); + public void store(Path path, String contents) throws IOException { + Files.writeString(path, contents.toString()); } } diff --git a/src/test/java/test_aids/test_storage/TestValueFormatter.java b/src/test/java/test_aids/test_storage/TestValueFormatter.java index a4510be..1ecf3bd 100644 --- a/src/test/java/test_aids/test_storage/TestValueFormatter.java +++ b/src/test/java/test_aids/test_storage/TestValueFormatter.java @@ -4,15 +4,15 @@ import storage.storage_values.StorageValue; import storage.value_formatters.ValueFormatter; -public class TestValueFormatter implements ValueFormatter { +public class TestValueFormatter implements ValueFormatter { @Override - public Object format(StorageValue value) throws UnsupportedValueException { - return value; + public String format(StorageValue value) throws UnsupportedValueException { + return value.getValue().toString(); } @Override - public StorageValue parse(Object formattedData) throws UnsupportedValueException { + public StorageValue parse(String formattedData) throws UnsupportedValueException { return new TestStorageValue(formattedData); } From c88888637e3cf877f1182ab08de1bf60f501756a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 12 Dec 2025 16:31:50 +0000 Subject: [PATCH 031/162] Rename TypeToken to TypeReference for clarity --- src/main/java/storage/Storage.java | 15 +++++++++------ .../{TypeToken.java => TypeReference.java} | 12 ++++++++---- 2 files changed, 17 insertions(+), 10 deletions(-) rename src/main/java/storage/{TypeToken.java => TypeReference.java} (57%) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 00e62ae..06c1b2f 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -99,7 +99,7 @@ public void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) t } public void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException { - Class expectedValueType = TypeToken.instantiate().getContainedClass(); + Class expectedValueType = TypeReference.instantiate().getContainedClass(); try (ObjectInputStream reader = new ObjectInputStream(inputStream)) { objectToLoad.load( @@ -119,7 +119,7 @@ public void store(Storable storageObject, OutputStream outputStream) throws Unch } public StorageValue load(InputStream inputStream) throws UncheckedIOException, RuntimeException { - Class expectedValueType = TypeToken.instantiate().getContainedClass(); + Class expectedValueType = TypeReference.instantiate().getContainedClass(); try (ObjectInputStream reader = new ObjectInputStream(inputStream)) { return formatter.parse(expectedValueType.cast(reader.readObject())); @@ -151,7 +151,7 @@ public void store(Storable storageObject, String filePath) throws UncheckedIOExc @SuppressWarnings("unchecked") public void store(StorageValue storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { - TypeToken typeToken = TypeToken.instantiate(); + Class typeToken = TypeReference.instantiate().getContainedClass(); FileWriter fileWriter; ValueFormatter formatter; @@ -160,7 +160,7 @@ public void store(StorageValue storageObject) throws UnsupportedValueExce fileWriter = (FileWriter)this.fileWriter; formatter = (ValueFormatter)this.formatter; } catch (ClassCastException e) { - throw new RuntimeException("The type " + typeToken.getContainedClass().getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); + throw new RuntimeException("The type " + typeToken.getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); } try { @@ -179,7 +179,8 @@ public void loadInto(Loadable targetObject) throws UnsupportedValueException, Un public StorageValue load() throws UnsupportedValueException, UncheckedIOException { try { - return formatter.parse(fileReader.readFrom(targetFilepath)); + Object data = fileReader.readFrom(targetFilepath); + return formatter.parse(data); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -195,6 +196,7 @@ private class ChosenFormatter implements ValueFormatter { public ChosenFormatter(ValueFormatter formatter) { innerFormatter = formatter; + format = TypeReference.instantiate().getContainedClass(); } @Override @@ -204,7 +206,8 @@ public F format(StorageValue value) throws UnsupportedValueException { @Override public StorageValue parse(Object formattedData) throws UnsupportedValueException { - return innerFormatter.parse(format.cast(formattedData)); + F data = format.cast(formattedData); + return innerFormatter.parse(data); } } diff --git a/src/main/java/storage/TypeToken.java b/src/main/java/storage/TypeReference.java similarity index 57% rename from src/main/java/storage/TypeToken.java rename to src/main/java/storage/TypeReference.java index d74cf22..1449f36 100644 --- a/src/main/java/storage/TypeToken.java +++ b/src/main/java/storage/TypeReference.java @@ -2,10 +2,14 @@ import java.lang.reflect.*; -public abstract class TypeToken { +/** + * A class for holding compile-time type information during runtime. + * Implementation of the "Type Token" design pattern. + */ +public abstract class TypeReference { private Type type; - private TypeToken() { + private TypeReference() { Type superClass = getClass().getGenericSuperclass(); this.type = ((ParameterizedType) superClass).getActualTypeArguments()[0]; } @@ -19,7 +23,7 @@ public Class getContainedClass() { return (Class) type.getClass(); } - public static TypeToken instantiate() { - return new TypeToken() {}; + public static TypeReference instantiate() { + return new TypeReference() {}; } } From 66af626c92d3387bb215acfeadf71b5fbc392d58 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 17 Dec 2025 21:52:31 +0000 Subject: [PATCH 032/162] Correct casting when loading from storage --- src/main/java/storage/Storage.java | 6 ++++-- src/test/java/storage/StorageTests.java | 27 +++++++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 06c1b2f..0a43662 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -1,8 +1,8 @@ package storage; import java.io.*; +import java.lang.reflect.ParameterizedType; import java.nio.file.Path; - import storage.file_editors.*; import storage.file_editors.FileWriter; import storage.file_editors.FileReader; @@ -194,9 +194,11 @@ private class ChosenFormatter implements ValueFormatter { ValueFormatter innerFormatter; Class format; + @SuppressWarnings("unchecked") public ChosenFormatter(ValueFormatter formatter) { innerFormatter = formatter; - format = TypeReference.instantiate().getContainedClass(); + ParameterizedType formatterType = (ParameterizedType)(formatter.getClass().getGenericInterfaces()[0]); + format = (Class)formatterType.getActualTypeArguments()[0]; } @Override diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 2936d0a..affed9c 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -5,11 +5,11 @@ import java.io.*; import java.lang.annotation.*; import java.nio.file.*; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.*; import org.junit.jupiter.api.io.TempDir; -import test_aids.test_storage.*; import storage.storage_values.*; +import test_aids.test_storage.*; @ExtendWith(StorageTests.UseTestFileExtension.class) public class StorageTests { @@ -106,10 +106,25 @@ public void store(Path testFile) throws IOException { assertEquals(expectedString, actualString); } - // Storage setFormatter(ValueFormatter formatter) - // Storage setFileWriter(FileWriter fileWriter) - // Storage setFileReader(FileReader fileReader) - // Storage setFileEditor(FileEditor fileEditor) + @Test + @UseTestFile + public void loadString(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestFileEditor()) + .setFormatter(new TestValueFormatter()); + + Files.writeString(testFile, testString); + + + StorageValue actualStorageValue = storage.load(); + + + StorageValue expectedStorageValue = new TestStorageValue(testString); + assertEquals(expectedStorageValue, actualStorageValue); + } + // void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UncheckedIOException // void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws UncheckedIOException // void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException From f578879223afa7f5f9289332bb89c57c273ba7cc Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 18 Dec 2025 16:10:49 +0000 Subject: [PATCH 033/162] Load empty file --- src/test/java/storage/StorageTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index affed9c..947efdd 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -125,6 +125,21 @@ public void loadString(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } + @Test + @UseTestFile + public void loadEmpty(Path testFile) throws IOException { + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestFileEditor()) + .setFormatter(new TestValueFormatter()); + + StorageValue actualStorageValue = storage.load(); + + + StorageValue expectedStorageValue = new TestStorageValue(""); + assertEquals(expectedStorageValue, actualStorageValue); + } + // void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UncheckedIOException // void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws UncheckedIOException // void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException From cf636bc6fce1b6ee25c8867737773e31a223121b Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 27 Jan 2026 00:06:37 +0000 Subject: [PATCH 034/162] Rework FileEditor components to use Streams Files can be edited as Streams through these components --- docs/diagrams/Storage.drawio.svg | 84 ++++++++++++++----- src/main/java/storage/Storage.java | 44 +++++----- .../file_editors/DefaultUTF8StreamEditor.java | 22 +++++ .../java/storage/file_editors/FileEditor.java | 3 - .../java/storage/file_editors/FileReader.java | 8 -- .../java/storage/file_editors/FileWriter.java | 8 -- .../storage/file_editors/StreamEditor.java | 3 + .../storage/file_editors/StreamReader.java | 7 ++ .../storage/file_editors/StreamWriter.java | 7 ++ .../file_editors/StringFileEditor.java | 19 ----- src/test/java/storage/StorageTests.java | 29 ++++++- .../test_storage/TestFileEditor.java | 20 ----- .../test_storage/TestStreamEditor.java | 23 +++++ 13 files changed, 172 insertions(+), 105 deletions(-) create mode 100644 src/main/java/storage/file_editors/DefaultUTF8StreamEditor.java delete mode 100644 src/main/java/storage/file_editors/FileEditor.java delete mode 100644 src/main/java/storage/file_editors/FileReader.java delete mode 100644 src/main/java/storage/file_editors/FileWriter.java create mode 100644 src/main/java/storage/file_editors/StreamEditor.java create mode 100644 src/main/java/storage/file_editors/StreamReader.java create mode 100644 src/main/java/storage/file_editors/StreamWriter.java delete mode 100644 src/main/java/storage/file_editors/StringFileEditor.java delete mode 100644 src/test/java/test_aids/test_storage/TestFileEditor.java create mode 100644 src/test/java/test_aids/test_storage/TestStreamEditor.java diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index 97793f0..2aebcd4 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,4 +1,4 @@ - + @@ -232,7 +232,7 @@ -
+
Produces a set of @@ -365,7 +365,7 @@ -
+
Passed into @@ -434,7 +434,7 @@ -
+
Throws @@ -442,7 +442,7 @@
- + Throws @@ -459,13 +459,13 @@
- Storage File + String Data Stream
- Storage File + String Data... @@ -478,7 +478,7 @@ -
+
Produces @@ -486,7 +486,7 @@
- + Produces @@ -526,16 +526,16 @@ -
+
- File Editors + Stream Editors
- File Editors + Stream Editors @@ -550,7 +550,7 @@
- FileWriter<T> + StreamWriter<T>
<I>
@@ -558,7 +558,7 @@
- FileWriter<T>... + StreamWriter<T>... @@ -573,13 +573,13 @@
- StringFileWriter + StringStreamWriter
- StringFileWriter + StringStreamWriter @@ -594,7 +594,7 @@
- FileReader<T> + StreamReader<T>
<I>
@@ -602,7 +602,7 @@
- FileReader<T>... + StreamReader<T>... @@ -617,7 +617,7 @@
- FileEditor<T> + StreamEditor<T>
<A>
@@ -625,7 +625,7 @@
- FileEditor<T>... + StreamEditor<T>... @@ -672,6 +672,50 @@ + + + + + + + + +
+
+
+ Text +
+
+
+
+ + Text + +
+
+
+ + + + + + + + +
+
+
+ Data File +
+
+
+
+ + Data File + +
+
+
diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 0a43662..eff5aaa 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -4,8 +4,6 @@ import java.lang.reflect.ParameterizedType; import java.nio.file.Path; import storage.file_editors.*; -import storage.file_editors.FileWriter; -import storage.file_editors.FileReader; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.StorageValue; import storage.value_formatters.*; @@ -17,8 +15,8 @@ public class Storage { private Path targetFilepath = Path.of("." + File.separator + "compilerFile.txt"); private ChosenFormatter formatter = new ChosenFormatter<>(new ValueToStringFormatter()); - private FileWriter fileWriter = new StringFileEditor(); - private FileReader fileReader = new StringFileEditor(); + private StreamWriter streamWriter = new DefaultUTF8StreamEditor(); + private StreamReader streamReader = new DefaultUTF8StreamEditor(); //#region Constructors @@ -56,19 +54,19 @@ public Storage setFormatter(ValueFormatter formatter) { return this; } - public Storage setFileWriter(FileWriter fileWriter) { - this.fileWriter = fileWriter; + public Storage setFileWriter(StreamWriter fileWriter) { + this.streamWriter = fileWriter; return this; } - public Storage setFileReader(FileReader fileReader) { - this.fileReader = fileReader; + public Storage setFileReader(StreamReader fileReader) { + this.streamReader = fileReader; return this; } - public Storage setFileEditor(FileEditor fileEditor) { - this.fileWriter = fileEditor; - this.fileReader = fileEditor; + public Storage setFileEditor(StreamEditor fileEditor) { + this.streamWriter = fileEditor; + this.streamReader = fileEditor; return this; } @@ -118,16 +116,16 @@ public void store(Storable storageObject, OutputStream outputStream) throws Unch convertAndStore(storageObject, formatter, outputStream); } + @SuppressWarnings("unchecked") public StorageValue load(InputStream inputStream) throws UncheckedIOException, RuntimeException { - Class expectedValueType = TypeReference.instantiate().getContainedClass(); - - try (ObjectInputStream reader = new ObjectInputStream(inputStream)) { - return formatter.parse(expectedValueType.cast(reader.readObject())); + try { + F value = (F)streamReader.readFrom(inputStream); + return formatter.parse(value); } catch (IOException e) { throw new UncheckedIOException(e); } - catch (UnsupportedValueException | ClassNotFoundException e) { + catch (UnsupportedValueException e) { throw new RuntimeException(e); } } @@ -153,19 +151,19 @@ public void store(Storable storageObject, String filePath) throws UncheckedIOExc public void store(StorageValue storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { Class typeToken = TypeReference.instantiate().getContainedClass(); - FileWriter fileWriter; + StreamWriter streamWriter; ValueFormatter formatter; try { - fileWriter = (FileWriter)this.fileWriter; + streamWriter = (StreamWriter)this.streamWriter; formatter = (ValueFormatter)this.formatter; } catch (ClassCastException e) { throw new RuntimeException("The type " + typeToken.getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); } - try { - fileWriter.store( - targetFilepath, + try (FileOutputStream outputStream = new FileOutputStream(targetFilepath.toFile())) { + streamWriter.addTo( + outputStream, formatter.format(storageObject) ); } catch (IOException e) { @@ -178,8 +176,8 @@ public void loadInto(Loadable targetObject) throws UnsupportedValueException, Un } public StorageValue load() throws UnsupportedValueException, UncheckedIOException { - try { - Object data = fileReader.readFrom(targetFilepath); + try (FileInputStream inputStream = new FileInputStream(targetFilepath.toFile())) { + Object data = streamReader.readFrom(inputStream); return formatter.parse(data); } catch (IOException e) { throw new UncheckedIOException(e); diff --git a/src/main/java/storage/file_editors/DefaultUTF8StreamEditor.java b/src/main/java/storage/file_editors/DefaultUTF8StreamEditor.java new file mode 100644 index 0000000..eca1c65 --- /dev/null +++ b/src/main/java/storage/file_editors/DefaultUTF8StreamEditor.java @@ -0,0 +1,22 @@ +package storage.file_editors; + +import java.io.*; +import java.nio.charset.StandardCharsets; + +public class DefaultUTF8StreamEditor extends StreamEditor { + + @Override + public String readFrom(InputStream stream) throws IOException { + try (stream) { + return new String(stream.readAllBytes(), StandardCharsets.UTF_8); + } + } + + @Override + public void addTo(OutputStream stream, String contents) throws IOException { + try (stream) { + stream.write(contents.getBytes(StandardCharsets.UTF_8)); + } + } + +} diff --git a/src/main/java/storage/file_editors/FileEditor.java b/src/main/java/storage/file_editors/FileEditor.java deleted file mode 100644 index 4a63313..0000000 --- a/src/main/java/storage/file_editors/FileEditor.java +++ /dev/null @@ -1,3 +0,0 @@ -package storage.file_editors; - -public abstract class FileEditor implements FileReader, FileWriter {} diff --git a/src/main/java/storage/file_editors/FileReader.java b/src/main/java/storage/file_editors/FileReader.java deleted file mode 100644 index ff1731c..0000000 --- a/src/main/java/storage/file_editors/FileReader.java +++ /dev/null @@ -1,8 +0,0 @@ -package storage.file_editors; - -import java.io.IOException; -import java.nio.file.Path; - -public interface FileReader { - public abstract T readFrom(Path path) throws IOException; -} diff --git a/src/main/java/storage/file_editors/FileWriter.java b/src/main/java/storage/file_editors/FileWriter.java deleted file mode 100644 index cf1add2..0000000 --- a/src/main/java/storage/file_editors/FileWriter.java +++ /dev/null @@ -1,8 +0,0 @@ -package storage.file_editors; - -import java.io.IOException; -import java.nio.file.Path; - -public interface FileWriter { - public abstract void store(Path path, T contents) throws IOException; -} \ No newline at end of file diff --git a/src/main/java/storage/file_editors/StreamEditor.java b/src/main/java/storage/file_editors/StreamEditor.java new file mode 100644 index 0000000..26a3487 --- /dev/null +++ b/src/main/java/storage/file_editors/StreamEditor.java @@ -0,0 +1,3 @@ +package storage.file_editors; + +public abstract class StreamEditor implements StreamReader, StreamWriter {} diff --git a/src/main/java/storage/file_editors/StreamReader.java b/src/main/java/storage/file_editors/StreamReader.java new file mode 100644 index 0000000..f63a314 --- /dev/null +++ b/src/main/java/storage/file_editors/StreamReader.java @@ -0,0 +1,7 @@ +package storage.file_editors; + +import java.io.*; + +public interface StreamReader { + public abstract T readFrom(InputStream stream) throws IOException; +} diff --git a/src/main/java/storage/file_editors/StreamWriter.java b/src/main/java/storage/file_editors/StreamWriter.java new file mode 100644 index 0000000..63ff81e --- /dev/null +++ b/src/main/java/storage/file_editors/StreamWriter.java @@ -0,0 +1,7 @@ +package storage.file_editors; + +import java.io.*; + +public interface StreamWriter { + public abstract void addTo(OutputStream stream, T contents) throws IOException; +} \ No newline at end of file diff --git a/src/main/java/storage/file_editors/StringFileEditor.java b/src/main/java/storage/file_editors/StringFileEditor.java deleted file mode 100644 index a771d49..0000000 --- a/src/main/java/storage/file_editors/StringFileEditor.java +++ /dev/null @@ -1,19 +0,0 @@ -package storage.file_editors; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.*; - -public class StringFileEditor extends FileEditor { - - @Override - public void store(Path path, String contents) throws IOException { - Files.writeString(path, contents); - } - - @Override - public String readFrom(Path path) throws IOException { - return Files.readString(path, StandardCharsets.UTF_8); - } - -} diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 947efdd..5b5eb9f 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -95,7 +95,7 @@ public void store(Path testFile) throws IOException { StorageValue storageValue = new StringStorageValue(expectedString); Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestFileEditor()) + .setFileEditor(new TestStreamEditor()) .setFormatter(new TestValueFormatter()); @@ -112,7 +112,7 @@ public void loadString(Path testFile) throws IOException { String testString = "testString"; Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestFileEditor()) + .setFileEditor(new TestStreamEditor()) .setFormatter(new TestValueFormatter()); Files.writeString(testFile, testString); @@ -130,7 +130,7 @@ public void loadString(Path testFile) throws IOException { public void loadEmpty(Path testFile) throws IOException { Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestFileEditor()) + .setFileEditor(new TestStreamEditor()) .setFormatter(new TestValueFormatter()); StorageValue actualStorageValue = storage.load(); @@ -144,7 +144,28 @@ public void loadEmpty(Path testFile) throws IOException { // void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws UncheckedIOException // void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException // void store(Storable storageObject, OutputStream outputStream) throws UncheckedIOException, RuntimeException - // StorageValue load(InputStream inputStream) + + @Test + @UseTestFile + public void load(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStreamEditor()) + .setFormatter(new TestValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + StorageValue actualStorageValue = storage.load(inputStream); + + + StorageValue expectedStorageValue = new TestStorageValue(testString); + assertEquals(expectedStorageValue, actualStorageValue); + } + // void store(Storable storageObject) // void store(Storable storageObject, String filePath) throws UncheckedIOException, RuntimeException // void store(StorageValue storageObject) diff --git a/src/test/java/test_aids/test_storage/TestFileEditor.java b/src/test/java/test_aids/test_storage/TestFileEditor.java deleted file mode 100644 index bec74fe..0000000 --- a/src/test/java/test_aids/test_storage/TestFileEditor.java +++ /dev/null @@ -1,20 +0,0 @@ -package test_aids.test_storage; - -import java.io.IOException; -import java.nio.file.*; - -import storage.file_editors.FileEditor; - -public class TestFileEditor extends FileEditor { - - @Override - public String readFrom(Path path) throws IOException { - return Files.readString(path); - } - - @Override - public void store(Path path, String contents) throws IOException { - Files.writeString(path, contents.toString()); - } - -} diff --git a/src/test/java/test_aids/test_storage/TestStreamEditor.java b/src/test/java/test_aids/test_storage/TestStreamEditor.java new file mode 100644 index 0000000..e9afade --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestStreamEditor.java @@ -0,0 +1,23 @@ +package test_aids.test_storage; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import storage.file_editors.StreamEditor; + +public class TestStreamEditor extends StreamEditor { + + @Override + public String readFrom(InputStream stream) throws IOException { + try (stream) { + return new String(stream.readAllBytes(), StandardCharsets.UTF_8); + } + } + + @Override + public void addTo(OutputStream stream, String contents) throws IOException { + try (stream) { + stream.write(contents.getBytes(StandardCharsets.UTF_8)); + } + } + +} \ No newline at end of file From d1242f5eea5de4ce8a49759485f6af7c230787c5 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 27 Jan 2026 23:50:40 +0000 Subject: [PATCH 035/162] Load from targetPath --- src/test/java/storage/StorageTests.java | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 5b5eb9f..b319105 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -147,7 +147,7 @@ public void loadEmpty(Path testFile) throws IOException { @Test @UseTestFile - public void load(Path testFile) throws IOException { + public void loadFromInputStream(Path testFile) throws IOException { String testString = "testString"; Storage storage = new Storage() .setTargetPath(testFile) @@ -170,5 +170,24 @@ public void load(Path testFile) throws IOException { // void store(Storable storageObject, String filePath) throws UncheckedIOException, RuntimeException // void store(StorageValue storageObject) // void loadInto(Loadable targetObject) - // StorageValue load() + + @UseTestFile + public void loadFromTargetPath(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStreamEditor()) + .setFormatter(new TestValueFormatter()); + + Files.writeString(testFile, testString); + + + StorageValue actualStorageValue = storage.load(); + + + StorageValue expectedStorageValue = new TestStorageValue(testString); + assertEquals(expectedStorageValue, actualStorageValue); + } + + //TODO: Apply for non-string types } From 2d6bea3bf3841ae38e37987e9240fee823de1231 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 30 Jan 2026 09:09:21 +0000 Subject: [PATCH 036/162] ConvertAndStore to OutputStream --- src/main/java/storage/Storage.java | 101 +++++++++++++----- src/test/java/storage/StorageTests.java | 27 ++++- .../test_aids/test_storage/TestStorable.java | 17 +++ 3 files changed, 115 insertions(+), 30 deletions(-) create mode 100644 src/test/java/test_aids/test_storage/TestStorable.java diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index eff5aaa..b8347db 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -15,7 +15,7 @@ public class Storage { private Path targetFilepath = Path.of("." + File.separator + "compilerFile.txt"); private ChosenFormatter formatter = new ChosenFormatter<>(new ValueToStringFormatter()); - private StreamWriter streamWriter = new DefaultUTF8StreamEditor(); + private ChosenStreamWriter streamWriter = new ChosenStreamWriter(new DefaultUTF8StreamEditor()); private StreamReader streamReader = new DefaultUTF8StreamEditor(); //#region Constructors @@ -54,40 +54,77 @@ public Storage setFormatter(ValueFormatter formatter) { return this; } - public Storage setFileWriter(StreamWriter fileWriter) { - this.streamWriter = fileWriter; + public Storage setStreamWriter(StreamWriter streamWriter) { + this.streamWriter = new ChosenStreamWriter(streamWriter); return this; } - public Storage setFileReader(StreamReader fileReader) { - this.streamReader = fileReader; + public Storage setStreamReader(StreamReader streamReader) { + this.streamReader = streamReader; return this; } - public Storage setFileEditor(StreamEditor fileEditor) { - this.streamWriter = fileEditor; - this.streamReader = fileEditor; + public Storage setStreamEditor(StreamEditor streamEditor) { + this.streamWriter = new ChosenStreamWriter(streamEditor); + this.streamReader = streamEditor; return this; } + //#endregion + + //#region ConvenienceMethods + + /** + * An equvalent method to setStreamWriter(StreamWriter streamWriter) + * @param + * @param fileWriter + * @return + */ + public Storage setFileWriter(StreamWriter fileWriter) { + return setStreamWriter(fileWriter); + } + + /** + * An equvalent method to setStreamReader(StreamReader streamReader) + * @param + * @param fileWriter + * @return + */ + public Storage setFileReader(StreamReader fileReader) { + return setStreamReader(fileReader); + } + + /** + * An equvalent method to setStreamEditor(StreamEditor streamEditor) + * @param + * @param fileWriter + * @return + */ + public Storage setFileEditor(StreamEditor fileEditor) { + return setStreamEditor(fileEditor); + } + //#endregion //#region StreamStorage /** * + * @param * @param storageObject * @param formatter Only set for execution of this function. Use setFormatter to use this for multiple executions. * @param outputStream + * @throws UnsupportedValueException * @throws UncheckedIOException + * @throws RuntimeException */ - public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UncheckedIOException { - try (ObjectOutputStream writer = new ObjectOutputStream(outputStream)) { - writer.writeObject( + public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UnsupportedValueException, UncheckedIOException, RuntimeException { + try { + streamWriter.addTo( + outputStream, formatter.format(storageObject.getStorageRepresentation()) ); - } - catch (IOException e) { + } catch (IOException e) { throw new UncheckedIOException(e); } } @@ -107,7 +144,7 @@ public void convertAndLoadInto(Loadable objectToLoad, ValueFormatter form catch (IOException e) { throw new UncheckedIOException(e); } - catch (UnsupportedValueException | ClassNotFoundException e) { + catch (ClassNotFoundException e) { throw new RuntimeException(e); } } @@ -147,20 +184,7 @@ public void store(Storable storageObject, String filePath) throws UncheckedIOExc } } - @SuppressWarnings("unchecked") public void store(StorageValue storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { - Class typeToken = TypeReference.instantiate().getContainedClass(); - - StreamWriter streamWriter; - ValueFormatter formatter; - - try { - streamWriter = (StreamWriter)this.streamWriter; - formatter = (ValueFormatter)this.formatter; - } catch (ClassCastException e) { - throw new RuntimeException("The type " + typeToken.getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); - } - try (FileOutputStream outputStream = new FileOutputStream(targetFilepath.toFile())) { streamWriter.addTo( outputStream, @@ -209,7 +233,28 @@ public StorageValue parse(Object formattedData) throws UnsupportedValueExcept F data = format.cast(formattedData); return innerFormatter.parse(data); } - + } + + private class ChosenStreamWriter { + StreamWriter innerStreamWriter; + + public ChosenStreamWriter(StreamWriter streamWriter) { + innerStreamWriter = streamWriter; + } + + @SuppressWarnings("unchecked") + public void addTo(OutputStream stream, F contents) throws IOException, RuntimeException { + Class typeReference = TypeReference.instantiate().getContainedClass(); + StreamWriter streamWriter; + + try { + streamWriter = (StreamWriter)innerStreamWriter; + } catch (ClassCastException e) { + throw new RuntimeException("The type " + typeReference.getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); + } + + streamWriter.addTo(stream, contents); + } } //#endregion diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index b319105..90a2188 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -9,6 +9,7 @@ import org.junit.jupiter.api.extension.*; import org.junit.jupiter.api.io.TempDir; import storage.storage_values.*; +import storage.value_formatters.ValueFormatter; import test_aids.test_storage.*; @ExtendWith(StorageTests.UseTestFileExtension.class) @@ -92,7 +93,7 @@ public void setRelativeTargetPath() { @UseTestFile public void store(Path testFile) throws IOException { String expectedString = "testString"; - StorageValue storageValue = new StringStorageValue(expectedString); + StorageValue storageValue = new TestStorageValue(expectedString); Storage storage = new Storage() .setTargetPath(testFile) .setFileEditor(new TestStreamEditor()) @@ -140,7 +141,29 @@ public void loadEmpty(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } - // void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UncheckedIOException + @Test + @UseTestFile + void convertAndStore(Path testFile) throws IOException { + String expectedString = "testString"; + + Storable storable = new TestStorable(expectedString); + ValueFormatter formatter = new TestValueFormatter(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + storage.convertAndStore(storable, formatter, outputStream); + } + + + String actualString = Files.readString(testFile); + assertEquals(expectedString, actualString); + } + // void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws UncheckedIOException // void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException // void store(Storable storageObject, OutputStream outputStream) throws UncheckedIOException, RuntimeException diff --git a/src/test/java/test_aids/test_storage/TestStorable.java b/src/test/java/test_aids/test_storage/TestStorable.java new file mode 100644 index 0000000..479e06e --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestStorable.java @@ -0,0 +1,17 @@ +package test_aids.test_storage; + +import storage.Storable; + +public class TestStorable implements Storable { + private Object value; + + public TestStorable(Object value) { + this.value = value; + } + + @Override + public TestStorageValue getStorageRepresentation() { + return new TestStorageValue(value); + } + +} From ccced17aef8415bc2b5bb4820c4683292bbc67c1 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 30 Jan 2026 23:27:15 +0000 Subject: [PATCH 037/162] ConvertAndLoadInto with addition of TestLoadable --- src/main/java/storage/Storage.java | 11 +++++---- src/test/java/storage/StorageTests.java | 24 ++++++++++++++++++- .../test_aids/test_storage/TestLoadable.java | 18 ++++++++++++++ 3 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 src/test/java/test_aids/test_storage/TestLoadable.java diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index b8347db..6941575 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -133,18 +133,19 @@ public void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) t convertAndLoadInto(objectToLoad, formatter, inputStream); } + @SuppressWarnings("unchecked") public void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException { - Class expectedValueType = TypeReference.instantiate().getContainedClass(); - - try (ObjectInputStream reader = new ObjectInputStream(inputStream)) { + try (inputStream) { + F value = (F)streamReader.readFrom(inputStream); + objectToLoad.load( - formatter.parse(expectedValueType.cast(reader.readObject())) + formatter.parse(value) ); } catch (IOException e) { throw new UncheckedIOException(e); } - catch (ClassNotFoundException e) { + catch (UnsupportedValueException e) { throw new RuntimeException(e); } } diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 90a2188..739f696 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -164,7 +164,29 @@ void convertAndStore(Path testFile) throws IOException { assertEquals(expectedString, actualString); } - // void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws UncheckedIOException + @Test + @UseTestFile + void convertAndLoadInto(Path testFile) throws IOException { + String expectedString = "testString"; + + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestValueFormatter()) + .setFileEditor(new TestStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + storage.convertAndLoadInto(loadable, inputStream); + } + + assertEquals(expectedString, loadable.getValue()); + } + // void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException // void store(Storable storageObject, OutputStream outputStream) throws UncheckedIOException, RuntimeException diff --git a/src/test/java/test_aids/test_storage/TestLoadable.java b/src/test/java/test_aids/test_storage/TestLoadable.java new file mode 100644 index 0000000..534b279 --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestLoadable.java @@ -0,0 +1,18 @@ +package test_aids.test_storage; + +import storage.Loadable; +import storage.storage_values.StorageValue; + +public class TestLoadable implements Loadable { + private Object value = null; + + public Object getValue() { + return value; + } + + @Override + public void load(StorageValue data) { + value = data.getValue(); + } + +} From 0bb6f3d99ee54c2adbfec900a39df9a8f442665e Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 3 Feb 2026 20:21:31 +0000 Subject: [PATCH 038/162] convertThenFormatAndLoadInto --- src/test/java/storage/StorageTests.java | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 739f696..f529877 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -187,7 +187,30 @@ void convertAndLoadInto(Path testFile) throws IOException { assertEquals(expectedString, loadable.getValue()); } - // void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException + @Test + @UseTestFile + void convertThenFormatAndLoadInto(Path testFile) throws IOException { + String expectedString = "testString"; + + TestLoadable loadable = new TestLoadable(); + ValueFormatter formatter = new TestValueFormatter(); + + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + storage.convertAndLoadInto(loadable, formatter, inputStream); + } + + assertEquals(expectedString, loadable.getValue()); + } + // void store(Storable storageObject, OutputStream outputStream) throws UncheckedIOException, RuntimeException @Test From ecd9a6924839b58786412b4c5476506d6c5117f6 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:10:54 +0000 Subject: [PATCH 039/162] storeToStream --- src/test/java/storage/StorageTests.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index f529877..6bdd8d7 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -211,7 +211,27 @@ void convertThenFormatAndLoadInto(Path testFile) throws IOException { assertEquals(expectedString, loadable.getValue()); } - // void store(Storable storageObject, OutputStream outputStream) throws UncheckedIOException, RuntimeException + @Test + @UseTestFile + public void storeToStream(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStreamEditor()) + .setFormatter(new TestValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + storage.store(storable, outputStream); + } + + + String actualString = Files.readString(testFile); + assertEquals(expectedString, actualString); + } @Test @UseTestFile From d5cb5ba30015f548457f596fcd37092896e31b75 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:20:51 +0000 Subject: [PATCH 040/162] storeStorable --- src/test/java/storage/StorageTests.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 6bdd8d7..701a97b 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -254,7 +254,24 @@ public void loadFromInputStream(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } - // void store(Storable storageObject) + @Test + @UseTestFile + public void storeStorable(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStreamEditor()) + .setFormatter(new TestValueFormatter()); + + + storage.store(storable); + String actualString = Files.readString(testFile); + + + assertEquals(expectedString, actualString); + } + // void store(Storable storageObject, String filePath) throws UncheckedIOException, RuntimeException // void store(StorageValue storageObject) // void loadInto(Loadable targetObject) From cbfd1818db49f4d46f30783818a27542dca07cef Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:54:31 +0000 Subject: [PATCH 041/162] storeStorableAtFilepath --- src/test/java/storage/StorageTests.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 701a97b..a276956 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -271,8 +271,24 @@ public void storeStorable(Path testFile) throws IOException { assertEquals(expectedString, actualString); } - - // void store(Storable storageObject, String filePath) throws UncheckedIOException, RuntimeException + + @Test + @UseTestFile + public void storeStorableAtFilepath(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setFileEditor(new TestStreamEditor()) + .setFormatter(new TestValueFormatter()); + + + storage.store(storable, testFile.toString()); + String actualString = Files.readString(testFile); + + + assertEquals(expectedString, actualString); + } + // void store(StorageValue storageObject) // void loadInto(Loadable targetObject) From cd06a8eb5eefaded25a936dcfff845efbb9ebcf9 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 3 Feb 2026 23:04:11 +0000 Subject: [PATCH 042/162] storeStorageValue --- src/test/java/storage/StorageTests.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index a276956..ce325cb 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -289,7 +289,24 @@ public void storeStorableAtFilepath(Path testFile) throws IOException { assertEquals(expectedString, actualString); } - // void store(StorageValue storageObject) + @Test + @UseTestFile + public void storeStorageValue(Path testFile) throws IOException { + String expectedString = "testString"; + StorageValue storageValue = new TestStorageValue(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStreamEditor()) + .setFormatter(new TestValueFormatter()); + + + storage.store(storageValue); + String actualString = Files.readString(testFile); + + + assertEquals(expectedString, actualString); + } + // void loadInto(Loadable targetObject) @UseTestFile From 75013508e69e43b98329e505988e6c1f6c869b1a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 3 Feb 2026 23:16:50 +0000 Subject: [PATCH 043/162] LoadInto --- src/test/java/storage/StorageTests.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index ce325cb..5d2dd9e 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -307,7 +307,24 @@ public void storeStorageValue(Path testFile) throws IOException { assertEquals(expectedString, actualString); } - // void loadInto(Loadable targetObject) + @Test + @UseTestFile + void LoadInto(Path testFile) throws IOException { + String expectedString = "testString"; + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestValueFormatter()) + .setFileEditor(new TestStreamEditor()); + + Files.writeString(testFile, expectedString); + + + storage.loadInto(loadable); + + + assertEquals(expectedString, loadable.getValue()); + } @UseTestFile public void loadFromTargetPath(Path testFile) throws IOException { @@ -328,4 +345,5 @@ public void loadFromTargetPath(Path testFile) throws IOException { } //TODO: Apply for non-string types + //TODO: Consider edge cases for all tests } From 15ffe59d05a43430882618fe04c0d8aeff7aa26f Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:17:33 +0000 Subject: [PATCH 044/162] StoreInteger --- src/test/java/storage/StorageTests.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 5d2dd9e..999aadd 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -91,7 +91,7 @@ public void setRelativeTargetPath() { @Test @UseTestFile - public void store(Path testFile) throws IOException { + public void storeString(Path testFile) throws IOException { String expectedString = "testString"; StorageValue storageValue = new TestStorageValue(expectedString); Storage storage = new Storage() @@ -107,6 +107,24 @@ public void store(Path testFile) throws IOException { assertEquals(expectedString, actualString); } + @Test + @UseTestFile + public void storeInteger(Path testFile) throws IOException { + int expectedInt = 10; + StorageValue storageValue = new TestStorageValue(expectedInt); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStreamEditor()) + .setFormatter(new TestValueFormatter()); + + + storage.store(storageValue); + int actualString = Integer.parseInt(Files.readString(testFile)); + + + assertEquals(expectedInt, actualString); + } + @Test @UseTestFile public void loadString(Path testFile) throws IOException { From b2fd60d405838a7267728b63603fecf1d576de8b Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:08:19 +0000 Subject: [PATCH 045/162] LoadInteger Includes some test helper renames --- src/test/java/storage/StorageTests.java | 77 ++++++++++++------- .../test_storage/TestIntegerStreamEditor.java | 23 ++++++ .../TestIntegerValueFormatter.java | 19 +++++ ...ditor.java => TestStringStreamEditor.java} | 2 +- ...ter.java => TestStringValueFormatter.java} | 2 +- 5 files changed, 93 insertions(+), 30 deletions(-) create mode 100644 src/test/java/test_aids/test_storage/TestIntegerStreamEditor.java create mode 100644 src/test/java/test_aids/test_storage/TestIntegerValueFormatter.java rename src/test/java/test_aids/test_storage/{TestStreamEditor.java => TestStringStreamEditor.java} (89%) rename src/test/java/test_aids/test_storage/{TestValueFormatter.java => TestStringValueFormatter.java} (87%) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 999aadd..28bdb41 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -96,8 +96,8 @@ public void storeString(Path testFile) throws IOException { StorageValue storageValue = new TestStorageValue(expectedString); Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); storage.store(storageValue); @@ -114,8 +114,8 @@ public void storeInteger(Path testFile) throws IOException { StorageValue storageValue = new TestStorageValue(expectedInt); Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); storage.store(storageValue); @@ -131,8 +131,8 @@ public void loadString(Path testFile) throws IOException { String testString = "testString"; Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); Files.writeString(testFile, testString); @@ -144,13 +144,32 @@ public void loadString(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } + @Test + @UseTestFile + public void loadInteger(Path testFile) throws IOException { + int testInteger = 10; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, Integer.toString(testInteger)); + + + StorageValue actualStorageValue = storage.load(); + + + StorageValue expectedStorageValue = new TestStorageValue(testInteger); + assertEquals(expectedStorageValue, actualStorageValue); + } + @Test @UseTestFile public void loadEmpty(Path testFile) throws IOException { Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); StorageValue actualStorageValue = storage.load(); @@ -165,10 +184,10 @@ void convertAndStore(Path testFile) throws IOException { String expectedString = "testString"; Storable storable = new TestStorable(expectedString); - ValueFormatter formatter = new TestValueFormatter(); + ValueFormatter formatter = new TestStringValueFormatter(); Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()); + .setFileEditor(new TestStringStreamEditor()); OutputStream outputStream = new FileOutputStream(testFile.toFile()); @@ -190,8 +209,8 @@ void convertAndLoadInto(Path testFile) throws IOException { TestLoadable loadable = new TestLoadable(); Storage storage = new Storage() .setTargetPath(testFile) - .setFormatter(new TestValueFormatter()) - .setFileEditor(new TestStreamEditor()); + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); Files.writeString(testFile, expectedString); @@ -211,11 +230,11 @@ void convertThenFormatAndLoadInto(Path testFile) throws IOException { String expectedString = "testString"; TestLoadable loadable = new TestLoadable(); - ValueFormatter formatter = new TestValueFormatter(); + ValueFormatter formatter = new TestStringValueFormatter(); Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()); + .setFileEditor(new TestStringStreamEditor()); Files.writeString(testFile, expectedString); @@ -236,8 +255,8 @@ public void storeToStream(Path testFile) throws IOException { Storable storable = new TestStorable(expectedString); Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); OutputStream outputStream = new FileOutputStream(testFile.toFile()); @@ -257,8 +276,8 @@ public void loadFromInputStream(Path testFile) throws IOException { String testString = "testString"; Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); Files.writeString(testFile, testString); @@ -279,8 +298,8 @@ public void storeStorable(Path testFile) throws IOException { Storable storable = new TestStorable(expectedString); Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); storage.store(storable); @@ -296,8 +315,8 @@ public void storeStorableAtFilepath(Path testFile) throws IOException { String expectedString = "testString"; Storable storable = new TestStorable(expectedString); Storage storage = new Storage() - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); storage.store(storable, testFile.toString()); @@ -314,8 +333,8 @@ public void storeStorageValue(Path testFile) throws IOException { StorageValue storageValue = new TestStorageValue(expectedString); Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); storage.store(storageValue); @@ -332,8 +351,8 @@ void LoadInto(Path testFile) throws IOException { TestLoadable loadable = new TestLoadable(); Storage storage = new Storage() .setTargetPath(testFile) - .setFormatter(new TestValueFormatter()) - .setFileEditor(new TestStreamEditor()); + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); Files.writeString(testFile, expectedString); @@ -349,8 +368,8 @@ public void loadFromTargetPath(Path testFile) throws IOException { String testString = "testString"; Storage storage = new Storage() .setTargetPath(testFile) - .setFileEditor(new TestStreamEditor()) - .setFormatter(new TestValueFormatter()); + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); Files.writeString(testFile, testString); @@ -364,4 +383,6 @@ public void loadFromTargetPath(Path testFile) throws IOException { //TODO: Apply for non-string types //TODO: Consider edge cases for all tests + //Include mismatched component types. e.g. Read file as integer and attempt formatting of string input. + //Ensure descriptive exceptions for this case. } diff --git a/src/test/java/test_aids/test_storage/TestIntegerStreamEditor.java b/src/test/java/test_aids/test_storage/TestIntegerStreamEditor.java new file mode 100644 index 0000000..3a9f5de --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestIntegerStreamEditor.java @@ -0,0 +1,23 @@ +package test_aids.test_storage; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import storage.file_editors.StreamEditor; + +public class TestIntegerStreamEditor extends StreamEditor { + + @Override + public Integer readFrom(InputStream stream) throws IOException { + try (stream) { + return Integer.parseInt(new String(stream.readAllBytes(), StandardCharsets.UTF_8)); + } + } + + @Override + public void addTo(OutputStream stream, Integer contents) throws IOException { + try (stream) { + stream.write(contents.toString().getBytes(StandardCharsets.UTF_8)); + } + } + +} \ No newline at end of file diff --git a/src/test/java/test_aids/test_storage/TestIntegerValueFormatter.java b/src/test/java/test_aids/test_storage/TestIntegerValueFormatter.java new file mode 100644 index 0000000..5690cec --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestIntegerValueFormatter.java @@ -0,0 +1,19 @@ +package test_aids.test_storage; + +import storage.storage_value_adapters.UnsupportedValueException; +import storage.storage_values.StorageValue; +import storage.value_formatters.ValueFormatter; + +public class TestIntegerValueFormatter implements ValueFormatter { + + @Override + public Integer format(StorageValue value) throws UnsupportedValueException { + return Integer.parseInt(value.getValue().toString()); + } + + @Override + public StorageValue parse(Integer formattedData) throws UnsupportedValueException { + return new TestStorageValue(formattedData); + } + +} \ No newline at end of file diff --git a/src/test/java/test_aids/test_storage/TestStreamEditor.java b/src/test/java/test_aids/test_storage/TestStringStreamEditor.java similarity index 89% rename from src/test/java/test_aids/test_storage/TestStreamEditor.java rename to src/test/java/test_aids/test_storage/TestStringStreamEditor.java index e9afade..b6a48e4 100644 --- a/src/test/java/test_aids/test_storage/TestStreamEditor.java +++ b/src/test/java/test_aids/test_storage/TestStringStreamEditor.java @@ -4,7 +4,7 @@ import java.nio.charset.StandardCharsets; import storage.file_editors.StreamEditor; -public class TestStreamEditor extends StreamEditor { +public class TestStringStreamEditor extends StreamEditor { @Override public String readFrom(InputStream stream) throws IOException { diff --git a/src/test/java/test_aids/test_storage/TestValueFormatter.java b/src/test/java/test_aids/test_storage/TestStringValueFormatter.java similarity index 87% rename from src/test/java/test_aids/test_storage/TestValueFormatter.java rename to src/test/java/test_aids/test_storage/TestStringValueFormatter.java index 1ecf3bd..4c97d38 100644 --- a/src/test/java/test_aids/test_storage/TestValueFormatter.java +++ b/src/test/java/test_aids/test_storage/TestStringValueFormatter.java @@ -4,7 +4,7 @@ import storage.storage_values.StorageValue; import storage.value_formatters.ValueFormatter; -public class TestValueFormatter implements ValueFormatter { +public class TestStringValueFormatter implements ValueFormatter { @Override public String format(StorageValue value) throws UnsupportedValueException { From cae7a3adb29a9e75af98785fa7af6ddc1ca3296b Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:24:41 +0000 Subject: [PATCH 046/162] LoadEmptyInteger --- src/test/java/storage/StorageTests.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 28bdb41..c560df6 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1,6 +1,7 @@ package storage; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.*; import java.lang.annotation.*; @@ -165,7 +166,7 @@ public void loadInteger(Path testFile) throws IOException { @Test @UseTestFile - public void loadEmpty(Path testFile) throws IOException { + public void loadEmptyString(Path testFile) throws IOException { Storage storage = new Storage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) @@ -178,6 +179,17 @@ public void loadEmpty(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } + @Test + @UseTestFile + public void loadEmptyInteger(Path testFile) throws IOException { + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + assertThrows(NumberFormatException.class, () -> storage.load()); + } + @Test @UseTestFile void convertAndStore(Path testFile) throws IOException { From c41552b29fc1fe53cb8d4dbe146685ef8ec42232 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:32:59 +0000 Subject: [PATCH 047/162] convertAndStoreInteger --- src/test/java/storage/StorageTests.java | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index c560df6..8b63635 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -192,7 +192,7 @@ public void loadEmptyInteger(Path testFile) throws IOException { @Test @UseTestFile - void convertAndStore(Path testFile) throws IOException { + void convertAndStoreString(Path testFile) throws IOException { String expectedString = "testString"; Storable storable = new TestStorable(expectedString); @@ -213,6 +213,29 @@ void convertAndStore(Path testFile) throws IOException { assertEquals(expectedString, actualString); } + @Test + @UseTestFile + void convertAndStoreInteger(Path testFile) throws IOException { + int expectedInteger = 10; + + Storable storable = new TestStorable(expectedInteger); + ValueFormatter formatter = new TestIntegerValueFormatter(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + storage.convertAndStore(storable, formatter, outputStream); + } + + + int actualInteger = Integer.parseInt(Files.readString(testFile)); + assertEquals(expectedInteger, actualInteger); + } + @Test @UseTestFile void convertAndLoadInto(Path testFile) throws IOException { From 369543db22dd7577c436832d4ea030a3d8d6c2de Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:35:48 +0000 Subject: [PATCH 048/162] convertAndLoadIntegerInto --- src/test/java/storage/StorageTests.java | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 8b63635..01aa35b 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -238,7 +238,7 @@ void convertAndStoreInteger(Path testFile) throws IOException { @Test @UseTestFile - void convertAndLoadInto(Path testFile) throws IOException { + void convertAndLoadStringInto(Path testFile) throws IOException { String expectedString = "testString"; TestLoadable loadable = new TestLoadable(); @@ -256,9 +256,34 @@ void convertAndLoadInto(Path testFile) throws IOException { storage.convertAndLoadInto(loadable, inputStream); } + assertEquals(expectedString, loadable.getValue()); } + @Test + @UseTestFile + void convertAndLoadIntegerInto(Path testFile) throws IOException { + int expectedInteger= 10; + + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestIntegerValueFormatter()) + .setFileEditor(new TestIntegerStreamEditor()); + + Files.writeString(testFile, Integer.toString(expectedInteger)); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + storage.convertAndLoadInto(loadable, inputStream); + } + + + assertEquals(expectedInteger, loadable.getValue()); + } + @Test @UseTestFile void convertThenFormatAndLoadInto(Path testFile) throws IOException { From 010ac3e022bdcec2e9546e4921b6e86e16f86d6d Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:37:41 +0000 Subject: [PATCH 049/162] convertThenFormatAndLoadIntegerInto --- src/test/java/storage/StorageTests.java | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 01aa35b..2ef1c38 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -256,7 +256,7 @@ void convertAndLoadStringInto(Path testFile) throws IOException { storage.convertAndLoadInto(loadable, inputStream); } - + assertEquals(expectedString, loadable.getValue()); } @@ -286,7 +286,7 @@ void convertAndLoadIntegerInto(Path testFile) throws IOException { @Test @UseTestFile - void convertThenFormatAndLoadInto(Path testFile) throws IOException { + void convertThenFormatAndLoadStringInto(Path testFile) throws IOException { String expectedString = "testString"; TestLoadable loadable = new TestLoadable(); @@ -308,6 +308,30 @@ void convertThenFormatAndLoadInto(Path testFile) throws IOException { assertEquals(expectedString, loadable.getValue()); } + @Test + @UseTestFile + void convertThenFormatAndLoadIntegerInto(Path testFile) throws IOException { + int expectedInteger = 10; + + TestLoadable loadable = new TestLoadable(); + ValueFormatter formatter = new TestIntegerValueFormatter(); + + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()); + + Files.writeString(testFile, Integer.toString(expectedInteger)); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + storage.convertAndLoadInto(loadable, formatter, inputStream); + } + + assertEquals(expectedInteger, loadable.getValue()); + } + @Test @UseTestFile public void storeToStream(Path testFile) throws IOException { From f856f7f0dedc9eb40316916a5a5ea384b4895605 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:39:41 +0000 Subject: [PATCH 050/162] storeIntegerToStream --- src/test/java/storage/StorageTests.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 2ef1c38..6fe5d81 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -334,7 +334,7 @@ void convertThenFormatAndLoadIntegerInto(Path testFile) throws IOException { @Test @UseTestFile - public void storeToStream(Path testFile) throws IOException { + public void storeStringToStream(Path testFile) throws IOException { String expectedString = "testString"; Storable storable = new TestStorable(expectedString); Storage storage = new Storage() @@ -354,6 +354,28 @@ public void storeToStream(Path testFile) throws IOException { assertEquals(expectedString, actualString); } + @Test + @UseTestFile + public void storeIntegerToStream(Path testFile) throws IOException { + int expectedInteger = 10; + Storable storable = new TestStorable(expectedInteger); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + storage.store(storable, outputStream); + } + + + int actualInteger = Integer.parseInt(Files.readString(testFile)); + assertEquals(expectedInteger, actualInteger); + } + @Test @UseTestFile public void loadFromInputStream(Path testFile) throws IOException { From d57571da4b16fc6c56aa099c9f12a0337f3b10c6 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:47:29 +0000 Subject: [PATCH 051/162] loadIntegerFromInputStream --- src/test/java/storage/StorageTests.java | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 6fe5d81..b1c7ab2 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -378,7 +378,7 @@ public void storeIntegerToStream(Path testFile) throws IOException { @Test @UseTestFile - public void loadFromInputStream(Path testFile) throws IOException { + public void loadStringFromInputStream(Path testFile) throws IOException { String testString = "testString"; Storage storage = new Storage() .setTargetPath(testFile) @@ -397,6 +397,27 @@ public void loadFromInputStream(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } + @Test + @UseTestFile + public void loadIntegerFromInputStream(Path testFile) throws IOException { + int testInteger = 10; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, Integer.toString(testInteger)); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + StorageValue actualStorageValue = storage.load(inputStream); + + + StorageValue expectedStorageValue = new TestStorageValue(testInteger); + assertEquals(expectedStorageValue, actualStorageValue); + } + @Test @UseTestFile public void storeStorable(Path testFile) throws IOException { From 9ce9f34c70d2c803db71a7d60baa34b90bd04493 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:52:57 +0000 Subject: [PATCH 052/162] storeStorableOfInteger --- src/test/java/storage/StorageTests.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index b1c7ab2..ceab5f1 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -420,7 +420,7 @@ public void loadIntegerFromInputStream(Path testFile) throws IOException { @Test @UseTestFile - public void storeStorable(Path testFile) throws IOException { + public void storeStorableOfString(Path testFile) throws IOException { String expectedString = "testString"; Storable storable = new TestStorable(expectedString); Storage storage = new Storage() @@ -436,6 +436,24 @@ public void storeStorable(Path testFile) throws IOException { assertEquals(expectedString, actualString); } + @Test + @UseTestFile + public void storeStorableOfInteger(Path testFile) throws IOException { + int expectedInteger = 10; + Storable storable = new TestStorable(expectedInteger); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + storage.store(storable); + int actualInteger = Integer.parseInt(Files.readString(testFile)); + + + assertEquals(expectedInteger, actualInteger); + } + @Test @UseTestFile public void storeStorableAtFilepath(Path testFile) throws IOException { From 2c03271deb96b623b0d6df1167b6e9562824eefe Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 22:55:01 +0000 Subject: [PATCH 053/162] storeStorableOfIntegerAtFilepath --- src/test/java/storage/StorageTests.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index ceab5f1..ec222f1 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -456,7 +456,7 @@ public void storeStorableOfInteger(Path testFile) throws IOException { @Test @UseTestFile - public void storeStorableAtFilepath(Path testFile) throws IOException { + public void storeStorableOfStringAtFilepath(Path testFile) throws IOException { String expectedString = "testString"; Storable storable = new TestStorable(expectedString); Storage storage = new Storage() @@ -471,6 +471,23 @@ public void storeStorableAtFilepath(Path testFile) throws IOException { assertEquals(expectedString, actualString); } + @Test + @UseTestFile + public void storeStorableOfIntegerAtFilepath(Path testFile) throws IOException { + int expectedInteger = 10; + Storable storable = new TestStorable(expectedInteger); + Storage storage = new Storage() + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + storage.store(storable, testFile.toString()); + int actualInteger = Integer.parseInt(Files.readString(testFile)); + + + assertEquals(expectedInteger, actualInteger); + } + @Test @UseTestFile public void storeStorageValue(Path testFile) throws IOException { From d7de25513c7a03fdaac60aa3fb7d76dfdbf24cfe Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 23:01:36 +0000 Subject: [PATCH 054/162] storeStorageValueOfInteger --- src/test/java/storage/StorageTests.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index ec222f1..31e31fe 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -490,7 +490,7 @@ public void storeStorableOfIntegerAtFilepath(Path testFile) throws IOException { @Test @UseTestFile - public void storeStorageValue(Path testFile) throws IOException { + public void storeStorageValueOfString(Path testFile) throws IOException { String expectedString = "testString"; StorageValue storageValue = new TestStorageValue(expectedString); Storage storage = new Storage() @@ -506,6 +506,24 @@ public void storeStorageValue(Path testFile) throws IOException { assertEquals(expectedString, actualString); } + @Test + @UseTestFile + public void storeStorageValueOfInteger(Path testFile) throws IOException { + int expectedInteger = 10; + StorageValue storageValue = new TestStorageValue(expectedInteger); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + storage.store(storageValue); + int actualInteger = Integer.parseInt(Files.readString(testFile)); + + + assertEquals(expectedInteger, actualInteger); + } + @Test @UseTestFile void LoadInto(Path testFile) throws IOException { From 32dbe4deea67a3477edef251e00fd6d28bff8a20 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 23:06:21 +0000 Subject: [PATCH 055/162] LoadIntegerInto --- src/test/java/storage/StorageTests.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 31e31fe..1fd1df1 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -526,7 +526,7 @@ public void storeStorageValueOfInteger(Path testFile) throws IOException { @Test @UseTestFile - void LoadInto(Path testFile) throws IOException { + void LoadStringInto(Path testFile) throws IOException { String expectedString = "testString"; TestLoadable loadable = new TestLoadable(); Storage storage = new Storage() @@ -542,6 +542,25 @@ void LoadInto(Path testFile) throws IOException { assertEquals(expectedString, loadable.getValue()); } + + @Test + @UseTestFile + void LoadIntegerInto(Path testFile) throws IOException { + int expectedInteger = 10; + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestIntegerValueFormatter()) + .setFileEditor(new TestIntegerStreamEditor()); + + Files.writeString(testFile, Integer.toString(expectedInteger)); + + + storage.loadInto(loadable); + + + assertEquals(expectedInteger, loadable.getValue()); + } @UseTestFile public void loadFromTargetPath(Path testFile) throws IOException { From 1446785c4377c5e7b440f184871e6f5604d73ccf Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 27 Feb 2026 23:08:10 +0000 Subject: [PATCH 056/162] loadIntegerFromTargetPath --- src/test/java/storage/StorageTests.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 1fd1df1..4662241 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -562,8 +562,9 @@ void LoadIntegerInto(Path testFile) throws IOException { assertEquals(expectedInteger, loadable.getValue()); } + @Test @UseTestFile - public void loadFromTargetPath(Path testFile) throws IOException { + public void loadStringFromTargetPath(Path testFile) throws IOException { String testString = "testString"; Storage storage = new Storage() .setTargetPath(testFile) @@ -580,6 +581,25 @@ public void loadFromTargetPath(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } + @Test + @UseTestFile + public void loadIntegerFromTargetPath(Path testFile) throws IOException { + int testInteger = 10; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, Integer.toString(testInteger)); + + + StorageValue actualStorageValue = storage.load(); + + + StorageValue expectedStorageValue = new TestStorageValue(testInteger); + assertEquals(expectedStorageValue, actualStorageValue); + } + //TODO: Apply for non-string types //TODO: Consider edge cases for all tests //Include mismatched component types. e.g. Read file as integer and attempt formatting of string input. From 5b3798d15036da73f2b97c9f76d8c9844c8d4ef0 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:24:33 +0000 Subject: [PATCH 057/162] Converted StreamEditor to Interface --- .../java/storage/file_editors/DefaultUTF8StreamEditor.java | 2 +- src/main/java/storage/file_editors/StreamEditor.java | 2 +- src/test/java/storage/StorageTests.java | 5 ++--- .../java/test_aids/test_storage/TestIntegerStreamEditor.java | 2 +- .../java/test_aids/test_storage/TestStringStreamEditor.java | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/storage/file_editors/DefaultUTF8StreamEditor.java b/src/main/java/storage/file_editors/DefaultUTF8StreamEditor.java index eca1c65..a18371a 100644 --- a/src/main/java/storage/file_editors/DefaultUTF8StreamEditor.java +++ b/src/main/java/storage/file_editors/DefaultUTF8StreamEditor.java @@ -3,7 +3,7 @@ import java.io.*; import java.nio.charset.StandardCharsets; -public class DefaultUTF8StreamEditor extends StreamEditor { +public class DefaultUTF8StreamEditor implements StreamEditor { @Override public String readFrom(InputStream stream) throws IOException { diff --git a/src/main/java/storage/file_editors/StreamEditor.java b/src/main/java/storage/file_editors/StreamEditor.java index 26a3487..454a994 100644 --- a/src/main/java/storage/file_editors/StreamEditor.java +++ b/src/main/java/storage/file_editors/StreamEditor.java @@ -1,3 +1,3 @@ package storage.file_editors; -public abstract class StreamEditor implements StreamReader, StreamWriter {} +public interface StreamEditor extends StreamReader, StreamWriter {} diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 4662241..be54b2a 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1,7 +1,6 @@ package storage; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import java.io.*; import java.lang.annotation.*; @@ -600,8 +599,8 @@ public void loadIntegerFromTargetPath(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } - //TODO: Apply for non-string types //TODO: Consider edge cases for all tests + //Include formatter and FileEditor which implement multiple interfaces/input-types //Include mismatched component types. e.g. Read file as integer and attempt formatting of string input. //Ensure descriptive exceptions for this case. } diff --git a/src/test/java/test_aids/test_storage/TestIntegerStreamEditor.java b/src/test/java/test_aids/test_storage/TestIntegerStreamEditor.java index 3a9f5de..d4f369b 100644 --- a/src/test/java/test_aids/test_storage/TestIntegerStreamEditor.java +++ b/src/test/java/test_aids/test_storage/TestIntegerStreamEditor.java @@ -4,7 +4,7 @@ import java.nio.charset.StandardCharsets; import storage.file_editors.StreamEditor; -public class TestIntegerStreamEditor extends StreamEditor { +public class TestIntegerStreamEditor implements StreamEditor { @Override public Integer readFrom(InputStream stream) throws IOException { diff --git a/src/test/java/test_aids/test_storage/TestStringStreamEditor.java b/src/test/java/test_aids/test_storage/TestStringStreamEditor.java index b6a48e4..29fdb62 100644 --- a/src/test/java/test_aids/test_storage/TestStringStreamEditor.java +++ b/src/test/java/test_aids/test_storage/TestStringStreamEditor.java @@ -4,7 +4,7 @@ import java.nio.charset.StandardCharsets; import storage.file_editors.StreamEditor; -public class TestStringStreamEditor extends StreamEditor { +public class TestStringStreamEditor implements StreamEditor { @Override public String readFrom(InputStream stream) throws IOException { From e51c899279e566b097712ad6e8e632fa50814bd3 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 7 Mar 2026 07:45:47 +0000 Subject: [PATCH 058/162] Handling of mismatched formatter and streamWriter --- src/main/java/storage/Storage.java | 89 +++++++++++++------ .../exceptions/FormatterException.java | 9 ++ .../StorageFormatMismatchException.java | 14 +++ .../exceptions/StoreFailureException.java | 9 ++ src/test/java/storage/StorageTests.java | 19 +++- 5 files changed, 112 insertions(+), 28 deletions(-) create mode 100644 src/main/java/storage/exceptions/FormatterException.java create mode 100644 src/main/java/storage/exceptions/StorageFormatMismatchException.java create mode 100644 src/main/java/storage/exceptions/StoreFailureException.java diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 6941575..65e3635 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -3,6 +3,8 @@ import java.io.*; import java.lang.reflect.ParameterizedType; import java.nio.file.Path; + +import storage.exceptions.*; import storage.file_editors.*; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.StorageValue; @@ -15,8 +17,8 @@ public class Storage { private Path targetFilepath = Path.of("." + File.separator + "compilerFile.txt"); private ChosenFormatter formatter = new ChosenFormatter<>(new ValueToStringFormatter()); - private ChosenStreamWriter streamWriter = new ChosenStreamWriter(new DefaultUTF8StreamEditor()); - private StreamReader streamReader = new DefaultUTF8StreamEditor(); + private ChosenStreamWriter streamWriter = new ChosenStreamWriter<>(new DefaultUTF8StreamEditor()); + private ChosenStreamReader streamReader = new ChosenStreamReader<>(new DefaultUTF8StreamEditor()); //#region Constructors @@ -55,18 +57,18 @@ public Storage setFormatter(ValueFormatter formatter) { } public Storage setStreamWriter(StreamWriter streamWriter) { - this.streamWriter = new ChosenStreamWriter(streamWriter); + this.streamWriter = new ChosenStreamWriter<>(streamWriter); return this; } public Storage setStreamReader(StreamReader streamReader) { - this.streamReader = streamReader; + this.streamReader = new ChosenStreamReader<>(streamReader); return this; } public Storage setStreamEditor(StreamEditor streamEditor) { - this.streamWriter = new ChosenStreamWriter(streamEditor); - this.streamReader = streamEditor; + this.streamWriter = new ChosenStreamWriter<>(streamEditor); + this.streamReader = new ChosenStreamReader<>(streamEditor); return this; } @@ -185,11 +187,22 @@ public void store(Storable storageObject, String filePath) throws UncheckedIOExc } } - public void store(StorageValue storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { + public void store(StorageValue storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException, StorageFormatMismatchException { + checkForFormatMismatch(formatter, streamWriter); + + Object formattedObject; + + try { + formattedObject = formatter.format(storageObject); + } + catch (Exception e) { + throw new FormatterException(e); + } + try (FileOutputStream outputStream = new FileOutputStream(targetFilepath.toFile())) { streamWriter.addTo( outputStream, - formatter.format(storageObject) + formattedObject ); } catch (IOException e) { throw new UncheckedIOException(e); @@ -213,15 +226,12 @@ public StorageValue load() throws UnsupportedValueException, UncheckedIOExcep //#region ComponentWrappers - private class ChosenFormatter implements ValueFormatter { + private class ChosenFormatter extends FormatHolder implements ValueFormatter { ValueFormatter innerFormatter; - Class format; - @SuppressWarnings("unchecked") public ChosenFormatter(ValueFormatter formatter) { + super(formatter); innerFormatter = formatter; - ParameterizedType formatterType = (ParameterizedType)(formatter.getClass().getGenericInterfaces()[0]); - format = (Class)formatterType.getActualTypeArguments()[0]; } @Override @@ -236,27 +246,54 @@ public StorageValue parse(Object formattedData) throws UnsupportedValueExcept } } - private class ChosenStreamWriter { - StreamWriter innerStreamWriter; + private class ChosenStreamWriter extends FormatHolder { + StreamWriter innerStreamWriter; - public ChosenStreamWriter(StreamWriter streamWriter) { + public ChosenStreamWriter(StreamWriter streamWriter) { + super(streamWriter); innerStreamWriter = streamWriter; } - @SuppressWarnings("unchecked") - public void addTo(OutputStream stream, F contents) throws IOException, RuntimeException { - Class typeReference = TypeReference.instantiate().getContainedClass(); - StreamWriter streamWriter; + public void addTo(OutputStream stream, Object contents) throws IOException, RuntimeException { + innerStreamWriter.addTo(stream, format.cast(contents)); + } + } + + private class ChosenStreamReader extends FormatHolder { + StreamReader innerStreamReader; - try { - streamWriter = (StreamWriter)innerStreamWriter; - } catch (ClassCastException e) { - throw new RuntimeException("The type " + typeReference.getName() + " could not be used by the file writer or formatter. Please check you are using the correct storage component and expecting the correct storage value type."); - } + public ChosenStreamReader(StreamReader streamReader) { + super(streamReader); + innerStreamReader = streamReader; + } - streamWriter.addTo(stream, contents); + public F readFrom(InputStream stream) throws IOException { + return innerStreamReader.readFrom(stream); } } //#endregion + + //#region Helpers + + private abstract class FormatHolder { + public Class format; + + @SuppressWarnings("unchecked") + public FormatHolder(Object genericTarget) { + ParameterizedType targetType = (ParameterizedType)(genericTarget.getClass().getGenericInterfaces()[0]); + format = (Class)targetType.getActualTypeArguments()[0]; + } + } + + private void checkForFormatMismatch(FormatHolder holder1, FormatHolder holder2) throws StorageFormatMismatchException { + if (holder1.format.equals(holder2.format)) return; + + throw new StorageFormatMismatchException( + holder1.format.getSimpleName(), + holder2.format.getSimpleName() + ); + } + + //#endregion } diff --git a/src/main/java/storage/exceptions/FormatterException.java b/src/main/java/storage/exceptions/FormatterException.java new file mode 100644 index 0000000..08d149d --- /dev/null +++ b/src/main/java/storage/exceptions/FormatterException.java @@ -0,0 +1,9 @@ +package storage.exceptions; + +public class FormatterException extends RuntimeException { + + public FormatterException(Exception cause) { + super("An error occurred when attempting to format data for storage.", cause); + } + +} diff --git a/src/main/java/storage/exceptions/StorageFormatMismatchException.java b/src/main/java/storage/exceptions/StorageFormatMismatchException.java new file mode 100644 index 0000000..980fd4e --- /dev/null +++ b/src/main/java/storage/exceptions/StorageFormatMismatchException.java @@ -0,0 +1,14 @@ +package storage.exceptions; + +public class StorageFormatMismatchException extends RuntimeException { + + public StorageFormatMismatchException(String type1Name, String type2Name) { + super( + "The formatter and stream editor types were mismatched. Formatter - " + + type1Name.getClass().getSimpleName() + + ", Stream - " + + type2Name.getClass().getSimpleName() + ); + } + +} diff --git a/src/main/java/storage/exceptions/StoreFailureException.java b/src/main/java/storage/exceptions/StoreFailureException.java new file mode 100644 index 0000000..0515ea3 --- /dev/null +++ b/src/main/java/storage/exceptions/StoreFailureException.java @@ -0,0 +1,9 @@ +package storage.exceptions; + +public class StoreFailureException extends RuntimeException { + + public StoreFailureException(Exception cause) { + super("An error occurred when attempting a store operation.", cause); + } + +} \ No newline at end of file diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index be54b2a..9515e7e 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -8,8 +8,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.*; import org.junit.jupiter.api.io.TempDir; + +import storage.exceptions.*; import storage.storage_values.*; -import storage.value_formatters.ValueFormatter; +import storage.value_formatters.*; import test_aids.test_storage.*; @ExtendWith(StorageTests.UseTestFileExtension.class) @@ -125,6 +127,20 @@ public void storeInteger(Path testFile) throws IOException { assertEquals(expectedInt, actualString); } + @Test + @UseTestFile + public void storeString_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + StorageValue storageValue = new TestStorageValue(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.store(storageValue)); + } + @Test @UseTestFile public void loadString(Path testFile) throws IOException { @@ -600,7 +616,6 @@ public void loadIntegerFromTargetPath(Path testFile) throws IOException { } //TODO: Consider edge cases for all tests - //Include formatter and FileEditor which implement multiple interfaces/input-types //Include mismatched component types. e.g. Read file as integer and attempt formatting of string input. //Ensure descriptive exceptions for this case. } From 14555146b9daece95a117b360197f0ccb9c5c864 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:25:55 +0000 Subject: [PATCH 059/162] Handling storage component failures on store --- src/main/java/storage/Storage.java | 6 +-- src/test/java/storage/StorageTests.java | 37 +++++++++++++++++++ .../exceptions/ExampleException.java | 8 ++++ .../TestStringErrorStreamEditor.java | 19 ++++++++++ .../TestStringErrorValueFormatter.java | 20 ++++++++++ 5 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 src/test/java/test_aids/exceptions/ExampleException.java create mode 100644 src/test/java/test_aids/test_storage/TestStringErrorStreamEditor.java create mode 100644 src/test/java/test_aids/test_storage/TestStringErrorValueFormatter.java diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 65e3635..eb289dd 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -187,7 +187,7 @@ public void store(Storable storageObject, String filePath) throws UncheckedIOExc } } - public void store(StorageValue storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException, StorageFormatMismatchException { + public void store(StorageValue storageObject) throws FormatterException, StoreFailureException, StorageFormatMismatchException { checkForFormatMismatch(formatter, streamWriter); Object formattedObject; @@ -204,8 +204,8 @@ public void store(StorageValue storageObject) throws UnsupportedValueExce outputStream, formattedObject ); - } catch (IOException e) { - throw new UncheckedIOException(e); + } catch (Exception e) { + throw new StoreFailureException(e); } } diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 9515e7e..1d1ea24 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -12,6 +12,7 @@ import storage.exceptions.*; import storage.storage_values.*; import storage.value_formatters.*; +import test_aids.exceptions.ExampleException; import test_aids.test_storage.*; @ExtendWith(StorageTests.UseTestFileExtension.class) @@ -141,6 +142,42 @@ public void storeString_IncorrectFormatter(Path testFile) throws IOException { assertThrows(StorageFormatMismatchException.class, () -> storage.store(storageValue)); } + @Test + @UseTestFile + public void storeString_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + StorageValue storageValue = new TestStorageValue(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(storageValue) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storeString_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + StorageValue storageValue = new TestStorageValue(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + + FormatterException exception = assertThrows( + FormatterException.class, + () -> storage.store(storageValue) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + @Test @UseTestFile public void loadString(Path testFile) throws IOException { diff --git a/src/test/java/test_aids/exceptions/ExampleException.java b/src/test/java/test_aids/exceptions/ExampleException.java new file mode 100644 index 0000000..74ec301 --- /dev/null +++ b/src/test/java/test_aids/exceptions/ExampleException.java @@ -0,0 +1,8 @@ +package test_aids.exceptions; + +public class ExampleException extends RuntimeException { + + public ExampleException() { + super("Example exception"); + } +} diff --git a/src/test/java/test_aids/test_storage/TestStringErrorStreamEditor.java b/src/test/java/test_aids/test_storage/TestStringErrorStreamEditor.java new file mode 100644 index 0000000..2680bd0 --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestStringErrorStreamEditor.java @@ -0,0 +1,19 @@ +package test_aids.test_storage; + +import java.io.*; +import storage.file_editors.StreamEditor; +import test_aids.exceptions.ExampleException; + +public class TestStringErrorStreamEditor implements StreamEditor { + + @Override + public String readFrom(InputStream stream) throws IOException { + throw new ExampleException(); + } + + @Override + public void addTo(OutputStream stream, String contents) throws IOException { + throw new ExampleException(); + } + +} \ No newline at end of file diff --git a/src/test/java/test_aids/test_storage/TestStringErrorValueFormatter.java b/src/test/java/test_aids/test_storage/TestStringErrorValueFormatter.java new file mode 100644 index 0000000..b8609e1 --- /dev/null +++ b/src/test/java/test_aids/test_storage/TestStringErrorValueFormatter.java @@ -0,0 +1,20 @@ +package test_aids.test_storage; + +import storage.storage_value_adapters.UnsupportedValueException; +import storage.storage_values.StorageValue; +import storage.value_formatters.ValueFormatter; +import test_aids.exceptions.ExampleException; + +public class TestStringErrorValueFormatter implements ValueFormatter { + + @Override + public String format(StorageValue value) throws UnsupportedValueException { + throw new ExampleException(); + } + + @Override + public StorageValue parse(String formattedData) throws UnsupportedValueException { + throw new ExampleException(); + } + +} \ No newline at end of file From 8044b49daff8b53e67ea059f9ebc89593ef6dbab Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 11 Mar 2026 00:58:36 +0000 Subject: [PATCH 060/162] Handling storage component failures on load --- src/main/java/storage/Storage.java | 22 +++++-- .../exceptions/FormatParseException.java | 9 +++ ...xception.java => FormattingException.java} | 4 +- .../exceptions/LoadFailureException.java | 9 +++ src/test/java/storage/StorageTests.java | 64 ++++++++++++++++++- 5 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 src/main/java/storage/exceptions/FormatParseException.java rename src/main/java/storage/exceptions/{FormatterException.java => FormattingException.java} (54%) create mode 100644 src/main/java/storage/exceptions/LoadFailureException.java diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index eb289dd..2724359 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -187,7 +187,7 @@ public void store(Storable storageObject, String filePath) throws UncheckedIOExc } } - public void store(StorageValue storageObject) throws FormatterException, StoreFailureException, StorageFormatMismatchException { + public void store(StorageValue storageObject) throws FormattingException, StoreFailureException, StorageFormatMismatchException { checkForFormatMismatch(formatter, streamWriter); Object formattedObject; @@ -196,7 +196,7 @@ public void store(StorageValue storageObject) throws FormatterException, formattedObject = formatter.format(storageObject); } catch (Exception e) { - throw new FormatterException(e); + throw new FormattingException(e); } try (FileOutputStream outputStream = new FileOutputStream(targetFilepath.toFile())) { @@ -213,12 +213,22 @@ public void loadInto(Loadable targetObject) throws UnsupportedValueException, Un targetObject.load(load()); } - public StorageValue load() throws UnsupportedValueException, UncheckedIOException { + public StorageValue load() throws FormattingException, StoreFailureException, StorageFormatMismatchException { + checkForFormatMismatch(formatter, streamWriter); + + Object data; + try (FileInputStream inputStream = new FileInputStream(targetFilepath.toFile())) { - Object data = streamReader.readFrom(inputStream); + data = streamReader.readFrom(inputStream); + } catch (Exception e) { + throw new LoadFailureException(e); + } + + try { return formatter.parse(data); - } catch (IOException e) { - throw new UncheckedIOException(e); + } + catch (Exception e) { + throw new FormatParseException(e); } } diff --git a/src/main/java/storage/exceptions/FormatParseException.java b/src/main/java/storage/exceptions/FormatParseException.java new file mode 100644 index 0000000..3092584 --- /dev/null +++ b/src/main/java/storage/exceptions/FormatParseException.java @@ -0,0 +1,9 @@ +package storage.exceptions; + +public class FormatParseException extends RuntimeException { + + public FormatParseException(Exception cause) { + super("An error occurred when attempting to parse formatted data.", cause); + } + +} diff --git a/src/main/java/storage/exceptions/FormatterException.java b/src/main/java/storage/exceptions/FormattingException.java similarity index 54% rename from src/main/java/storage/exceptions/FormatterException.java rename to src/main/java/storage/exceptions/FormattingException.java index 08d149d..99b08b3 100644 --- a/src/main/java/storage/exceptions/FormatterException.java +++ b/src/main/java/storage/exceptions/FormattingException.java @@ -1,8 +1,8 @@ package storage.exceptions; -public class FormatterException extends RuntimeException { +public class FormattingException extends RuntimeException { - public FormatterException(Exception cause) { + public FormattingException(Exception cause) { super("An error occurred when attempting to format data for storage.", cause); } diff --git a/src/main/java/storage/exceptions/LoadFailureException.java b/src/main/java/storage/exceptions/LoadFailureException.java new file mode 100644 index 0000000..c4f2f55 --- /dev/null +++ b/src/main/java/storage/exceptions/LoadFailureException.java @@ -0,0 +1,9 @@ +package storage.exceptions; + +public class LoadFailureException extends RuntimeException { + + public LoadFailureException(Exception cause) { + super("An error occurred when attempting a load operation.", cause); + } + +} \ No newline at end of file diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 1d1ea24..2241a5b 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -171,8 +171,8 @@ public void storeString_FormatterError(Path testFile) throws IOException { .setFormatter(new TestStringErrorValueFormatter()); - FormatterException exception = assertThrows( - FormatterException.class, + FormattingException exception = assertThrows( + FormattingException.class, () -> storage.store(storageValue) ); assertInstanceOf(ExampleException.class, exception.getCause()); @@ -239,7 +239,65 @@ public void loadEmptyInteger(Path testFile) throws IOException { .setFileEditor(new TestIntegerStreamEditor()) .setFormatter(new TestIntegerValueFormatter()); - assertThrows(NumberFormatException.class, () -> storage.load()); + + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.load() + ); + assertInstanceOf(NumberFormatException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void loadString_IncorrectFormatter(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, testString); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.load()); + } + + @Test + @UseTestFile + public void loadString_FileWriteError(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.load() + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void loadString_FormatterError(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + Files.writeString(testFile, testString); + + + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.load() + ); + assertInstanceOf(ExampleException.class, exception.getCause()); } @Test From ca2b95aa56c20146aea905c2e7c489055f8873a8 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:22:23 +0000 Subject: [PATCH 061/162] Handling storage component failures on convertAndStore --- src/main/java/storage/Storage.java | 20 +++++--- src/test/java/storage/StorageTests.java | 62 +++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 2724359..a4cc0e9 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -121,13 +121,21 @@ public Storage setFileEditor(StreamEditor fileEditor) { * @throws RuntimeException */ public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UnsupportedValueException, UncheckedIOException, RuntimeException { + checkForFormatMismatch(new ChosenFormatter(formatter), streamWriter); + + F format; + try { - streamWriter.addTo( - outputStream, - formatter.format(storageObject.getStorageRepresentation()) - ); - } catch (IOException e) { - throw new UncheckedIOException(e); + format = formatter.format(storageObject.getStorageRepresentation()); + } + catch (Exception e) { + throw new FormattingException(e); + } + + try { + streamWriter.addTo(outputStream, format); + } catch (Exception e) { + throw new StoreFailureException(e); } } diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 2241a5b..8742dc9 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -346,6 +346,68 @@ void convertAndStoreInteger(Path testFile) throws IOException { assertEquals(expectedInteger, actualInteger); } + @Test + @UseTestFile + public void convertAndStoreString_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + + Storable storable = new TestStorable(expectedString); + ValueFormatter formatter = new TestIntegerValueFormatter(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + try (outputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.convertAndStore(storable, formatter, outputStream)); + } + } + + @Test + @UseTestFile + public void convertAndStoreString_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + + Storable storable = new TestStorable(expectedString); + ValueFormatter formatter = new TestStringValueFormatter(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + try (outputStream) { + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.convertAndStore(storable, formatter, outputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void convertAndStoreString_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + + Storable storable = new TestStorable(expectedString); + ValueFormatter formatter = new TestStringErrorValueFormatter(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + try (outputStream) { + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.convertAndStore(storable, formatter, outputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + @Test @UseTestFile void convertAndLoadStringInto(Path testFile) throws IOException { From faf393b3051059fc143cbfb7088558f1f16308d5 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 13 Mar 2026 23:08:03 +0000 Subject: [PATCH 062/162] Handling storage component failures on convertAndLoadInto Includes restructure of Storage code for clarity and to enable convertAndLoadInto functionality. --- src/main/java/storage/Storage.java | 202 +++++++++++++----------- src/test/java/storage/StorageTests.java | 71 +++++++++ 2 files changed, 177 insertions(+), 96 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index a4cc0e9..c7cb8e9 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -120,129 +120,115 @@ public Storage setFileEditor(StreamEditor fileEditor) { * @throws UncheckedIOException * @throws RuntimeException */ - public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws UnsupportedValueException, UncheckedIOException, RuntimeException { - checkForFormatMismatch(new ChosenFormatter(formatter), streamWriter); - - F format; - - try { - format = formatter.format(storageObject.getStorageRepresentation()); - } - catch (Exception e) { - throw new FormattingException(e); - } - - try { - streamWriter.addTo(outputStream, format); - } catch (Exception e) { - throw new StoreFailureException(e); - } + public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException { + convertAndStore_Inner(storageObject.getStorageRepresentation(), new ChosenFormatter(formatter), streamWriter, outputStream); } - public void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws UncheckedIOException { - convertAndLoadInto(objectToLoad, formatter, inputStream); + public void store(Storable storageObject, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException { + convertAndStore_Inner(storageObject.getStorageRepresentation(), formatter, streamWriter, outputStream); } - @SuppressWarnings("unchecked") - public void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws UncheckedIOException, RuntimeException { - try (inputStream) { - F value = (F)streamReader.readFrom(inputStream); - - objectToLoad.load( - formatter.parse(value) - ); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } - catch (UnsupportedValueException e) { - throw new RuntimeException(e); - } + public void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + objectToLoad.load(load_Inner(inputStream, formatter, streamReader)); } - public void store(Storable storageObject, OutputStream outputStream) throws UncheckedIOException, RuntimeException { - convertAndStore(storageObject, formatter, outputStream); + public void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + objectToLoad.load(load_Inner(inputStream, new ChosenFormatter(formatter), streamReader)); } - @SuppressWarnings("unchecked") - public StorageValue load(InputStream inputStream) throws UncheckedIOException, RuntimeException { - try { - F value = (F)streamReader.readFrom(inputStream); - return formatter.parse(value); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } - catch (UnsupportedValueException e) { - throw new RuntimeException(e); - } + public StorageValue load(InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + return load_Inner(inputStream, formatter, streamReader); } //#endregion //#region FileStorage - public void store(Storable storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { - store(storageObject.getStorageRepresentation()); + public void store(Storable storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException { + usingTargetFileOutputStream( + (outputStream) -> convertAndStore_Inner(storageObject.getStorageRepresentation(), formatter, streamWriter, outputStream) + ); + } + + public void store(Storable storageObject, String filePath) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException { + usingFileOutputStream( + new File(filePath), + (outputStream) -> convertAndStore_Inner(storageObject.getStorageRepresentation(), formatter, streamWriter, outputStream) + ); } - public void store(Storable storageObject, String filePath) throws UncheckedIOException, RuntimeException { - try (FileOutputStream fileStream = new FileOutputStream(filePath)) { - convertAndStore(storageObject, formatter, fileStream); + public void store(StorageValue storageObject) throws StoreFailureException, FormattingException, StorageFormatMismatchException, UncheckedIOException { + usingTargetFileOutputStream( + (outputStream) -> convertAndStore_Inner(storageObject, formatter, streamWriter, outputStream) + ); + } + + public StorageValue load() throws LoadFailureException, FormatParseException, StorageFormatMismatchException, UncheckedIOException { + return usingTargetFileInputStream( + (inputStream) -> load(inputStream) + ); + } + + public void loadInto(Loadable targetObject) throws LoadFailureException, FormatParseException, StorageFormatMismatchException, UncheckedIOException { + targetObject.load(load()); + } + + //#endregion + + //#region StorageOperations + + private StorageValue load_Inner(InputStream inputStream, ChosenFormatter formatter, ChosenStreamReader streamReader) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + checkForFormatMismatch(formatter, streamReader); + + Object format; + + try { + format = streamReader.readFrom(inputStream); } - catch (IOException e) { - throw new UncheckedIOException(e); + catch (Exception e) { + throw new LoadFailureException(e); + } + + try { + return formatter.parse(format); + } + catch (Exception e) { + throw new FormatParseException(e); } } - public void store(StorageValue storageObject) throws FormattingException, StoreFailureException, StorageFormatMismatchException { + private void convertAndStore_Inner(StorageValue storageObject, ChosenFormatter formatter, ChosenStreamWriter streamWriter, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException { checkForFormatMismatch(formatter, streamWriter); - Object formattedObject; + Object format; try { - formattedObject = formatter.format(storageObject); + format = formatter.format(storageObject); } catch (Exception e) { throw new FormattingException(e); } - try (FileOutputStream outputStream = new FileOutputStream(targetFilepath.toFile())) { - streamWriter.addTo( - outputStream, - formattedObject - ); + try { + streamWriter.addTo(outputStream, format); } catch (Exception e) { throw new StoreFailureException(e); } } - public void loadInto(Loadable targetObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException { - targetObject.load(load()); - } - - public StorageValue load() throws FormattingException, StoreFailureException, StorageFormatMismatchException { - checkForFormatMismatch(formatter, streamWriter); - - Object data; + //#endregion + + //#region ComponentWrappers - try (FileInputStream inputStream = new FileInputStream(targetFilepath.toFile())) { - data = streamReader.readFrom(inputStream); - } catch (Exception e) { - throw new LoadFailureException(e); - } + private abstract class FormatHolder { + public Class format; - try { - return formatter.parse(data); - } - catch (Exception e) { - throw new FormatParseException(e); + @SuppressWarnings("unchecked") + public FormatHolder(Object genericTarget) { + ParameterizedType targetType = (ParameterizedType)(genericTarget.getClass().getGenericInterfaces()[0]); + format = (Class)targetType.getActualTypeArguments()[0]; } } - - //#endregion - - //#region ComponentWrappers private class ChosenFormatter extends FormatHolder implements ValueFormatter { ValueFormatter innerFormatter; @@ -294,17 +280,7 @@ public F readFrom(InputStream stream) throws IOException { //#region Helpers - private abstract class FormatHolder { - public Class format; - - @SuppressWarnings("unchecked") - public FormatHolder(Object genericTarget) { - ParameterizedType targetType = (ParameterizedType)(genericTarget.getClass().getGenericInterfaces()[0]); - format = (Class)targetType.getActualTypeArguments()[0]; - } - } - - private void checkForFormatMismatch(FormatHolder holder1, FormatHolder holder2) throws StorageFormatMismatchException { + private void checkForFormatMismatch(FormatHolder holder1, FormatHolder holder2) throws StorageFormatMismatchException { if (holder1.format.equals(holder2.format)) return; throw new StorageFormatMismatchException( @@ -313,5 +289,39 @@ private void checkForFormatMismatch(FormatHolder holder1, FormatHol ); } + private interface OutputStreamReceiver { + void run(OutputStream outputStream); + } + + private interface InputStreamReceiver { + T run(InputStream inputStream); + } + + private void usingFileOutputStream(File file, OutputStreamReceiver function) throws UncheckedIOException { + try (FileOutputStream outputStream = new FileOutputStream(file)) { + function.run(outputStream); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private void usingTargetFileOutputStream(OutputStreamReceiver function) throws UncheckedIOException { + usingFileOutputStream(targetFilepath.toFile(), function); + } + + private T usingFileInputStream(File file, InputStreamReceiver function) throws UncheckedIOException { + try (FileInputStream inputStream = new FileInputStream(file)) { + return function.run(inputStream); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private T usingTargetFileInputStream(InputStreamReceiver function) throws UncheckedIOException { + return usingFileInputStream(targetFilepath.toFile(), function); + } + //#endregion } diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 8742dc9..8f1d9d2 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -456,6 +456,77 @@ void convertAndLoadIntegerInto(Path testFile) throws IOException { assertEquals(expectedInteger, loadable.getValue()); } + @Test + @UseTestFile + public void convertAndLoadStringInto_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestIntegerValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.convertAndLoadInto(loadable, inputStream)); + } + } + + @Test + @UseTestFile + public void convertAndLoadStringInto_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestStringErrorStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.convertAndLoadInto(loadable, inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void convertAndLoadStringInto_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestStringErrorValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.convertAndLoadInto(loadable, inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + @Test @UseTestFile void convertThenFormatAndLoadStringInto(Path testFile) throws IOException { From f7edb8574bbe944d566825ce6c55cea0b1a41960 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 16:29:23 +0000 Subject: [PATCH 063/162] Handling storage component failures on convertThenFormatAndLoadInto --- src/test/java/storage/StorageTests.java | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 8f1d9d2..b45a177 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -575,6 +575,80 @@ void convertThenFormatAndLoadIntegerInto(Path testFile) throws IOException { assertEquals(expectedInteger, loadable.getValue()); } + @Test + @UseTestFile + public void convertThenFormatAndLoadStringInto_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + + TestLoadable loadable = new TestLoadable(); + ValueFormatter formatter = new TestIntegerValueFormatter(); + + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.convertAndLoadInto(loadable, formatter, inputStream)); + } + } + + @Test + @UseTestFile + public void convertThenFormatAndLoadStringInto_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + + TestLoadable loadable = new TestLoadable(); + ValueFormatter formatter = new TestStringValueFormatter(); + + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.convertAndLoadInto(loadable, formatter, inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void convertThenFormatAndLoadStringInto_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + + TestLoadable loadable = new TestLoadable(); + ValueFormatter formatter = new TestStringErrorValueFormatter(); + + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.convertAndLoadInto(loadable, formatter, inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + @Test @UseTestFile public void storeStringToStream(Path testFile) throws IOException { From 892189b7070cf981ada3750b8210b5d7092b1c25 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 16:34:36 +0000 Subject: [PATCH 064/162] Handling storage component failures on storeToStream --- src/test/java/storage/StorageTests.java | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index b45a177..723f7be 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -693,6 +693,68 @@ public void storeIntegerToStream(Path testFile) throws IOException { assertEquals(expectedInteger, actualInteger); } + @Test + @UseTestFile + public void storeStringToStream_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.store(storable, outputStream)); + } + } + + @Test + @UseTestFile + public void storeStringToStream_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(storable, outputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void storeStringToStream_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(storable, outputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + @Test @UseTestFile public void loadStringFromInputStream(Path testFile) throws IOException { From 2cf9198caeec4a485fda7ec48bd2920b463317f2 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 17:20:52 +0000 Subject: [PATCH 065/162] Handling storage component failures on loadFromInputStream Includes small load() rework and addition of untested loadWithType() method --- src/main/java/storage/Storage.java | 21 +++++++- src/test/java/storage/StorageTests.java | 69 ++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 3 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index c7cb8e9..96c9f21 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -136,10 +136,29 @@ public void convertAndLoadInto(Loadable objectToLoad, ValueFormatter form objectToLoad.load(load_Inner(inputStream, new ChosenFormatter(formatter), streamReader)); } - public StorageValue load(InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + public StorageValue load(InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { return load_Inner(inputStream, formatter, streamReader); } + //TODO: Test + @SuppressWarnings("unchecked") + public StorageValue loadWithType(InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + try { + return (StorageValue)load(inputStream); + } + catch (ClassCastException e) { + Class chosenType = TypeReference.instantiate().getContainedClass(); + + throw new ClassCastException( + "The format " + + chosenType.getSimpleName() + + " is inconsistant with the type " + + formatter.format.getSimpleName() + + " produced by the chosen formatter." + ); + } + } + //#endregion //#region FileStorage diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 723f7be..8d98b74 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -769,7 +769,7 @@ public void loadStringFromInputStream(Path testFile) throws IOException { InputStream inputStream = new FileInputStream(testFile.toFile()); - StorageValue actualStorageValue = storage.load(inputStream); + StorageValue actualStorageValue = storage.load(inputStream); StorageValue expectedStorageValue = new TestStorageValue(testString); @@ -790,13 +790,78 @@ public void loadIntegerFromInputStream(Path testFile) throws IOException { InputStream inputStream = new FileInputStream(testFile.toFile()); - StorageValue actualStorageValue = storage.load(inputStream); + StorageValue actualStorageValue = storage.load(inputStream); StorageValue expectedStorageValue = new TestStorageValue(testInteger); assertEquals(expectedStorageValue, actualStorageValue); } + @Test + @UseTestFile + public void loadStringFromInputStream_IncorrectFormatter(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.load(inputStream)); + } + } + + @Test + @UseTestFile + public void loadStringFromInputStream_FileWriteError(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.load(inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void loadStringFromInputStream_FormatterError(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.load(inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + @Test @UseTestFile public void storeStorableOfString(Path testFile) throws IOException { From 07e750dadc6f5a387b30450d5f9c97980e344e38 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 17:29:54 +0000 Subject: [PATCH 066/162] Handling storage component failures on storeStorable --- src/test/java/storage/StorageTests.java | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 8d98b74..da8e890 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -898,6 +898,56 @@ public void storeStorableOfInteger(Path testFile) throws IOException { assertEquals(expectedInteger, actualInteger); } + @Test + @UseTestFile + public void storeStorableOfString_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.store(storable)); + } + + @Test + @UseTestFile + public void storeStorableOfString_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(storable) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storeStorableOfString_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(storable) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + @Test @UseTestFile public void storeStorableOfStringAtFilepath(Path testFile) throws IOException { From e6273e23f1e2568f9e345b99d58cda68a827d469 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 17:45:08 +0000 Subject: [PATCH 067/162] Handling storage component failures on storeStorableAtFilepath --- src/test/java/storage/StorageTests.java | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index da8e890..3475add 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -982,6 +982,53 @@ public void storeStorableOfIntegerAtFilepath(Path testFile) throws IOException { assertEquals(expectedInteger, actualInteger); } + @Test + @UseTestFile + public void storeStorableOfStringAtFilepath_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.store(storable, testFile.toString())); + } + + @Test + @UseTestFile + public void storeStorableOfStringAtFilepath_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(storable, testFile.toString()) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storeStorableOfStringAtFilepath_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + Storable storable = new TestStorable(expectedString); + Storage storage = new Storage() + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(storable, testFile.toString()) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + @Test @UseTestFile public void storeStorageValueOfString(Path testFile) throws IOException { From cc490944258a6aac93ebe4e7b05d3c6b4d7ce5d7 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 21:43:47 +0000 Subject: [PATCH 068/162] Handling storage component failures on storeStorageValue --- src/test/java/storage/StorageTests.java | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 3475add..6225e31 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1065,6 +1065,56 @@ public void storeStorageValueOfInteger(Path testFile) throws IOException { assertEquals(expectedInteger, actualInteger); } + @Test + @UseTestFile + public void storeStorageValueOfString_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + StorageValue storageValue = new TestStorageValue(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.store(storageValue)); + } + + @Test + @UseTestFile + public void storeStorageValueOfString_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + StorageValue storageValue = new TestStorageValue(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(storageValue) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storeStorageValueOfString_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + StorageValue storageValue = new TestStorageValue(expectedString); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(storageValue) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + @Test @UseTestFile void LoadStringInto(Path testFile) throws IOException { From 468db8dbe45eda2d2aaaf10fd811d3321b932578 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 22:00:04 +0000 Subject: [PATCH 069/162] Handling storage component failures on loadInto --- src/test/java/storage/StorageTests.java | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 6225e31..89a13f7 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1152,6 +1152,62 @@ void LoadIntegerInto(Path testFile) throws IOException { assertEquals(expectedInteger, loadable.getValue()); } + + @Test + @UseTestFile + public void LoadStringInto_IncorrectFormatter(Path testFile) throws IOException { + String expectedString = "testString"; + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestIntegerStreamEditor()); + + Files.writeString(testFile, expectedString); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.loadInto(loadable)); + } + + @Test + @UseTestFile + public void LoadStringInto_FileWriteError(Path testFile) throws IOException { + String expectedString = "testString"; + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestStringErrorStreamEditor()); + + Files.writeString(testFile, expectedString); + + + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.loadInto(loadable) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void LoadStringInto_FormatterError(Path testFile) throws IOException { + String expectedString = "testString"; + TestLoadable loadable = new TestLoadable(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFormatter(new TestStringErrorValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.loadInto(loadable) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } @Test @UseTestFile From f2eca3f014b9a0c884f998dd0dbe3a683a2d030d Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 22:34:42 +0000 Subject: [PATCH 070/162] Handling storage component failures on loadFromTargetPath --- src/test/java/storage/StorageTests.java | 53 +++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 89a13f7..16c5824 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1247,6 +1247,59 @@ public void loadIntegerFromTargetPath(Path testFile) throws IOException { assertEquals(expectedStorageValue, actualStorageValue); } + @Test + @UseTestFile + public void loadStringFromTargetPath_IncorrectFormatter(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, testString); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.load()); + } + + @Test + @UseTestFile + public void loadStringFromTargetPath_FileWriteError(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.load() + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void loadStringFromTargetPath_FormatterError(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + Files.writeString(testFile, testString); + + + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.load() + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + //TODO: Consider edge cases for all tests //Include mismatched component types. e.g. Read file as integer and attempt formatting of string input. //Ensure descriptive exceptions for this case. From 2491ce0237e47cc0d524af8f38fd1b30dfddf777 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 15 Mar 2026 23:50:12 +0000 Subject: [PATCH 071/162] Handling storage component failures on loadWithType --- src/main/java/storage/Storage.java | 1 - src/test/java/storage/StorageTests.java | 111 +++++++++++++++++++++++- 2 files changed, 107 insertions(+), 5 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 96c9f21..6134634 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -140,7 +140,6 @@ public StorageValue load(InputStream inputStream) throws LoadFailureException return load_Inner(inputStream, formatter, streamReader); } - //TODO: Test @SuppressWarnings("unchecked") public StorageValue loadWithType(InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { try { diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 16c5824..6df81f2 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -862,6 +862,113 @@ public void loadStringFromInputStream_FormatterError(Path testFile) throws IOExc } } + @Test + @UseTestFile + public void loadWithTypeString(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + StorageValue actualStorageValue = storage.loadWithType(inputStream); + + + StorageValue expectedStorageValue = new TestStorageValue(testString); + assertEquals(expectedStorageValue, actualStorageValue); + } + + @Test + @UseTestFile + public void loadWithTypeInteger(Path testFile) throws IOException { + int testInteger = 10; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestIntegerStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, Integer.toString(testInteger)); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + StorageValue actualStorageValue = storage.loadWithType(inputStream); + + + StorageValue expectedStorageValue = new TestStorageValue(testInteger); + assertEquals(expectedStorageValue, actualStorageValue); + } + + @Test + @UseTestFile + public void loadWithTypeString_IncorrectFormatter(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.loadWithType(inputStream)); + } + } + + @Test + @UseTestFile + public void loadWithTypeString_FileWriteError(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.loadWithType(inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void loadWithTypeString_FormatterError(Path testFile) throws IOException { + String testString = "testString"; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.loadWithType(inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + @Test @UseTestFile public void storeStorableOfString(Path testFile) throws IOException { @@ -1299,8 +1406,4 @@ public void loadStringFromTargetPath_FormatterError(Path testFile) throws IOExce ); assertInstanceOf(ExampleException.class, exception.getCause()); } - - //TODO: Consider edge cases for all tests - //Include mismatched component types. e.g. Read file as integer and attempt formatting of string input. - //Ensure descriptive exceptions for this case. } From ed70a9f58187a1d8f13d23e2be4df9eafd867d7f Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 18 Mar 2026 00:12:29 +0000 Subject: [PATCH 072/162] Start of Storage documentation --- src/main/java/storage/Storage.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 6134634..9445e6c 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -28,6 +28,10 @@ public Storage() {} //#region Getters + /** + * Gets the currently tagetted filepath being used for storage + * @return The targeted filepath + */ public Path getTargetFilepath() { return targetFilepath; } @@ -36,21 +40,42 @@ public Path getTargetFilepath() { //#region Configuration + /** + * Sets the target filepath the be use for storage + * @param filepath The filepath to target + * @return This Storage object for method chaining + */ public Storage setTargetPath(Path filepath) { targetFilepath = filepath; return this; } + /** + * Sets the target filepath the be use for storage + * @param filepath The absolute filepath to be targeted + * @return This Storage object for method chaining + */ public Storage setAbsoluteTargetPath(String filepath) { targetFilepath = Path.of(filepath); return this; } + /** + * Sets the target filepath the be use for storage + * @param filepath The relative filepath to be targeted + * @return This Storage object for method chaining + */ public Storage setRelativeTargetPath(String filepath) { targetFilepath = Path.of("." + File.separator + filepath); return this; } + /** + * Sets the formatter to be used for converting StorageValues into storage representations + * @param The target format to convert values to/from + * @param formatter The formatter to be used + * @return This Storage object for method chaining + */ public Storage setFormatter(ValueFormatter formatter) { this.formatter = new ChosenFormatter(formatter); return this; From a28bb5e136c8d9a6f1362171eca924c5e8e92406 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 18 Mar 2026 23:47:31 +0000 Subject: [PATCH 073/162] Configuration methods documentation --- src/main/java/storage/Storage.java | 39 +++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 9445e6c..07de8e8 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -81,16 +81,34 @@ public Storage setFormatter(ValueFormatter formatter) { return this; } + /** + * Sets the stream writer to be used for storing storage values + * @param The data format expected to be writen + * @param streamWriter The stream writer to be selected + * @return This Storage object for method chaining + */ public Storage setStreamWriter(StreamWriter streamWriter) { this.streamWriter = new ChosenStreamWriter<>(streamWriter); return this; } + /** + * Sets the stream reader to be used for reading values from storage + * @param The data format expected to be output when read + * @param streamReader The stream reader to be selected + * @return This Storage object for method chaining + */ public Storage setStreamReader(StreamReader streamReader) { this.streamReader = new ChosenStreamReader<>(streamReader); return this; } + /** + * Sets the stream reader to be used for reading and storing values in storage + * @param The data format expected to be read or stored + * @param streamEditor The stream editor to be selected + * @return This Storage object for method chaining + */ public Storage setStreamEditor(StreamEditor streamEditor) { this.streamWriter = new ChosenStreamWriter<>(streamEditor); this.streamReader = new ChosenStreamReader<>(streamEditor); @@ -102,30 +120,33 @@ public Storage setStreamEditor(StreamEditor streamEditor) { //#region ConvenienceMethods /** + * Sets the file reader to be used for reading and storing values in storage. * An equvalent method to setStreamWriter(StreamWriter streamWriter) - * @param - * @param fileWriter - * @return + * @param The data format expected to be writen + * @param fileWriter The file writer to be selected + * @return This Storage object for method chaining */ public Storage setFileWriter(StreamWriter fileWriter) { return setStreamWriter(fileWriter); } /** + * Sets the file reader to be used for reading values from storage. * An equvalent method to setStreamReader(StreamReader streamReader) - * @param - * @param fileWriter - * @return + * @param The data format expected to be writen + * @param fileReader The file reader to be selected + * @return This Storage object for method chaining */ public Storage setFileReader(StreamReader fileReader) { return setStreamReader(fileReader); } /** + * Sets the stream reader to be used for reading and storing values in storage. * An equvalent method to setStreamEditor(StreamEditor streamEditor) - * @param - * @param fileWriter - * @return + * @param The data format expected to be read or stored + * @param fileEditor The stream editor to be selected + * @return This Storage object for method chaining */ public Storage setFileEditor(StreamEditor fileEditor) { return setStreamEditor(fileEditor); From 4c8ccd18a5cc8a6eddf8804e52d4196077f1e842 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 19 Mar 2026 00:15:48 +0000 Subject: [PATCH 074/162] Stream storage documentation --- src/main/java/storage/Storage.java | 59 ++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 07de8e8..439d2e8 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -157,35 +157,78 @@ public Storage setFileEditor(StreamEditor fileEditor) { //#region StreamStorage /** - * - * @param - * @param storageObject - * @param formatter Only set for execution of this function. Use setFormatter to use this for multiple executions. - * @param outputStream - * @throws UnsupportedValueException - * @throws UncheckedIOException - * @throws RuntimeException + * Stores the given object to the given output stream, converting the object using the specified formatter to produce a storable data format + * @param The data format to be used for storage + * @param storageObject The object to be stored + * @param formatter The formatter to be used to convert values for storage. Only set for execution of this function. Use setFormatter to use this for multiple executions. + * @param outputStream The stream to be used + * @throws StoreFailureException + * @throws FormattingException + * @throws StorageFormatMismatchException */ public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException { convertAndStore_Inner(storageObject.getStorageRepresentation(), new ChosenFormatter(formatter), streamWriter, outputStream); } + /** + * Stores the given object in the given output stream + * @param storageObject The object to be stored + * @param outputStream The stream to be used + * @throws StoreFailureException + * @throws FormattingException + * @throws StorageFormatMismatchException + */ public void store(Storable storageObject, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException { convertAndStore_Inner(storageObject.getStorageRepresentation(), formatter, streamWriter, outputStream); } + /** + * Reads a value from the given input stream, converts the value using the chosen formatter and loads it into the given object + * @param objectToLoad The object to load the value into + * @param inputStream The input stream to be read + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + */ public void convertAndLoadInto(Loadable objectToLoad, InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { objectToLoad.load(load_Inner(inputStream, formatter, streamReader)); } + /** + * Reads a value from the given input stream, converts the value using the provided formatter and loads it into the given object + * @param The expected value format to be read and provided to the formatter + * @param objectToLoad The object to load the value into + * @param formatter The formatter to be used to convert data from the stream + * @param inputStream The input stream to be read + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + */ public void convertAndLoadInto(Loadable objectToLoad, ValueFormatter formatter, InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { objectToLoad.load(load_Inner(inputStream, new ChosenFormatter(formatter), streamReader)); } + /** + * Loads a value from the given input stream + * @param inputStream The input stream to read from + * @return The value read from the stream, once formatted by the chosen formatter + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + */ public StorageValue load(InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { return load_Inner(inputStream, formatter, streamReader); } + /** + * Loads a value from the given input stream and specifies the expected type + * @param The expected inner type of the returned storage value + * @param inputStream The input stream to be read + * @return The value read from the stream, once formatted by the chosen formatter + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + */ @SuppressWarnings("unchecked") public StorageValue loadWithType(InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { try { From 3760127a353a2f9674819c9d9aca94d9c7fd00b7 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:13:35 +0000 Subject: [PATCH 075/162] File storage documentation --- src/main/java/storage/Storage.java | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 439d2e8..72b9a28 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -251,12 +251,29 @@ public StorageValue loadWithType(InputStream inputStream) throws LoadFail //#region FileStorage + /** + * Stores the given object in the targetted file + * @param storageObject The object to be stored + * @throws UnsupportedValueException + * @throws UncheckedIOException + * @throws RuntimeException + * @throws UncheckedIOException + */ public void store(Storable storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException { usingTargetFileOutputStream( (outputStream) -> convertAndStore_Inner(storageObject.getStorageRepresentation(), formatter, streamWriter, outputStream) ); } + /** + * Stores the given object in the given file + * @param storageObject The object to be stored + * @param filePath The target file to use for storage + * @throws UnsupportedValueException + * @throws UncheckedIOException + * @throws RuntimeException + * @throws UncheckedIOException + */ public void store(Storable storageObject, String filePath) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException { usingFileOutputStream( new File(filePath), @@ -264,18 +281,43 @@ public void store(Storable storageObject, String filePath) throws UnsupportedVal ); } + /** + * Stores the given object in the targetted file + * @param The type of storage value to be stored + * @param storageObject The object to be stored + * @throws StoreFailureException + * @throws FormattingException + * @throws StorageFormatMismatchException + * @throws UncheckedIOException + */ public void store(StorageValue storageObject) throws StoreFailureException, FormattingException, StorageFormatMismatchException, UncheckedIOException { usingTargetFileOutputStream( (outputStream) -> convertAndStore_Inner(storageObject, formatter, streamWriter, outputStream) ); } + /** + * Loads a value from the chosen file + * @return The loaded value + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + * @throws UncheckedIOException + */ public StorageValue load() throws LoadFailureException, FormatParseException, StorageFormatMismatchException, UncheckedIOException { return usingTargetFileInputStream( (inputStream) -> load(inputStream) ); } + /** + * Loads a value from the chosen file into the given object + * @param targetObject The object to load stored values into + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + * @throws UncheckedIOException + */ public void loadInto(Loadable targetObject) throws LoadFailureException, FormatParseException, StorageFormatMismatchException, UncheckedIOException { targetObject.load(load()); } From 1f87c65f6e8435876714e735efbe6f0ec1990141 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 24 Mar 2026 22:48:13 +0000 Subject: [PATCH 076/162] Relocation of TypeReference to helper_objects --- src/main/java/{storage => helper_objects}/TypeReference.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/{storage => helper_objects}/TypeReference.java (96%) diff --git a/src/main/java/storage/TypeReference.java b/src/main/java/helper_objects/TypeReference.java similarity index 96% rename from src/main/java/storage/TypeReference.java rename to src/main/java/helper_objects/TypeReference.java index 1449f36..9b2b9d1 100644 --- a/src/main/java/storage/TypeReference.java +++ b/src/main/java/helper_objects/TypeReference.java @@ -1,4 +1,4 @@ -package storage; +package helper_objects; import java.lang.reflect.*; From c40001471ae20b36491837e9488dfee65d3d0faf Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 13 May 2026 23:41:25 +0100 Subject: [PATCH 077/162] Broken changes: Compiler interface and builder changes Custom components also defined --- docs/diagrams/CustomCompilers.drawio.svg | 909 ++++++++++++++++++ docs/diagrams/Storage.drawio.svg | 24 +- .../java/component_construction/Compiler.java | 28 +- .../builders/CompilerBuilder.java | 37 +- .../CustomCodeGenerator.java | 6 + .../custom_components/CustomCompiler.java | 30 + .../CustomCompilerFactory.java | 47 + .../CustomLexicalAnalyser.java | 6 + .../CustomSyntaxAnalyser.java | 6 + .../StorableCustomCompiler.java | 42 + .../syntax_analysis/CLR1ParserFactory.java | 1 + src/main/java/storage/Storage.java | 2 + .../{ => external_interfaces}/Loadable.java | 2 +- .../{ => external_interfaces}/Storable.java | 2 +- .../StorableAndLoadable.java | 3 + .../java/syntax_analysis/SyntaxAnalyser.java | 41 +- .../{ => parsing/parsers}/CLR1Parser.java | 2 +- .../{ => parsing/parsers}/LR0Parser.java | 4 +- .../parsing/parsers/Parser.java | 48 + .../{ => parsing/parsers}/SLR1Parser.java | 2 +- src/test/java/storage/StorageTests.java | 1 + .../java/syntax_analysis/CLR1ParserTests.java | 1 + .../java/syntax_analysis/LR0ParserTests.java | 1 + .../java/syntax_analysis/SLR1ParserTests.java | 1 + .../test_aids/test_storage/TestLoadable.java | 2 +- .../test_aids/test_storage/TestStorable.java | 2 +- 26 files changed, 1159 insertions(+), 91 deletions(-) create mode 100644 docs/diagrams/CustomCompilers.drawio.svg create mode 100644 src/main/java/component_construction/custom_components/CustomCodeGenerator.java create mode 100644 src/main/java/component_construction/custom_components/CustomCompiler.java create mode 100644 src/main/java/component_construction/custom_components/CustomCompilerFactory.java create mode 100644 src/main/java/component_construction/custom_components/CustomLexicalAnalyser.java create mode 100644 src/main/java/component_construction/custom_components/CustomSyntaxAnalyser.java create mode 100644 src/main/java/component_construction/custom_components/StorableCustomCompiler.java rename src/main/java/storage/{ => external_interfaces}/Loadable.java (77%) rename src/main/java/storage/{ => external_interfaces}/Storable.java (78%) create mode 100644 src/main/java/storage/external_interfaces/StorableAndLoadable.java rename src/main/java/syntax_analysis/{ => parsing/parsers}/CLR1Parser.java (99%) rename src/main/java/syntax_analysis/{ => parsing/parsers}/LR0Parser.java (99%) create mode 100644 src/main/java/syntax_analysis/parsing/parsers/Parser.java rename src/main/java/syntax_analysis/{ => parsing/parsers}/SLR1Parser.java (99%) diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg new file mode 100644 index 0000000..e04e1cb --- /dev/null +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -0,0 +1,909 @@ + + + + + + + + + + +
+
+
+
+ Compiler <<I>> +
+
+
+
+
+ + Compiler <<I>> + +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ Contains +
+
+
+
+ + Contains + +
+
+
+ + + + + + + +
+
+
+
+ CustomCompiler +
+
+
+
+
+ + CustomCompiler + +
+
+
+ + + + + + + +
+
+
+
+ StoreAndLoadable <<I>> +
+
+
+
+
+ + StoreAndLoadable <<I>> + +
+
+
+ + + + + + + +
+
+
+
+ Storable <<I>> +
+
+
+
+
+ + Storable <<I>> + +
+
+
+ + + + + + + +
+
+
+
+ Loadable <<I>> +
+
+
+
+
+ + Loadable <<I>> + +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ Creates +
+
+
+
+ + Creates + +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ Uses +
+
+
+
+ + Uses + +
+
+
+ + + + + + + +
+
+
+
+ CustomCompilerBuilder +
+
+
+
+
+ + CustomCompilerBuilder + +
+
+
+ + + + + + + +
+
+
+
+ CustomLexicalAnalyser <<I>> +
+
+
+
+
+ + CustomLexicalAnalyser <<I>> + +
+
+
+ + + + + + + +
+
+
+
+ CustomSyntaxAnalyser <<I>> +
+
+
+
+
+ + CustomSyntaxAnalyser <<I>> + +
+
+
+ + + + + + + +
+
+
+
+ CustomCodeGenerator <<I>> +
+
+
+
+
+ + CustomCodeGenerator <<I>> + +
+
+
+ + + + + + + + +
+
+
+ Creates +
+
+
+
+ + Creates + +
+
+
+ + + + + + + +
+
+
+
+ CustomLexicalAnalyserFactory <<I>> +
+
+
+
+
+ + CustomLexicalAnalyserFactory <<I>> + +
+
+
+ + + + + + + + +
+
+
+ Creates +
+
+
+
+ + Creates + +
+
+
+ + + + + + + +
+
+
+
+ CustomSyntaxAnalyserFactory <<I>> +
+
+
+
+
+ + CustomSyntaxAnalyserFactory <<I>> + +
+
+
+ + + + + + + + +
+
+
+ Creates +
+
+
+
+ + Creates + +
+
+
+ + + + + + + +
+
+
+
+ CustomCodeGeneratorFactory <<I>> +
+
+
+
+
+ + CustomCodeGeneratorFactory <<I>> + +
+
+
+ + + + + + + + +
+
+
+ Builder +
+
+
+
+ + Builder + +
+
+
+ + + + + + + + +
+
+
+ CustomCompiler +
+
+
+
+ + CustomCompiler + +
+
+
+ + + + + + + +
+
+
+
+ LexicalAnalyser <<I>> +
+
+
+
+
+ + LexicalAnalyser <<I>> + +
+
+
+ + + + + + + +
+
+
+
+ SyntaxAnalyser <<I>> +
+
+
+
+
+ + SyntaxAnalyser <<I>> + +
+
+
+ + + + + + + +
+
+
+
+ CodeGenerator <<I>> +
+
+
+
+
+ + CodeGenerator <<I>> + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Store +
+
+
+
+ + Store + +
+
+
+ + + + +
+
+
+ Load +
+
+
+
+ + Load + +
+
+
+ + + + + + + +
+
+
+
+ Storage +
+
+
+
+
+ + Storage + +
+
+
+ + + + + + + + +
+
+
+ load() +
+
+
+
+ + load() + +
+
+
+ + + + +
+
+
+ Store() +
+
+
+
+ + Store() + +
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ Query and Instantiate +
+
+
+
+ + Query and Instantiate + +
+
+
+ + + + + + + +
+
+
+
+ CustomCompilerStorage +
+
+
+
+
+ + CustomCompilerStorage + +
+
+
+ + + + + + + + + + + +
+
+
+ Store() +
+
+
+
+ + Store() + +
+
+
+ + + + + + + + + + + + +
+
+
+ Instantiate +
+
+
+
+ + Instantiate + +
+
+
+ + + + + + + + +
+
+
+ Repositories +
+
+
+
+ + Repositories + +
+
+
+ + + + + + + +
+
+
+
+ LexicalAnalyserRepository +
+
+
+
+
+ + LexicalAnalyserRepository + +
+
+
+ + + + + + + +
+
+
+
+ LexicalAnalyserRepository +
+
+
+
+
+ + LexicalAnalyserRepository + +
+
+
+ + + + + + + +
+
+
+
+ LexicalAnalyserRepository +
+
+
+
+
+ + LexicalAnalyserRepository + +
+
+
+ + + + + + + +
+
+
+ File +
+
+
+
+ + File + +
+
+
+
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file diff --git a/docs/diagrams/Storage.drawio.svg b/docs/diagrams/Storage.drawio.svg index 2aebcd4..174ce39 100644 --- a/docs/diagrams/Storage.drawio.svg +++ b/docs/diagrams/Storage.drawio.svg @@ -1,4 +1,4 @@ - + @@ -232,7 +232,7 @@ -
+
Produces a set of @@ -256,13 +256,13 @@
- Compiler Component + Component
- Compiler Comp... + Component @@ -365,7 +365,7 @@ -
+
Passed into @@ -434,7 +434,7 @@ -
+
Throws @@ -442,7 +442,7 @@
- + Throws @@ -478,7 +478,7 @@ -
+
Produces @@ -486,7 +486,7 @@
- + Produces @@ -526,7 +526,7 @@ -
+
Stream Editors @@ -680,7 +680,7 @@ -
+
Text @@ -688,7 +688,7 @@
- + Text diff --git a/src/main/java/component_construction/Compiler.java b/src/main/java/component_construction/Compiler.java index 7ff7b57..4d7d7ea 100644 --- a/src/main/java/component_construction/Compiler.java +++ b/src/main/java/component_construction/Compiler.java @@ -1,30 +1,6 @@ package component_construction; - -import code_generation.CodeGenerator; -import grammar_objects.Token; -import lexical_analysis.LexicalAnalyser; -import syntax_analysis.SyntaxAnalyser; import syntax_analysis.parsing.ParseFailedException; -import syntax_analysis.parsing.ParseState; - -public class Compiler { - protected LexicalAnalyser lexicalAnalyser; - protected SyntaxAnalyser syntaxAnalyser; - protected CodeGenerator codeGenerator; - - public Compiler( - LexicalAnalyser lexicalAnalyser, - SyntaxAnalyser syntaxAnalyser, - CodeGenerator codeGenerator - ) { - this.lexicalAnalyser = lexicalAnalyser; - this.syntaxAnalyser = syntaxAnalyser; - this.codeGenerator = codeGenerator; - } - public String compile(String input) throws ParseFailedException { - Token[] tokens = lexicalAnalyser.analyse(input); - ParseState parseRoot = syntaxAnalyser.analyse(tokens); - return codeGenerator.generate(parseRoot); - } +public interface Compiler { + public String compile(String input) throws ParseFailedException; } diff --git a/src/main/java/component_construction/builders/CompilerBuilder.java b/src/main/java/component_construction/builders/CompilerBuilder.java index 2a11c63..bab8451 100644 --- a/src/main/java/component_construction/builders/CompilerBuilder.java +++ b/src/main/java/component_construction/builders/CompilerBuilder.java @@ -6,9 +6,14 @@ import lexical_analysis.*; import syntax_analysis.SyntaxAnalyser; import code_generation.CodeGenerator; -import component_construction.Compiler; import component_construction.ParameterError; import component_construction.bundles.GrammarBundle; +import component_construction.custom_components.CustomCodeGenerator; +import component_construction.custom_components.CustomCompiler; +import component_construction.custom_components.CustomCompilerFactory; +import component_construction.custom_components.CustomLexicalAnalyser; +import component_construction.custom_components.CustomSyntaxAnalyser; +import component_construction.custom_components.StorableCustomCompiler; import component_construction.factories.code_generation.CodeGeneratorFactory; import component_construction.factories.lexical_analysis.LexicalAnalyserFactory; import component_construction.factories.syntax_analysis.SyntaxAnalyserFactory; @@ -137,7 +142,23 @@ public CompilerBuilder setDynamicTokenRegex(DynamicTokenRegex[] dynamicTokenRege } - public Compiler createCompiler() { + public CustomCompiler createCompiler() { + checkForCompleteBuild(); + + return new CustomCompilerFactory().produce( + lexicalAnalyserFactory, + syntaxAnalyserFactory, + codeGeneratorFactory, + grammar, + whitespaceDelimiters, + stronglyReservedWords, + weaklyReservedWords, + dynamicTokenRegex, + ruleConvertor + ); + } + + public StorableCustomCompiler createStorableCompiler() { checkForCompleteBuild(); if(whitespaceDelimiters == null) whitespaceDelimiters = new String[]{}; @@ -156,10 +177,14 @@ public Compiler createCompiler() { SyntaxAnalyser syntaxAnalyser = syntaxAnalyserFactory.produceAnalyser(parts); CodeGenerator codeGenerator = codeGeneratorFactory.produceGenerator(ruleConvertor); - return new Compiler( - lexicalAnalyser, - syntaxAnalyser, - codeGenerator + if(!(lexicalAnalyser instanceof CustomLexicalAnalyser)) throw new RuntimeException("TODO"); //TODO + if(!(syntaxAnalyser instanceof CustomSyntaxAnalyser)) throw new RuntimeException("TODO"); //TODO + if(!(codeGenerator instanceof CustomCodeGenerator)) throw new RuntimeException("TODO"); //TODO + + return new StorableCustomCompiler( + (CustomLexicalAnalyser)lexicalAnalyser, + (CustomSyntaxAnalyser)syntaxAnalyser, + (CustomCodeGenerator)codeGenerator ); } diff --git a/src/main/java/component_construction/custom_components/CustomCodeGenerator.java b/src/main/java/component_construction/custom_components/CustomCodeGenerator.java new file mode 100644 index 0000000..f71a3b7 --- /dev/null +++ b/src/main/java/component_construction/custom_components/CustomCodeGenerator.java @@ -0,0 +1,6 @@ +package component_construction.custom_components; + +import code_generation.CodeGenerator; +import storage.external_interfaces.StorableAndLoadable; + +public interface CustomCodeGenerator extends CodeGenerator, StorableAndLoadable {} diff --git a/src/main/java/component_construction/custom_components/CustomCompiler.java b/src/main/java/component_construction/custom_components/CustomCompiler.java new file mode 100644 index 0000000..9fb9a2f --- /dev/null +++ b/src/main/java/component_construction/custom_components/CustomCompiler.java @@ -0,0 +1,30 @@ +package component_construction.custom_components; + +import code_generation.CodeGenerator; +import component_construction.Compiler; +import grammar_objects.Token; +import lexical_analysis.LexicalAnalyser; +import syntax_analysis.SyntaxAnalyser; +import syntax_analysis.parsing.*; + +public class CustomCompiler implements Compiler { + protected LexicalAnalyser lexicalAnalyser; + protected SyntaxAnalyser syntaxAnalyser; + protected CodeGenerator codeGenerator; + + public CustomCompiler( + LexicalAnalyser lexicalAnalyser, + SyntaxAnalyser syntaxAnalyser, + CodeGenerator codeGenerator + ) { + this.lexicalAnalyser = lexicalAnalyser; + this.syntaxAnalyser = syntaxAnalyser; + this.codeGenerator = codeGenerator; + } + + public String compile(String input) throws ParseFailedException { + Token[] tokens = lexicalAnalyser.analyse(input); + ParseState parseRoot = syntaxAnalyser.analyse(tokens); + return codeGenerator.generate(parseRoot); + } +} \ No newline at end of file diff --git a/src/main/java/component_construction/custom_components/CustomCompilerFactory.java b/src/main/java/component_construction/custom_components/CustomCompilerFactory.java new file mode 100644 index 0000000..dd221c3 --- /dev/null +++ b/src/main/java/component_construction/custom_components/CustomCompilerFactory.java @@ -0,0 +1,47 @@ +package component_construction.custom_components; + +import code_generation.CodeGenerator; +import component_construction.factories.code_generation.CodeGeneratorFactory; +import component_construction.factories.lexical_analysis.LexicalAnalyserFactory; +import component_construction.factories.syntax_analysis.SyntaxAnalyserFactory; +import grammar_objects.Grammar; +import grammar_objects.GrammarParts; +import grammar_objects.RuleConvertor; +import lexical_analysis.DynamicTokenRegex; +import lexical_analysis.LexicalAnalyser; +import syntax_analysis.SyntaxAnalyser; + +public class CustomCompilerFactory { + + public CustomCompiler produce( + LexicalAnalyserFactory lexicalAnalyserFactory, + SyntaxAnalyserFactory syntaxAnalyserFactory, + CodeGeneratorFactory codeGeneratorFactory, + Grammar grammar, + String[] whitespaceDelimiters, + String[] stronglyReservedWords, + String[] weaklyReservedWords, + DynamicTokenRegex[] dynamicTokenRegex, + RuleConvertor ruleConvertor + ) { + if(whitespaceDelimiters == null) whitespaceDelimiters = new String[]{}; + if(stronglyReservedWords == null) stronglyReservedWords = new String[]{}; + if(weaklyReservedWords == null) weaklyReservedWords = new String[]{}; + if(dynamicTokenRegex == null) dynamicTokenRegex = new DynamicTokenRegex[]{}; + + LexicalAnalyser lexicalAnalyser = lexicalAnalyserFactory.produceAnalyser( + whitespaceDelimiters, + stronglyReservedWords, + weaklyReservedWords, + dynamicTokenRegex + ); + SyntaxAnalyser syntaxAnalyser = syntaxAnalyserFactory.produceAnalyser(grammar.getParts()); + CodeGenerator codeGenerator = codeGeneratorFactory.produceGenerator(ruleConvertor); + + return new CustomCompiler( + lexicalAnalyser, + syntaxAnalyser, + codeGenerator + ); + } +} diff --git a/src/main/java/component_construction/custom_components/CustomLexicalAnalyser.java b/src/main/java/component_construction/custom_components/CustomLexicalAnalyser.java new file mode 100644 index 0000000..dd7c05d --- /dev/null +++ b/src/main/java/component_construction/custom_components/CustomLexicalAnalyser.java @@ -0,0 +1,6 @@ +package component_construction.custom_components; + +import lexical_analysis.LexicalAnalyser; +import storage.external_interfaces.StorableAndLoadable; + +public interface CustomLexicalAnalyser extends LexicalAnalyser, StorableAndLoadable {} \ No newline at end of file diff --git a/src/main/java/component_construction/custom_components/CustomSyntaxAnalyser.java b/src/main/java/component_construction/custom_components/CustomSyntaxAnalyser.java new file mode 100644 index 0000000..e02f857 --- /dev/null +++ b/src/main/java/component_construction/custom_components/CustomSyntaxAnalyser.java @@ -0,0 +1,6 @@ +package component_construction.custom_components; + +import syntax_analysis.SyntaxAnalyser; +import storage.external_interfaces.StorableAndLoadable; + +public interface CustomSyntaxAnalyser extends SyntaxAnalyser, StorableAndLoadable {} \ No newline at end of file diff --git a/src/main/java/component_construction/custom_components/StorableCustomCompiler.java b/src/main/java/component_construction/custom_components/StorableCustomCompiler.java new file mode 100644 index 0000000..6ec9993 --- /dev/null +++ b/src/main/java/component_construction/custom_components/StorableCustomCompiler.java @@ -0,0 +1,42 @@ +package component_construction.custom_components; + +import java.util.Map; + +import storage.external_interfaces.StorableAndLoadable; +import storage.storage_values.MapStorageValue; +import storage.storage_values.StorageValue; + +public class StorableCustomCompiler extends CustomCompiler implements StorableAndLoadable { + + public StorableCustomCompiler( + CustomLexicalAnalyser lexicalAnalyser, + CustomSyntaxAnalyser syntaxAnalyser, + CustomCodeGenerator codeGenerator + ) { + super(lexicalAnalyser, syntaxAnalyser, codeGenerator); + } + + + @Override + public MapStorageValue getStorageRepresentation() { + return new MapStorageValue(Map.of( + "lexicalAnalyser", ((CustomLexicalAnalyser)lexicalAnalyser).getStorageRepresentation(), + "syntaxAnalyser", ((CustomSyntaxAnalyser)syntaxAnalyser).getStorageRepresentation(), + "codeGenerator", ((CustomCodeGenerator)codeGenerator).getStorageRepresentation() + )); + } + + @Override + public void load(StorageValue data) { + MapStorageValue map = (MapStorageValue) data; + Map> value = map.getValue(); + + lexicalAnalyser = new CustomLexicalAnalyser(); + syntaxAnalyser = new CustomSyntaxAnalyser(); + codeGenerator = new CustomCodeGenerator(); + + ((CustomLexicalAnalyser)lexicalAnalyser).load(value.get("lexicalAnalyser")); + ((CustomSyntaxAnalyser)syntaxAnalyser).load(value.get("syntaxAnalyser")); + ((CustomCodeGenerator)codeGenerator).load(value.get("codeGenerator")); + } +} diff --git a/src/main/java/component_construction/factories/syntax_analysis/CLR1ParserFactory.java b/src/main/java/component_construction/factories/syntax_analysis/CLR1ParserFactory.java index ca65ce4..ec9a800 100644 --- a/src/main/java/component_construction/factories/syntax_analysis/CLR1ParserFactory.java +++ b/src/main/java/component_construction/factories/syntax_analysis/CLR1ParserFactory.java @@ -2,6 +2,7 @@ import grammar_objects.GrammarParts; import syntax_analysis.*; +import syntax_analysis.parsing.parsers.CLR1Parser; public class CLR1ParserFactory implements SyntaxAnalyserFactory { diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 72b9a28..3bcaa60 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -4,8 +4,10 @@ import java.lang.reflect.ParameterizedType; import java.nio.file.Path; +import helper_objects.TypeReference; import storage.exceptions.*; import storage.file_editors.*; +import storage.external_interfaces.*; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.StorageValue; import storage.value_formatters.*; diff --git a/src/main/java/storage/Loadable.java b/src/main/java/storage/external_interfaces/Loadable.java similarity index 77% rename from src/main/java/storage/Loadable.java rename to src/main/java/storage/external_interfaces/Loadable.java index 493d87e..bdbb850 100644 --- a/src/main/java/storage/Loadable.java +++ b/src/main/java/storage/external_interfaces/Loadable.java @@ -1,4 +1,4 @@ -package storage; +package storage.external_interfaces; import storage.storage_values.StorageValue; diff --git a/src/main/java/storage/Storable.java b/src/main/java/storage/external_interfaces/Storable.java similarity index 78% rename from src/main/java/storage/Storable.java rename to src/main/java/storage/external_interfaces/Storable.java index 083c0bb..a46f089 100644 --- a/src/main/java/storage/Storable.java +++ b/src/main/java/storage/external_interfaces/Storable.java @@ -1,4 +1,4 @@ -package storage; +package storage.external_interfaces; import storage.storage_values.StorageValue; diff --git a/src/main/java/storage/external_interfaces/StorableAndLoadable.java b/src/main/java/storage/external_interfaces/StorableAndLoadable.java new file mode 100644 index 0000000..6747fc1 --- /dev/null +++ b/src/main/java/storage/external_interfaces/StorableAndLoadable.java @@ -0,0 +1,3 @@ +package storage.external_interfaces; + +public interface StorableAndLoadable extends Storable, Loadable {} \ No newline at end of file diff --git a/src/main/java/syntax_analysis/SyntaxAnalyser.java b/src/main/java/syntax_analysis/SyntaxAnalyser.java index 6903cb5..406603f 100644 --- a/src/main/java/syntax_analysis/SyntaxAnalyser.java +++ b/src/main/java/syntax_analysis/SyntaxAnalyser.java @@ -1,47 +1,10 @@ package syntax_analysis; -import java.util.*; - import grammar_objects.*; -import helper_objects.LexElementFinder; import syntax_analysis.parsing.*; -public abstract class SyntaxAnalyser { - - protected final Set tokens; - protected final Set nonTerminals; - protected final NonTerminal sentinel; - protected final Set productionRules; - - protected Map> productionsForNonTerminal; - - public SyntaxAnalyser(Set tokens, Set nonTerminals, Set productionRules, NonTerminal sentinel) { - this.tokens = tokens; - this.nonTerminals = nonTerminals; - this.productionRules = productionRules; - this.sentinel = sentinel; - } - - public SyntaxAnalyser(Token[] tokens, NonTerminal[] nonTerminals, ProductionRule[] productionRules, NonTerminal sentinel) { - this.tokens = Set.of(tokens); - this.nonTerminals = Set.of(nonTerminals); - this.productionRules = Set.of(productionRules); - this.sentinel = sentinel; - } - - public SyntaxAnalyser(Set productionRules, NonTerminal sentinel) { - this.tokens = LexElementFinder.tokens(productionRules); - this.nonTerminals = LexElementFinder.nonTerminals(productionRules); - this.productionRules = productionRules; - this.sentinel = sentinel; - } - - public SyntaxAnalyser(ProductionRule[] productionRules, NonTerminal sentinel) { - this.tokens = LexElementFinder.tokens(productionRules); - this.nonTerminals = LexElementFinder.nonTerminals(productionRules); - this.productionRules = Set.of(productionRules); - this.sentinel = sentinel; - } +public interface SyntaxAnalyser { public abstract ParseState analyse(Token[] inputTokens) throws ParseFailedException; + } \ No newline at end of file diff --git a/src/main/java/syntax_analysis/CLR1Parser.java b/src/main/java/syntax_analysis/parsing/parsers/CLR1Parser.java similarity index 99% rename from src/main/java/syntax_analysis/CLR1Parser.java rename to src/main/java/syntax_analysis/parsing/parsers/CLR1Parser.java index a77454a..571cfa5 100644 --- a/src/main/java/syntax_analysis/CLR1Parser.java +++ b/src/main/java/syntax_analysis/parsing/parsers/CLR1Parser.java @@ -1,4 +1,4 @@ -package syntax_analysis; +package syntax_analysis.parsing.parsers; import java.util.*; diff --git a/src/main/java/syntax_analysis/LR0Parser.java b/src/main/java/syntax_analysis/parsing/parsers/LR0Parser.java similarity index 99% rename from src/main/java/syntax_analysis/LR0Parser.java rename to src/main/java/syntax_analysis/parsing/parsers/LR0Parser.java index c733c66..ecac4d1 100644 --- a/src/main/java/syntax_analysis/LR0Parser.java +++ b/src/main/java/syntax_analysis/parsing/parsers/LR0Parser.java @@ -1,4 +1,4 @@ -package syntax_analysis; +package syntax_analysis.parsing.parsers; import java.util.*; @@ -6,7 +6,7 @@ import syntax_analysis.grammar_structure_creation.*; import syntax_analysis.parsing.*; -public class LR0Parser extends SyntaxAnalyser { +public class LR0Parser extends Parser { protected Map> productionMap; protected Set states; diff --git a/src/main/java/syntax_analysis/parsing/parsers/Parser.java b/src/main/java/syntax_analysis/parsing/parsers/Parser.java new file mode 100644 index 0000000..a546c5e --- /dev/null +++ b/src/main/java/syntax_analysis/parsing/parsers/Parser.java @@ -0,0 +1,48 @@ +package syntax_analysis.parsing.parsers; + +import java.util.*; + +import grammar_objects.*; +import helper_objects.LexElementFinder; +import syntax_analysis.SyntaxAnalyser; +import syntax_analysis.parsing.*; + +public abstract class Parser implements SyntaxAnalyser { + + protected final Set tokens; + protected final Set nonTerminals; + protected final NonTerminal sentinel; + protected final Set productionRules; + + protected Map> productionsForNonTerminal; + + public Parser(Set tokens, Set nonTerminals, Set productionRules, NonTerminal sentinel) { + this.tokens = tokens; + this.nonTerminals = nonTerminals; + this.productionRules = productionRules; + this.sentinel = sentinel; + } + + public Parser(Token[] tokens, NonTerminal[] nonTerminals, ProductionRule[] productionRules, NonTerminal sentinel) { + this.tokens = Set.of(tokens); + this.nonTerminals = Set.of(nonTerminals); + this.productionRules = Set.of(productionRules); + this.sentinel = sentinel; + } + + public Parser(Set productionRules, NonTerminal sentinel) { + this.tokens = LexElementFinder.tokens(productionRules); + this.nonTerminals = LexElementFinder.nonTerminals(productionRules); + this.productionRules = productionRules; + this.sentinel = sentinel; + } + + public Parser(ProductionRule[] productionRules, NonTerminal sentinel) { + this.tokens = LexElementFinder.tokens(productionRules); + this.nonTerminals = LexElementFinder.nonTerminals(productionRules); + this.productionRules = Set.of(productionRules); + this.sentinel = sentinel; + } + + public abstract ParseState analyse(Token[] inputTokens) throws ParseFailedException; +} \ No newline at end of file diff --git a/src/main/java/syntax_analysis/SLR1Parser.java b/src/main/java/syntax_analysis/parsing/parsers/SLR1Parser.java similarity index 99% rename from src/main/java/syntax_analysis/SLR1Parser.java rename to src/main/java/syntax_analysis/parsing/parsers/SLR1Parser.java index cdc1cac..91f92f1 100644 --- a/src/main/java/syntax_analysis/SLR1Parser.java +++ b/src/main/java/syntax_analysis/parsing/parsers/SLR1Parser.java @@ -1,4 +1,4 @@ -package syntax_analysis; +package syntax_analysis.parsing.parsers; import java.util.*; diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 6df81f2..3828768 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -10,6 +10,7 @@ import org.junit.jupiter.api.io.TempDir; import storage.exceptions.*; +import storage.external_interfaces.Storable; import storage.storage_values.*; import storage.value_formatters.*; import test_aids.exceptions.ExampleException; diff --git a/src/test/java/syntax_analysis/CLR1ParserTests.java b/src/test/java/syntax_analysis/CLR1ParserTests.java index 1a5ffcb..1d9f101 100644 --- a/src/test/java/syntax_analysis/CLR1ParserTests.java +++ b/src/test/java/syntax_analysis/CLR1ParserTests.java @@ -7,6 +7,7 @@ import grammar_objects.*; import syntax_analysis.grammar_structure_creation.*; import syntax_analysis.parsing.*; +import syntax_analysis.parsing.parsers.CLR1Parser; import test_aids.*; import test_aids.test_grammars.BasicCLR1TestGrammar; import test_aids.test_grammars.BasicIdentifierTestGrammar; diff --git a/src/test/java/syntax_analysis/LR0ParserTests.java b/src/test/java/syntax_analysis/LR0ParserTests.java index c9504c7..95c067e 100644 --- a/src/test/java/syntax_analysis/LR0ParserTests.java +++ b/src/test/java/syntax_analysis/LR0ParserTests.java @@ -7,6 +7,7 @@ import grammar_objects.*; import syntax_analysis.grammar_structure_creation.*; import syntax_analysis.parsing.*; +import syntax_analysis.parsing.parsers.LR0Parser; import test_aids.*; import test_aids.test_grammars.BasicIdentifierTestGrammar; import test_aids.test_grammars.SelfReferentialTestGrammar; diff --git a/src/test/java/syntax_analysis/SLR1ParserTests.java b/src/test/java/syntax_analysis/SLR1ParserTests.java index 326106f..c89e4b0 100644 --- a/src/test/java/syntax_analysis/SLR1ParserTests.java +++ b/src/test/java/syntax_analysis/SLR1ParserTests.java @@ -7,6 +7,7 @@ import grammar_objects.*; import syntax_analysis.grammar_structure_creation.*; import syntax_analysis.parsing.*; +import syntax_analysis.parsing.parsers.SLR1Parser; import test_aids.*; import test_aids.test_grammars.BasicIdentifierTestGrammar; import test_aids.test_grammars.BasicSLR1TestGrammar; diff --git a/src/test/java/test_aids/test_storage/TestLoadable.java b/src/test/java/test_aids/test_storage/TestLoadable.java index 534b279..9021331 100644 --- a/src/test/java/test_aids/test_storage/TestLoadable.java +++ b/src/test/java/test_aids/test_storage/TestLoadable.java @@ -1,6 +1,6 @@ package test_aids.test_storage; -import storage.Loadable; +import storage.external_interfaces.Loadable; import storage.storage_values.StorageValue; public class TestLoadable implements Loadable { diff --git a/src/test/java/test_aids/test_storage/TestStorable.java b/src/test/java/test_aids/test_storage/TestStorable.java index 479e06e..367b56e 100644 --- a/src/test/java/test_aids/test_storage/TestStorable.java +++ b/src/test/java/test_aids/test_storage/TestStorable.java @@ -1,6 +1,6 @@ package test_aids.test_storage; -import storage.Storable; +import storage.external_interfaces.Storable; public class TestStorable implements Storable { private Object value; From b9e6d66d9a3c3edb70928e154cbbd7198a40c50c Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 16 May 2026 18:03:00 +0100 Subject: [PATCH 078/162] Compiler Storage design --- docs/diagrams/CustomCompilers.drawio.svg | 239 +++++++++++++++-------- 1 file changed, 157 insertions(+), 82 deletions(-) diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg index e04e1cb..32a34db 100644 --- a/docs/diagrams/CustomCompilers.drawio.svg +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -1,4 +1,4 @@ - + @@ -25,22 +25,22 @@ - + - + - + -
+
Contains @@ -48,7 +48,7 @@
- + Contains @@ -147,12 +147,12 @@ - - + + - - + + @@ -162,7 +162,7 @@ -
+
Creates @@ -170,29 +170,29 @@
- + Creates - + - + - + -
+
Uses @@ -200,7 +200,7 @@
- + Uses @@ -306,7 +306,7 @@ -
+
Creates @@ -314,7 +314,7 @@
- + Creates @@ -449,7 +449,7 @@
- + Builder
@@ -471,7 +471,7 @@
- + CustomCompiler
@@ -559,7 +559,7 @@
- + @@ -567,26 +567,29 @@ - + - + - + - - + + + + + -
+
Store @@ -594,7 +597,7 @@
- + Store @@ -604,7 +607,7 @@ -
+
Load @@ -612,20 +615,20 @@
- + Load - + -
+
@@ -635,21 +638,21 @@
- + Storage - - + + -
+
load() @@ -657,7 +660,7 @@
- + load() @@ -667,7 +670,7 @@ -
+
Store() @@ -675,50 +678,72 @@
- + Store() - - + + + + + + - - + + + + + + + +
+
+
+ Query +
+
+
+
+ + Query + +
+
- - + + -
+
- Query and Instantiate + Expects
- - Query and Instantiate + + Expects - + -
+
@@ -728,24 +753,21 @@
- + CustomCompilerStorage - - - - - + + -
+
Store() @@ -753,25 +775,25 @@
- + Store() - - + + - - + + -
+
Instantiate @@ -779,21 +801,21 @@
- + Instantiate - - + + -
+
Repositories @@ -801,20 +823,20 @@
- + Repositories - + -
+
@@ -824,20 +846,20 @@
- + LexicalAnalyserRepository - + -
+
@@ -847,20 +869,24 @@
- + LexicalAnalyserRepository - + + + + + -
+
@@ -870,20 +896,20 @@
- + LexicalAnalyserRepository - + -
+
File @@ -891,12 +917,61 @@
- + File + + + + + + + + + + + + +
+
+
+ Instantiate +
+
+
+
+ + Instantiate + +
+
+
+ + + + + + + +
+
+
+
+ TypedMapStorageValue +
+
+
+
+
+ + TypedMapStorageValue + +
+
+
From 2cf8970b0a5e35c42a26a7899d6a61ff6a0091e2 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 16 May 2026 18:46:55 +0100 Subject: [PATCH 079/162] ListStorageValue Untested --- .../storage_values/ListStorageValue.java | 23 +++++++++++ .../ValueToStringFormatter.java | 41 ++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/main/java/storage/storage_values/ListStorageValue.java diff --git a/src/main/java/storage/storage_values/ListStorageValue.java b/src/main/java/storage/storage_values/ListStorageValue.java new file mode 100644 index 0000000..a9339ca --- /dev/null +++ b/src/main/java/storage/storage_values/ListStorageValue.java @@ -0,0 +1,23 @@ +package storage.storage_values; + +import java.util.List; + +public class ListStorageValue extends StorageValue>> { + + public ListStorageValue(List> list) { + super(list); + } + + @Override + public String toString() { + String msg = "ListStorageValue(["; + + for (StorageValue entry : this.value) { + msg += entry.toString() + ", "; + } + + msg.substring(0, msg.length() - 3); // Remove ending ", " + + return msg + "])"; + } +} diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index eca4ff5..6b48309 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -20,6 +20,7 @@ public class ValueToStringFormatter implements ValueFormatter { public String format(StorageValue value) throws UnsupportedValueException { if (value instanceof StringStorageValue) return formatValue((StringStorageValue)value); if (value instanceof IntegerStorageValue) return formatValue((IntegerStorageValue)value); + if (value instanceof ListStorageValue) return formatValue((ListStorageValue)value); if (value instanceof MapStorageValue) return formatValue((MapStorageValue)value); //TODO: Add more value types and ensure types are differentiable from their stored formats @@ -36,6 +37,7 @@ public String format(StorageValue value) throws UnsupportedValueException { public StorageValue parse(String formattedData) throws UnsupportedValueException { if (formattedData.startsWith("\"")) return parseStringFormat(formattedData); if (formattedData.matches("[0-9]+.*")) return parseIntegerFormat(formattedData); + if (formattedData.startsWith("[")) return parseListFormat(formattedData); if (formattedData.startsWith("{")) return parseMapFormat(formattedData); //TODO: Add more value types @@ -65,7 +67,44 @@ private String formatValue(IntegerStorageValue value) { private IntegerStorageValue parseIntegerFormat(String formattedData) { return new IntegerStorageValue(Integer.parseInt(formattedData)); } - + + private String formatValue(ListStorageValue value) { + String out = ""; + List> entries = value.getValue(); + + if (entries.isEmpty()) return "[]"; + + for (StorageValue entry : entries) { + out += format(entry) + ",\n"; + } + + out = out.substring(0, out.length() - 2); //Remove trailing ",\n" + + return "[\n" + indent(out) + "\n]"; + } + + private ListStorageValue parseListFormat(String formattedData) { + if (!formattedData.endsWith("]")) throw new RuntimeException("The list " + formattedData + " must end with ]"); + if (formattedData.matches("\\[" + ANY_WHITESPACE + "\\]")) return new ListStorageValue(List.of()); + + formattedData = formattedData.substring(1, formattedData.length() - 1); + formattedData = formattedData.strip(); + + List> list = new LinkedList<>(); + + Matcher entryMatcher = Pattern.compile( + "(?\\{.*\\}|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", + Pattern.DOTALL | Pattern.MULTILINE + ) + .matcher(formattedData); + + while (entryMatcher.find()) { + list.add(parse(entryMatcher.group("value"))); + } + + return new ListStorageValue(list); + } + private String formatValue(MapStorageValue value) { String out = ""; Set>> mapEntries = value.getValue().entrySet(); From 2219306da8e7596a7c84535e9ab0713ef5d5e68f Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 16 May 2026 18:50:08 +0100 Subject: [PATCH 080/162] Small ValueToStringFormatter rearrange --- .../value_formatters/ValueToStringFormatter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index 6b48309..4e9294e 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -18,10 +18,10 @@ public class ValueToStringFormatter implements ValueFormatter { @Override public String format(StorageValue value) throws UnsupportedValueException { - if (value instanceof StringStorageValue) return formatValue((StringStorageValue)value); - if (value instanceof IntegerStorageValue) return formatValue((IntegerStorageValue)value); if (value instanceof ListStorageValue) return formatValue((ListStorageValue)value); if (value instanceof MapStorageValue) return formatValue((MapStorageValue)value); + if (value instanceof StringStorageValue) return formatValue((StringStorageValue)value); + if (value instanceof IntegerStorageValue) return formatValue((IntegerStorageValue)value); //TODO: Add more value types and ensure types are differentiable from their stored formats throw new UnsupportedValueException(value); @@ -35,11 +35,11 @@ public String format(StorageValue value) throws UnsupportedValueException { */ @Override public StorageValue parse(String formattedData) throws UnsupportedValueException { - if (formattedData.startsWith("\"")) return parseStringFormat(formattedData); - if (formattedData.matches("[0-9]+.*")) return parseIntegerFormat(formattedData); if (formattedData.startsWith("[")) return parseListFormat(formattedData); if (formattedData.startsWith("{")) return parseMapFormat(formattedData); - + if (formattedData.startsWith("\"")) return parseStringFormat(formattedData); + if (formattedData.matches("[0-9]+.*")) return parseIntegerFormat(formattedData); + //TODO: Add more value types throw new UnsupportedValueException(); } From 322714fe759edc8fad027ae65c4fcd0386e1cb03 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 16 May 2026 18:58:24 +0100 Subject: [PATCH 081/162] Small cleanup, TODO and diagram change --- docs/diagrams/CustomCompilers.drawio.svg | 183 +++++++----------- .../builders/CompilerBuilder.java | 7 +- .../CustomCompilerFactory.java | 4 +- .../ValueToStringFormatterTests.java | 2 + 4 files changed, 73 insertions(+), 123 deletions(-) diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg index 32a34db..4d65c0c 100644 --- a/docs/diagrams/CustomCompilers.drawio.svg +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -1,4 +1,4 @@ - + @@ -25,16 +25,16 @@ - - + + - - + + - - + + @@ -48,7 +48,7 @@
- + Contains
@@ -147,12 +147,12 @@
- - + + - - + + @@ -162,7 +162,7 @@ -
+
Creates @@ -170,29 +170,29 @@
- + Creates - - + + - - + + - - + + -
+
Uses @@ -200,7 +200,7 @@
- + Uses @@ -306,7 +306,7 @@ -
+
Creates @@ -314,7 +314,7 @@
- + Creates @@ -396,7 +396,7 @@ -
+
Creates @@ -404,7 +404,7 @@
- + Creates @@ -441,7 +441,7 @@ -
+
Builder @@ -559,37 +559,37 @@ - - + + - + - + - + - - + + -
+
Store @@ -597,7 +597,7 @@
- + Store @@ -607,7 +607,7 @@ -
+
Load @@ -615,20 +615,20 @@
- + Load - + -
+
@@ -638,21 +638,21 @@
- + Storage - - + + -
+
load() @@ -660,7 +660,7 @@
- + load() @@ -670,7 +670,7 @@ -
+
Store() @@ -678,23 +678,23 @@
- + Store() - - + + - - + + - - + + @@ -714,28 +714,6 @@ - - - - - - - - -
-
-
- Expects -
-
-
-
- - Expects - -
-
-
@@ -760,14 +738,14 @@ - - + + -
+
Store() @@ -786,14 +764,14 @@ - - + + -
+
Instantiate @@ -801,7 +779,7 @@
- + Instantiate @@ -823,7 +801,7 @@
- + Repositories
@@ -876,7 +854,7 @@
- + @@ -903,13 +881,13 @@ - + -
+
File @@ -917,25 +895,25 @@
- + File - + - + -
+
Instantiate @@ -943,35 +921,12 @@
- + Instantiate - - - - - - - -
-
-
-
- TypedMapStorageValue -
-
-
-
-
- - TypedMapStorageValue - -
-
-
diff --git a/src/main/java/component_construction/builders/CompilerBuilder.java b/src/main/java/component_construction/builders/CompilerBuilder.java index bab8451..3cf79b5 100644 --- a/src/main/java/component_construction/builders/CompilerBuilder.java +++ b/src/main/java/component_construction/builders/CompilerBuilder.java @@ -8,12 +8,7 @@ import code_generation.CodeGenerator; import component_construction.ParameterError; import component_construction.bundles.GrammarBundle; -import component_construction.custom_components.CustomCodeGenerator; -import component_construction.custom_components.CustomCompiler; -import component_construction.custom_components.CustomCompilerFactory; -import component_construction.custom_components.CustomLexicalAnalyser; -import component_construction.custom_components.CustomSyntaxAnalyser; -import component_construction.custom_components.StorableCustomCompiler; +import component_construction.custom_components.*; import component_construction.factories.code_generation.CodeGeneratorFactory; import component_construction.factories.lexical_analysis.LexicalAnalyserFactory; import component_construction.factories.syntax_analysis.SyntaxAnalyserFactory; diff --git a/src/main/java/component_construction/custom_components/CustomCompilerFactory.java b/src/main/java/component_construction/custom_components/CustomCompilerFactory.java index dd221c3..50f1ae0 100644 --- a/src/main/java/component_construction/custom_components/CustomCompilerFactory.java +++ b/src/main/java/component_construction/custom_components/CustomCompilerFactory.java @@ -5,10 +5,8 @@ import component_construction.factories.lexical_analysis.LexicalAnalyserFactory; import component_construction.factories.syntax_analysis.SyntaxAnalyserFactory; import grammar_objects.Grammar; -import grammar_objects.GrammarParts; import grammar_objects.RuleConvertor; -import lexical_analysis.DynamicTokenRegex; -import lexical_analysis.LexicalAnalyser; +import lexical_analysis.*; import syntax_analysis.SyntaxAnalyser; public class CustomCompilerFactory { diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index d069035..0e1b5b5 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -221,4 +221,6 @@ public void formatNestedMap() { .contains(actualValue) ); } + + // TODO: List tests } From 1ae45d629e9e2cfb5c3cb14b64767b6a9d1dea23 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 17 May 2026 22:52:44 +0100 Subject: [PATCH 082/162] Custom storage redesign --- docs/diagrams/CustomCompilers.drawio.svg | 323 ++++++++++++++--------- 1 file changed, 203 insertions(+), 120 deletions(-) diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg index 4d65c0c..eb557e1 100644 --- a/docs/diagrams/CustomCompilers.drawio.svg +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -1,4 +1,4 @@ - + @@ -25,16 +25,16 @@ - - + + - - + + - - + + @@ -147,12 +147,12 @@ - - + + - - + + @@ -162,7 +162,7 @@ -
+
Creates @@ -170,29 +170,29 @@
- + Creates - - + + - - + + - - + + -
+
Uses @@ -200,7 +200,7 @@
- + Uses @@ -351,7 +351,7 @@ -
+
Creates @@ -359,7 +359,7 @@
- + Creates @@ -441,7 +441,7 @@ -
+
Builder @@ -463,7 +463,7 @@ -
+
CustomCompiler @@ -559,37 +559,34 @@ - - + + - + - + - + - - - - - + + -
+
Store @@ -597,7 +594,7 @@
- + Store @@ -607,7 +604,7 @@ -
+
Load @@ -615,20 +612,20 @@
- + Load - + -
+
@@ -638,21 +635,21 @@
- + Storage - - + + -
+
load() @@ -660,7 +657,7 @@
- + load() @@ -670,37 +667,37 @@ -
+
- Store() + store()
- - Store() + + store() - - + + - - + + - - + + -
+
Query @@ -708,92 +705,66 @@
- + Query - + + -
-
-
-
- CustomCompilerStorage -
-
-
-
-
- - CustomCompilerStorage - -
-
-
- - - - - - - - -
+
- Store() + uses
- - Store() + + uses - - - - - - + -
-
-
- Instantiate +
+
+
+
+ CustomCompilerStorage +
- - Instantiate + + CustomCompilerStorage - - + + -
+
Repositories @@ -801,20 +772,20 @@
- + Repositories - + -
+
@@ -824,20 +795,20 @@
- + LexicalAnalyserRepository - + -
+
@@ -847,24 +818,24 @@
- + LexicalAnalyserRepository - + - + -
+
@@ -874,20 +845,20 @@
- + LexicalAnalyserRepository - + -
+
File @@ -895,25 +866,25 @@
- + File - + - + -
+
Instantiate @@ -921,12 +892,124 @@
- + Instantiate + + + + + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+
+ + + + + + + +
+
+
+
+ StorableCustomCompiler +
+
+
+
+
+ + StorableCustomCompiler + +
+
+
+ + + + + + + + +
+
+
+ Creates +
+
+
+
+ + Creates + +
+
+
+ + + + + + + +
+
+
+
+ StorableCustomCompilerBuilder +
+
+
+
+
+ + StorableCustomCompilerBuilder + +
+
+
+ + + + + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+
From b05f632081aac1d2f9a3cc15e5727b6a0679abda Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 6 Jun 2026 00:48:58 +0100 Subject: [PATCH 083/162] An assortment of unfinished experimentations --- docs/diagrams/CustomCompilers.drawio.svg | 316 +++++++----------- ...lder.java => CompilerBuilderTemplate.java} | 108 ++---- .../builders/CustomCompilerBuilder.java | 29 ++ .../StorableCustomCompiler.java | 42 --- .../storage/CompilerStorage.java | 21 ++ .../storage/Factories/Factory.java | 7 + .../StorableCustomCompilerFactory.java | 59 ++++ .../storage/LoadableBy.java | 5 + .../storage/ReflectiveFactoryRepository.java | 74 ++++ .../storage/StorableBy.java | 5 + .../storage/StorableCustomCompiler.java | 36 ++ .../StorableCustomCompilerBuilder.java | 42 +++ .../storage_values/ListStorageValue.java | 6 +- .../component_construction/CompilerTests.java | 7 +- .../builders/CompilerBuilderTests.java | 16 +- 15 files changed, 448 insertions(+), 325 deletions(-) rename src/main/java/component_construction/builders/{CompilerBuilder.java => CompilerBuilderTemplate.java} (58%) create mode 100644 src/main/java/component_construction/builders/CustomCompilerBuilder.java delete mode 100644 src/main/java/component_construction/custom_components/StorableCustomCompiler.java create mode 100644 src/main/java/component_construction/storage/CompilerStorage.java create mode 100644 src/main/java/component_construction/storage/Factories/Factory.java create mode 100644 src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java create mode 100644 src/main/java/component_construction/storage/LoadableBy.java create mode 100644 src/main/java/component_construction/storage/ReflectiveFactoryRepository.java create mode 100644 src/main/java/component_construction/storage/StorableBy.java create mode 100644 src/main/java/component_construction/storage/StorableCustomCompiler.java create mode 100644 src/main/java/component_construction/storage/StorableCustomCompilerBuilder.java diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg index eb557e1..96ccbdd 100644 --- a/docs/diagrams/CustomCompilers.drawio.svg +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -1,4 +1,4 @@ - + @@ -40,7 +40,7 @@ -
+
Contains @@ -162,7 +162,7 @@ -
+
Creates @@ -170,7 +170,7 @@
- + Creates @@ -192,7 +192,7 @@ -
+
Uses @@ -200,7 +200,7 @@
- + Uses @@ -306,7 +306,7 @@ -
+
Creates @@ -314,7 +314,7 @@
- + Creates @@ -351,7 +351,7 @@ -
+
Creates @@ -359,7 +359,7 @@
- + Creates @@ -396,7 +396,7 @@ -
+
Creates @@ -404,7 +404,7 @@
- + Creates @@ -463,7 +463,7 @@ -
+
CustomCompiler @@ -579,86 +579,67 @@ - - + + -
+
- Store -
-
-
- - - Store - - - - - - - - -
-
-
- Load + Extends
- - Load + + Extends
- + + -
-
-
-
- Storage -
+
+
+
+ Extends
- - Storage + + Extends - - + + -
+
- load() + Store
- - load() + + Store @@ -667,198 +648,158 @@ -
+
- store() + Load
- - store() + + Load - - - - - - - - - - + -
-
-
- Query +
+
+
+
+ Storage +
- - Query + + Storage - - + + -
+
- uses -
-
-
- - - uses - - - - - - - - - - - -
-
-
-
- CustomCompilerStorage -
+ load()
- - CustomCompilerStorage + + load()
- - - - -
-
-
- Repositories +
+
+
+ store()
- - Repositories + + store() - + + -
-
-
-
- LexicalAnalyserRepository -
+
+
+
+ Query
- - LexicalAnalyserRepository + + Query - + + -
-
-
-
- LexicalAnalyserRepository -
+
+
+
+ uses
- - LexicalAnalyserRepository + + uses - - - - - + -
-
+
+
- LexicalAnalyserRepository + CustomCompilerStorage
- - LexicalAnalyserRepository + + CustomCompilerStorage - + -
+
File @@ -866,146 +807,121 @@
- + File - - - - - - + -
-
-
- Instantiate +
+
+
+
+ StorableCustomCompiler +
- - Instantiate + + StorableCustomCompiler - - + + -
+
- Extends + Creates
- - Extends + + Creates - + -
-
+
+
- StorableCustomCompiler + StorableCustomCompilerBuilder
- - StorableCustomCompiler + + StorableCustomCompilerBuilder - - + + -
+
- Creates + Instantiate
- - Creates + + Instantiate - + -
-
+
+
- StorableCustomCompilerBuilder + ReflectiveFactoryRepository
- - StorableCustomCompilerBuilder - - - - - - - - - - - - -
-
-
- Extends -
-
-
-
- - Extends + + ReflectiveFactoryRepository
diff --git a/src/main/java/component_construction/builders/CompilerBuilder.java b/src/main/java/component_construction/builders/CompilerBuilderTemplate.java similarity index 58% rename from src/main/java/component_construction/builders/CompilerBuilder.java rename to src/main/java/component_construction/builders/CompilerBuilderTemplate.java index 3cf79b5..49c5208 100644 --- a/src/main/java/component_construction/builders/CompilerBuilder.java +++ b/src/main/java/component_construction/builders/CompilerBuilderTemplate.java @@ -4,8 +4,6 @@ import grammar_objects.*; import lexical_analysis.*; -import syntax_analysis.SyntaxAnalyser; -import code_generation.CodeGenerator; import component_construction.ParameterError; import component_construction.bundles.GrammarBundle; import component_construction.custom_components.*; @@ -13,7 +11,12 @@ import component_construction.factories.lexical_analysis.LexicalAnalyserFactory; import component_construction.factories.syntax_analysis.SyntaxAnalyserFactory; -public class CompilerBuilder { +/** + * An template for builders of CustomCompilers + * @param The type of the current implementing subclass of this template + * @param The type of CustomCompiler that will be built by the implemented builder + */ +public abstract class CompilerBuilderTemplate , C extends CustomCompiler> { protected LexicalAnalyserFactory lexicalAnalyserFactory; protected SyntaxAnalyserFactory syntaxAnalyserFactory; protected CodeGeneratorFactory codeGeneratorFactory; @@ -33,7 +36,7 @@ public class CompilerBuilder { * @param codeGeneratorFactory * @param grammarBundle */ - public CompilerBuilder setComponents( + public B setComponents( LexicalAnalyserFactory lexicalAnalyserFactory, SyntaxAnalyserFactory syntaxAnalyserFactory, CodeGeneratorFactory codeGeneratorFactory, @@ -64,7 +67,7 @@ public CompilerBuilder setComponents( * @param weaklyReservedWords May be null * @param dynamicTokenRegex May be null */ - public CompilerBuilder setComponents( + public B setComponents( LexicalAnalyserFactory lexicalAnalyserFactory, SyntaxAnalyserFactory syntaxAnalyserFactory, CodeGeneratorFactory codeGeneratorFactory, @@ -85,105 +88,68 @@ public CompilerBuilder setComponents( setWeaklyReservedWords(weaklyReservedWords); setDynamicTokenRegex(dynamicTokenRegex); - return this; + return getThis(); } - public CompilerBuilder setLexicalAnalyser(LexicalAnalyserFactory factory) { + public B setLexicalAnalyser(LexicalAnalyserFactory factory) { this.lexicalAnalyserFactory = factory; - return this; + return getThis(); } - public CompilerBuilder setSyntaxAnalyser(SyntaxAnalyserFactory factory) { + public B setSyntaxAnalyser(SyntaxAnalyserFactory factory) { this.syntaxAnalyserFactory = factory; - return this; + return getThis(); } - public CompilerBuilder setCodeGenerator(CodeGeneratorFactory factory) { + public B setCodeGenerator(CodeGeneratorFactory factory) { this.codeGeneratorFactory = factory; - return this; + return getThis(); } - public CompilerBuilder setGrammar(Grammar grammar) { + public B setGrammar(Grammar grammar) { this.grammar = grammar; - return this; + return getThis(); } - public CompilerBuilder setRuleConvertor(RuleConvertor ruleConvertor) { + public B setRuleConvertor(RuleConvertor ruleConvertor) { this.ruleConvertor = ruleConvertor; - return this; + return getThis(); } - public CompilerBuilder setWhitespaceDelimiters(String[] whitespaceDelimiters) { + public B setWhitespaceDelimiters(String[] whitespaceDelimiters) { this.whitespaceDelimiters = whitespaceDelimiters; - return this; + return getThis(); } - public CompilerBuilder setStronglyReservedWords(String[] stronglyReservedWords) { + public B setStronglyReservedWords(String[] stronglyReservedWords) { this.stronglyReservedWords = stronglyReservedWords; - return this; + return getThis(); } - public CompilerBuilder setWeaklyReservedWords(String[] weaklyReservedWords) { + public B setWeaklyReservedWords(String[] weaklyReservedWords) { this.weaklyReservedWords = weaklyReservedWords; - return this; + return getThis(); } - public CompilerBuilder setDynamicTokenRegex(DynamicTokenRegex[] dynamicTokenRegex) { + public B setDynamicTokenRegex(DynamicTokenRegex[] dynamicTokenRegex) { this.dynamicTokenRegex = dynamicTokenRegex; - return this; + return getThis(); } + + public abstract C createCompiler(); - public CustomCompiler createCompiler() { - checkForCompleteBuild(); - - return new CustomCompilerFactory().produce( - lexicalAnalyserFactory, - syntaxAnalyserFactory, - codeGeneratorFactory, - grammar, - whitespaceDelimiters, - stronglyReservedWords, - weaklyReservedWords, - dynamicTokenRegex, - ruleConvertor - ); - } - - public StorableCustomCompiler createStorableCompiler() { - checkForCompleteBuild(); - - if(whitespaceDelimiters == null) whitespaceDelimiters = new String[]{}; - if(stronglyReservedWords == null) stronglyReservedWords = new String[]{}; - if(weaklyReservedWords == null) weaklyReservedWords = new String[]{}; - if(dynamicTokenRegex == null) dynamicTokenRegex = new DynamicTokenRegex[]{}; - - GrammarParts parts = grammar.getParts(); - - LexicalAnalyser lexicalAnalyser = lexicalAnalyserFactory.produceAnalyser( - whitespaceDelimiters, - stronglyReservedWords, - weaklyReservedWords, - dynamicTokenRegex - ); - SyntaxAnalyser syntaxAnalyser = syntaxAnalyserFactory.produceAnalyser(parts); - CodeGenerator codeGenerator = codeGeneratorFactory.produceGenerator(ruleConvertor); - - if(!(lexicalAnalyser instanceof CustomLexicalAnalyser)) throw new RuntimeException("TODO"); //TODO - if(!(syntaxAnalyser instanceof CustomSyntaxAnalyser)) throw new RuntimeException("TODO"); //TODO - if(!(codeGenerator instanceof CustomCodeGenerator)) throw new RuntimeException("TODO"); //TODO - return new StorableCustomCompiler( - (CustomLexicalAnalyser)lexicalAnalyser, - (CustomSyntaxAnalyser)syntaxAnalyser, - (CustomCodeGenerator)codeGenerator - ); - } + /** + * A simple helper method to be filled with "return this;" by subclasses of this builder + * @return The current builder object "this" + */ + protected abstract B getThis(); - private void checkForCompleteBuild() { + protected void checkForCompleteBuild() { List msgParts = new ArrayList<>(); if(lexicalAnalyserFactory == null) msgParts.add("lexical analyser factory"); @@ -191,9 +157,9 @@ private void checkForCompleteBuild() { if(codeGeneratorFactory == null) msgParts.add("code generator factory"); if(grammar == null) msgParts.add("grammar"); if(ruleConvertor == null) msgParts.add("rule convertor"); - //Note: Allowing null lexical components + // Note: Allowing null lexical components - if(msgParts.size() == 0) return; //No error + if(msgParts.size() == 0) return; // No error if(msgParts.size() == 1) throw new ParameterError(msgParts.get(0) + " not provided"); String msg = msgParts.get(0); diff --git a/src/main/java/component_construction/builders/CustomCompilerBuilder.java b/src/main/java/component_construction/builders/CustomCompilerBuilder.java new file mode 100644 index 0000000..f843b54 --- /dev/null +++ b/src/main/java/component_construction/builders/CustomCompilerBuilder.java @@ -0,0 +1,29 @@ +package component_construction.builders; + +import component_construction.custom_components.*; + +public class CustomCompilerBuilder extends CompilerBuilderTemplate { + + @Override + protected CustomCompilerBuilder getThis() { + return this; + } + + @Override + public CustomCompiler createCompiler() { + checkForCompleteBuild(); + + return new CustomCompilerFactory().produce( + lexicalAnalyserFactory, + syntaxAnalyserFactory, + codeGeneratorFactory, + grammar, + whitespaceDelimiters, + stronglyReservedWords, + weaklyReservedWords, + dynamicTokenRegex, + ruleConvertor + ); + } + +} diff --git a/src/main/java/component_construction/custom_components/StorableCustomCompiler.java b/src/main/java/component_construction/custom_components/StorableCustomCompiler.java deleted file mode 100644 index 6ec9993..0000000 --- a/src/main/java/component_construction/custom_components/StorableCustomCompiler.java +++ /dev/null @@ -1,42 +0,0 @@ -package component_construction.custom_components; - -import java.util.Map; - -import storage.external_interfaces.StorableAndLoadable; -import storage.storage_values.MapStorageValue; -import storage.storage_values.StorageValue; - -public class StorableCustomCompiler extends CustomCompiler implements StorableAndLoadable { - - public StorableCustomCompiler( - CustomLexicalAnalyser lexicalAnalyser, - CustomSyntaxAnalyser syntaxAnalyser, - CustomCodeGenerator codeGenerator - ) { - super(lexicalAnalyser, syntaxAnalyser, codeGenerator); - } - - - @Override - public MapStorageValue getStorageRepresentation() { - return new MapStorageValue(Map.of( - "lexicalAnalyser", ((CustomLexicalAnalyser)lexicalAnalyser).getStorageRepresentation(), - "syntaxAnalyser", ((CustomSyntaxAnalyser)syntaxAnalyser).getStorageRepresentation(), - "codeGenerator", ((CustomCodeGenerator)codeGenerator).getStorageRepresentation() - )); - } - - @Override - public void load(StorageValue data) { - MapStorageValue map = (MapStorageValue) data; - Map> value = map.getValue(); - - lexicalAnalyser = new CustomLexicalAnalyser(); - syntaxAnalyser = new CustomSyntaxAnalyser(); - codeGenerator = new CustomCodeGenerator(); - - ((CustomLexicalAnalyser)lexicalAnalyser).load(value.get("lexicalAnalyser")); - ((CustomSyntaxAnalyser)syntaxAnalyser).load(value.get("syntaxAnalyser")); - ((CustomCodeGenerator)codeGenerator).load(value.get("codeGenerator")); - } -} diff --git a/src/main/java/component_construction/storage/CompilerStorage.java b/src/main/java/component_construction/storage/CompilerStorage.java new file mode 100644 index 0000000..ae20cb7 --- /dev/null +++ b/src/main/java/component_construction/storage/CompilerStorage.java @@ -0,0 +1,21 @@ +package component_construction.storage; + +import component_construction.storage.Factories.StorableCustomCompilerFactory; +import storage.Storage; +import storage.storage_values.StorageValue; + +public class CompilerStorage { + private Storage storage = new Storage(); + private StorableCustomCompilerFactory storableCustomCompilerFactory = new StorableCustomCompilerFactory(); + + public void store(StorableCustomCompiler compiler) { + //TODO: Store using Storable or StorableBy<> if defined + storage.store(compiler); + } + + public StorableCustomCompiler load() { + //TODO: Store using Loadable or LoadableBy<> if defined + StorageValue storageValue = storage.load(); + return storableCustomCompilerFactory.produce(storageValue); + } +} \ No newline at end of file diff --git a/src/main/java/component_construction/storage/Factories/Factory.java b/src/main/java/component_construction/storage/Factories/Factory.java new file mode 100644 index 0000000..710f489 --- /dev/null +++ b/src/main/java/component_construction/storage/Factories/Factory.java @@ -0,0 +1,7 @@ +package component_construction.storage.Factories; + +import storage.storage_values.StorageValue; + +public interface Factory { + public T produce(StorageValue loadValue); +} \ No newline at end of file diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java new file mode 100644 index 0000000..b540b1b --- /dev/null +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -0,0 +1,59 @@ +package component_construction.storage.Factories; + +import java.util.Map; +import component_construction.storage.*; +import storage.storage_values.*; +import component_construction.custom_components.*; + +public class StorableCustomCompilerFactory implements Factory { + ReflectiveFactoryRepository lexicalAnalyserFactoryRepository = new ReflectiveFactoryRepository<>(); + ReflectiveFactoryRepository syntaxAnalyserFactoryRepository = new ReflectiveFactoryRepository<>(); + ReflectiveFactoryRepository codeGeneratorFactoryRepository = new ReflectiveFactoryRepository<>(); + + @Override + public StorableCustomCompiler produce(StorageValue loadValue) { + MapStorageValue map = (MapStorageValue) loadValue; + Map> mapValue = map.getValue(); + + CustomLexicalAnalyser customLexicalAnalyser; + CustomSyntaxAnalyser customSyntaxAnalyser; + CustomCodeGenerator customCodeGenerator; + + try { + customLexicalAnalyser = lexicalAnalyserFactoryRepository.instantiate( + "lexicalAnalyser", + mapValue.get("lexicalAnalyser") + ); + } + catch (ClassNotFoundException e) { + throw new RuntimeException(e); // TODO: Create custom exception + } + + try { + customSyntaxAnalyser = syntaxAnalyserFactoryRepository.instantiate( + "syntaxAnalyser", + mapValue.get("syntaxAnalyser") + ); + } + catch (ClassNotFoundException e) { + throw new RuntimeException(e); // TODO: Create custom exception + } + + try { + customCodeGenerator = codeGeneratorFactoryRepository.instantiate( + "codeGenerator", + mapValue.get("codeGenerator") + ); + } + catch (ClassNotFoundException e) { + throw new RuntimeException(e); // TODO: Create custom exception + } + + return new StorableCustomCompiler( + customLexicalAnalyser, + customSyntaxAnalyser, + customCodeGenerator + ); + } + +} diff --git a/src/main/java/component_construction/storage/LoadableBy.java b/src/main/java/component_construction/storage/LoadableBy.java new file mode 100644 index 0000000..0fe9534 --- /dev/null +++ b/src/main/java/component_construction/storage/LoadableBy.java @@ -0,0 +1,5 @@ +package component_construction.storage; + +import component_construction.storage.Factories.Factory; + +public interface LoadableBy> {} diff --git a/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java b/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java new file mode 100644 index 0000000..70eccef --- /dev/null +++ b/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java @@ -0,0 +1,74 @@ +package component_construction.storage; + +import java.lang.reflect.InvocationTargetException; +import java.util.*; + +import component_construction.storage.Factories.Factory; +import helper_objects.TypeReference; +import storage.storage_values.StorageValue; + +public class ReflectiveFactoryRepository { + protected Map> factories = new HashMap<>(); + + /** + * + * @param name + * @param generator + * @return This object for method chaining + */ + public ReflectiveFactoryRepository addFactory(String name, Factory generator) { + factories.put(name, generator); + return this; + } + + public T instantiate(String name, StorageValue loadValue) throws ClassNotFoundException { + if (!factories.containsKey(name)) { + // Assume name is the name of a class with type T + return createInstanceOf(name, loadValue); + } + + return factories + .get(name) + .produce(loadValue); + } + + /** + * + * @param + * @param className Must include the package definition e.g "com.example.ExampleClass" + * @param state + * @return + * @throws Exception + */ + private T createInstanceOf(String className, StorageValue state) throws ClassNotFoundException { + Class clazz; + + try { + clazz = Class.forName(className); + } + catch (ClassNotFoundException e) { + throw e; //TODO: More descriptive exception + } + + Class expectedClass = TypeReference.instantiate().getContainedClass(); + + //TODO: Call default constructor for loading (Must be made as a standard if not registering a factory) + try { + return clazz + .asSubclass(expectedClass) + .getDeclaredConstructor(state.getClass()) + .newInstance(state); + } + catch ( + InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException + | NoSuchMethodException + | SecurityException + e + ) { + throw new RuntimeException(e); //TODO: Combine into more descriptive/useful exception + } + } +} diff --git a/src/main/java/component_construction/storage/StorableBy.java b/src/main/java/component_construction/storage/StorableBy.java new file mode 100644 index 0000000..5d6e42d --- /dev/null +++ b/src/main/java/component_construction/storage/StorableBy.java @@ -0,0 +1,5 @@ +package component_construction.storage; + +import storage.external_interfaces.Storable; + +public interface StorableBy {} \ No newline at end of file diff --git a/src/main/java/component_construction/storage/StorableCustomCompiler.java b/src/main/java/component_construction/storage/StorableCustomCompiler.java new file mode 100644 index 0000000..e98f86c --- /dev/null +++ b/src/main/java/component_construction/storage/StorableCustomCompiler.java @@ -0,0 +1,36 @@ +package component_construction.storage; + +import java.util.Map; +import component_construction.custom_components.*; +import component_construction.storage.Factories.StorableCustomCompilerFactory; +import storage.external_interfaces.Storable; +import storage.storage_values.*; + +public class StorableCustomCompiler extends CustomCompiler implements Storable, LoadableBy { + + public StorableCustomCompiler( + CustomLexicalAnalyser lexicalAnalyser, + CustomSyntaxAnalyser syntaxAnalyser, + CustomCodeGenerator codeGenerator + ) { + super(lexicalAnalyser, syntaxAnalyser, codeGenerator); + } + + @Override + public MapStorageValue getStorageRepresentation() { + return new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue(lexicalAnalyser.getClass().getSimpleName()), + ((CustomLexicalAnalyser)lexicalAnalyser).getStorageRepresentation() + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxAnalyser.getClass().getSimpleName()), + ((CustomSyntaxAnalyser)syntaxAnalyser).getStorageRepresentation() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGenerator.getClass().getSimpleName()), + ((CustomCodeGenerator)codeGenerator).getStorageRepresentation() + ) + )); + } +} diff --git a/src/main/java/component_construction/storage/StorableCustomCompilerBuilder.java b/src/main/java/component_construction/storage/StorableCustomCompilerBuilder.java new file mode 100644 index 0000000..0806c5a --- /dev/null +++ b/src/main/java/component_construction/storage/StorableCustomCompilerBuilder.java @@ -0,0 +1,42 @@ +package component_construction.storage; + +import code_generation.CodeGenerator; +import component_construction.builders.CompilerBuilderTemplate; +import component_construction.custom_components.*; +import grammar_objects.GrammarParts; +import lexical_analysis.LexicalAnalyser; +import syntax_analysis.SyntaxAnalyser; + +public class StorableCustomCompilerBuilder extends CompilerBuilderTemplate { + + @Override + protected StorableCustomCompilerBuilder getThis() { + return this; + } + + @Override + public StorableCustomCompiler createCompiler() { + checkForCompleteBuild(); + + GrammarParts parts = grammar.getParts(); + + LexicalAnalyser lexicalAnalyser = lexicalAnalyserFactory.produceAnalyser( + whitespaceDelimiters, + stronglyReservedWords, + weaklyReservedWords, + dynamicTokenRegex + ); + SyntaxAnalyser syntaxAnalyser = syntaxAnalyserFactory.produceAnalyser(parts); + CodeGenerator codeGenerator = codeGeneratorFactory.produceGenerator(ruleConvertor); + + if(!(lexicalAnalyser instanceof CustomLexicalAnalyser)) throw new RuntimeException("TODO"); //TODO + if(!(syntaxAnalyser instanceof CustomSyntaxAnalyser)) throw new RuntimeException("TODO"); //TODO + if(!(codeGenerator instanceof CustomCodeGenerator)) throw new RuntimeException("TODO"); //TODO + + return new StorableCustomCompiler( + (CustomLexicalAnalyser)lexicalAnalyser, + (CustomSyntaxAnalyser)syntaxAnalyser, + (CustomCodeGenerator)codeGenerator + ); + } +} diff --git a/src/main/java/storage/storage_values/ListStorageValue.java b/src/main/java/storage/storage_values/ListStorageValue.java index a9339ca..555ea7e 100644 --- a/src/main/java/storage/storage_values/ListStorageValue.java +++ b/src/main/java/storage/storage_values/ListStorageValue.java @@ -1,6 +1,6 @@ package storage.storage_values; -import java.util.List; +import java.util.*; public class ListStorageValue extends StorageValue>> { @@ -8,6 +8,10 @@ public ListStorageValue(List> list) { super(list); } + public ListStorageValue(StorageValue ...list) { + super(List.of(list)); + } + @Override public String toString() { String msg = "ListStorageValue(["; diff --git a/src/test/java/component_construction/CompilerTests.java b/src/test/java/component_construction/CompilerTests.java index 8f3f7c7..1574cac 100644 --- a/src/test/java/component_construction/CompilerTests.java +++ b/src/test/java/component_construction/CompilerTests.java @@ -1,9 +1,10 @@ package component_construction; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import component_construction.builders.CompilerBuilder; +import component_construction.builders.CompilerBuilderTemplate; +import component_construction.builders.CustomCompilerBuilder; import component_construction.factories.code_generation.BasicCodeGenFactory; import component_construction.factories.lexical_analysis.GeneralLexicalAnalyserFactory; import component_construction.factories.syntax_analysis.CLR1ParserFactory; @@ -18,7 +19,7 @@ public class CompilerTests { @Test public void basicIdentifierCompiler() throws ParseFailedException { - CompilerBuilder builder = new CompilerBuilder(); + CustomCompilerBuilder builder = new CustomCompilerBuilder(); builder.setComponents( new GeneralLexicalAnalyserFactory(), diff --git a/src/test/java/component_construction/builders/CompilerBuilderTests.java b/src/test/java/component_construction/builders/CompilerBuilderTests.java index f5c0bb7..09c3e51 100644 --- a/src/test/java/component_construction/builders/CompilerBuilderTests.java +++ b/src/test/java/component_construction/builders/CompilerBuilderTests.java @@ -1,6 +1,6 @@ package component_construction.builders; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import component_construction.ParameterError; @@ -15,7 +15,7 @@ public class CompilerBuilderTests { @Test public void basicCompilerBuilder() { - CompilerBuilder builder = new CompilerBuilder(); + CustomCompilerBuilder builder = new CustomCompilerBuilder(); builder.setComponents( new GeneralLexicalAnalyserFactory(), new CLR1ParserFactory(), @@ -37,11 +37,11 @@ public void basicCompilerBuilder() { @Test public void nullComponentInputs() { - CompilerBuilder builder1 = new CompilerBuilder(); - CompilerBuilder builder2 = new CompilerBuilder(); - CompilerBuilder builder3 = new CompilerBuilder(); - CompilerBuilder builder4 = new CompilerBuilder(); - CompilerBuilder builder5 = new CompilerBuilder(); + CustomCompilerBuilder builder1 = new CustomCompilerBuilder(); + CustomCompilerBuilder builder2 = new CustomCompilerBuilder(); + CustomCompilerBuilder builder3 = new CustomCompilerBuilder(); + CustomCompilerBuilder builder4 = new CustomCompilerBuilder(); + CustomCompilerBuilder builder5 = new CustomCompilerBuilder(); builder1.setComponents( null, @@ -124,7 +124,7 @@ public void nullComponentInputs() { @Test public void nullLexicalInputs() { - CompilerBuilder builder = new CompilerBuilder(); + CustomCompilerBuilder builder = new CustomCompilerBuilder(); builder.setComponents( new GeneralLexicalAnalyserFactory(), new CLR1ParserFactory(), From 108045025f7b84842540822696b6f0c411a39a40 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 11 Jun 2026 00:16:34 +0100 Subject: [PATCH 084/162] Adding list parsing and formatting tests for ValueToStringFormatter --- .../ValueToStringFormatterTests.java | 288 +++++++++++++++++- 1 file changed, 282 insertions(+), 6 deletions(-) diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index 0e1b5b5..dd6b3b6 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -1,12 +1,10 @@ package storage.value_formatters; import static org.junit.jupiter.api.Assertions.*; -import java.util.List; -import java.util.Map; +import java.util.*; import org.junit.jupiter.api.Test; -import helper_objects.NotEmptyTuple; -import helper_objects.Tuple; +import helper_objects.*; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.*; @@ -14,6 +12,8 @@ public class ValueToStringFormatterTests { //NOTE: No exceptions for incorrectly formatted data were made. This will be left to more sophisticated ValueFormatters + //#region parsing + @Test public void parseFormattedString() { String str = "Java"; @@ -105,7 +105,81 @@ public void parseNestedMap() { assertEquals(expectedValue, actualValue1); } - //TODO: Fomatting of StorageValues + @Test + public void parseFormattedEmptyList() { + String formattedString1 = "[]"; + String formattedString2 = "[\n]"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + StorageValue actualValue2 = valueFormatter.parse(formattedString2); + + ListStorageValue expectedValue = new ListStorageValue(List.of()); + assertEquals(expectedValue, actualValue1); + assertEquals(expectedValue, actualValue2); + } + + @Test + public void parseFormattedSimpleList() { + String testString1 = "testString1"; + String testString2 = "testString2"; + Integer testInt = 30; + String formattedString1 = "[\n" + + " \"" + testString1 + "\",\n" + + " \"" + testString2 + "\",\n" + + " " + testInt + "\n" + + "]"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + + ListStorageValue expectedValue = new ListStorageValue(List.of( + new StringStorageValue(testString1), + new StringStorageValue(testString2), + new IntegerStorageValue(testInt) + )); + assertEquals(expectedValue, actualValue1); + } + + @Test + public void parseFormattedNestedList() { + String testString1 = "testString1"; + String testString2 = "testString2"; + Integer testInt = 30; + String formattedString1 = "[\n" + + " [\n" + + " \"" + testString1 + "\",\n" + + " \"" + testString2 + "\"\n" + + " ],\n" + + " " + testInt + "\n" + + "]"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + + ListStorageValue expectedValue = new ListStorageValue(List.of( + new ListStorageValue(List.of( + new StringStorageValue(testString1), + new StringStorageValue(testString2) + )), + new IntegerStorageValue(testInt) + )); + assertEquals(expectedValue, actualValue1); + } + + @Test + public void parseFormattedNestedMapAndList() { + // TODO + } + + @Test + public void parseFormattedNestedListAndMap() { + // TODO + } + + //#endregion + + //#region formatting @Test public void formatString() { @@ -222,5 +296,207 @@ public void formatNestedMap() { ); } - // TODO: List tests + @Test + public void formatEmptyList() { + MapStorageValue mapValue = new MapStorageValue(Map.of()); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + String expectedValue = "{}"; + assertEquals(expectedValue, actualValue); + // TODO + } + + @Test + public void formatSimpleList() { + Tuple testString = new NotEmptyTuple<>("testStringKey", "testString"); + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( + Map.entry(testString.value1(), new StringStorageValue(testString.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + )); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + assertTrue(List.of( + "{\n" + + " \"" + testString.value1() + "\":\"" + testString.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + "}", + + "{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString.value1() + "\":\"" + testString.value2() + "\"\n" + + "}" + ) + .contains(actualValue) + ); + // TODO + } + + @Test + public void formatNestedList() { + Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); + Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( + Map.entry("innerMap", new MapStorageValue(Map.ofEntries( + Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + ))), + Map.entry(testString2.value1(), new StringStorageValue(testString2.value2())) + )); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + assertTrue(List.of( + "{\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}", + + "{\n" + + " \"innerMap\":{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}", + + "{\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " }\n" + + "}", + + "{\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + + " \"innerMap\":{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + + " }\n" + + "}" + ) + .contains(actualValue) + ); + // TODO + } + + @Test + public void formatNestedMapAndList() { + Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); + Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( + Map.entry("innerMap", new MapStorageValue(Map.ofEntries( + Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + ))), + Map.entry(testString2.value1(), new StringStorageValue(testString2.value2())) + )); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + assertTrue(List.of( + "{\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}", + + "{\n" + + " \"innerMap\":{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}", + + "{\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " }\n" + + "}", + + "{\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + + " \"innerMap\":{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + + " }\n" + + "}" + ) + .contains(actualValue) + ); + // TODO + } + + @Test + public void formatNestedListAndMap() { + Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); + Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( + Map.entry("innerMap", new MapStorageValue(Map.ofEntries( + Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + ))), + Map.entry(testString2.value1(), new StringStorageValue(testString2.value2())) + )); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + assertTrue(List.of( + "{\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}", + + "{\n" + + " \"innerMap\":{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + + " },\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + + "}", + + "{\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + + " \"innerMap\":{\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " }\n" + + "}", + + "{\n" + + " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + + " \"innerMap\":{\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + + " }\n" + + "}" + ) + .contains(actualValue) + ); + // TODO + } + + //#endregion } From 80e34edc8d470879eb293805c5cfdda81ad452c4 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 11 Jun 2026 23:58:08 +0100 Subject: [PATCH 085/162] Parse tests for lists within ValueToStringFormatter --- .../ValueToStringFormatterTests.java | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index dd6b3b6..9879e6d 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -169,12 +169,59 @@ public void parseFormattedNestedList() { @Test public void parseFormattedNestedMapAndList() { - // TODO + Tuple> testList = new NotEmptyTuple<>( + "testStringKey1", + List.of( + "testString2", + "testString3" + ) + ); + Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); + String formattedString1 = "{\n" + + " \"" + testList.value1() + "\":[\n" + + " \"" + testList.value2().get(0) + "\",\n" + + " \"" + testList.value2().get(1)+ "\",\n" + + " ],\n" + + " \"" + testInt.value1() + "\":\"" + testInt.value2() + "\"\n" + + "}"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + + MapStorageValue expectedValue = new MapStorageValue(Map.ofEntries( + Map.entry(testList.value1(), new ListStorageValue(List.of( + new StringStorageValue(testList.value2().get(0)), + new StringStorageValue(testList.value2().get(1)) + ))), + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + )); + assertEquals(expectedValue, actualValue1); } @Test public void parseFormattedNestedListAndMap() { - // TODO + Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); + Tuple testInt1 = new NotEmptyTuple<>("testStringKey2", 50); + Integer testInt2 = 30; + String formattedString1 = "[\n" + + " {\n" + + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + + " \"" + testInt1.value1() + "\":" + testInt1.value2() + "\n" + + " },\n" + + " " + testInt2 + "\n" + + "]"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString1); + + ListStorageValue expectedValue = new ListStorageValue(List.of( + new MapStorageValue(Map.ofEntries( + Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), + Map.entry(testInt1.value1(), new IntegerStorageValue(testInt1.value2())) + )), + new IntegerStorageValue(testInt2) + )); + assertEquals(expectedValue, actualValue1); } //#endregion From 60eccbd4ce1ba11ee4b6d790f9a48cf82731d3cf Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 12 Jun 2026 00:22:02 +0100 Subject: [PATCH 086/162] Format tests for ValueToStringFormatter --- .../ValueToStringFormatterTests.java | 210 ++++++------------ 1 file changed, 73 insertions(+), 137 deletions(-) diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index 9879e6d..4762ae3 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -345,109 +345,79 @@ public void formatNestedMap() { @Test public void formatEmptyList() { - MapStorageValue mapValue = new MapStorageValue(Map.of()); + ListStorageValue mapValue = new ListStorageValue(List.of()); ValueFormatter valueFormatter = new ValueToStringFormatter(); String actualValue = valueFormatter.format(mapValue); - String expectedValue = "{}"; + String expectedValue = "[]"; assertEquals(expectedValue, actualValue); - // TODO } @Test public void formatSimpleList() { - Tuple testString = new NotEmptyTuple<>("testStringKey", "testString"); - Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); - MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( - Map.entry(testString.value1(), new StringStorageValue(testString.value2())), - Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + String testString1 = "testString1"; + String testString2 = "testString2"; + Integer testInt = 30; + ListStorageValue listValue = new ListStorageValue(List.of( + new StringStorageValue(testString1), + new StringStorageValue(testString2), + new IntegerStorageValue(testInt) )); ValueFormatter valueFormatter = new ValueToStringFormatter(); - String actualValue = valueFormatter.format(mapValue); + String actualValue = valueFormatter.format(listValue); - assertTrue(List.of( - "{\n" + - " \"" + testString.value1() + "\":\"" + testString.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + - "}", - - "{\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + - " \"" + testString.value1() + "\":\"" + testString.value2() + "\"\n" + - "}" - ) - .contains(actualValue) - ); - // TODO + String expectedValue = "[\n" + + " \"" + testString1 + "\",\n" + + " \"" + testString2 + "\",\n" + + " " + testInt + "\n" + + "]"; + assertEquals(expectedValue, actualValue); } @Test public void formatNestedList() { - Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); - Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); - Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); - MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( - Map.entry("innerMap", new MapStorageValue(Map.ofEntries( - Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), - Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) - ))), - Map.entry(testString2.value1(), new StringStorageValue(testString2.value2())) + String testString1 = "testString1"; + String testString2 = "testString2"; + Integer testInt = 30; + ListStorageValue listValue = new ListStorageValue(List.of( + new ListStorageValue(List.of( + new StringStorageValue(testString1), + new StringStorageValue(testString2) + )), + new IntegerStorageValue(testInt) )); ValueFormatter valueFormatter = new ValueToStringFormatter(); - String actualValue = valueFormatter.format(mapValue); - - assertTrue(List.of( - "{\n" + - " \"innerMap\":{\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + - " },\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + - "}", - - "{\n" + - " \"innerMap\":{\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + - " },\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + - "}", - - "{\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + - " \"innerMap\":{\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + - " }\n" + - "}", + String actualValue = valueFormatter.format(listValue); - "{\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + - " \"innerMap\":{\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + - " }\n" + - "}" - ) - .contains(actualValue) - ); - // TODO + String expectedValue = "[\n" + + " [\n" + + " \"" + testString1 + "\",\n" + + " \"" + testString2 + "\"\n" + + " ],\n" + + " " + testInt + "\n" + + "]"; + assertEquals(expectedValue, actualValue); } @Test public void formatNestedMapAndList() { - Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); - Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); + Tuple> testList = new NotEmptyTuple<>( + "testStringKey1", + List.of( + "testString2", + "testString3" + ) + ); Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( - Map.entry("innerMap", new MapStorageValue(Map.ofEntries( - Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), - Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) + Map.entry(testList.value1(), new ListStorageValue(List.of( + new StringStorageValue(testList.value2().get(0)), + new StringStorageValue(testList.value2().get(1)) ))), - Map.entry(testString2.value1(), new StringStorageValue(testString2.value2())) + Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) )); ValueFormatter valueFormatter = new ValueToStringFormatter(); @@ -455,94 +425,60 @@ public void formatNestedMapAndList() { assertTrue(List.of( "{\n" + - " \"innerMap\":{\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + - " },\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + - "}", - - "{\n" + - " \"innerMap\":{\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + - " },\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + - "}", - - "{\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + - " \"innerMap\":{\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + - " }\n" + + " \"" + testList.value1() + "\":[\n" + + " \"" + testList.value2().get(0) + "\",\n" + + " \"" + testList.value2().get(1)+ "\",\n" + + " ],\n" + + " \"" + testInt.value1() + "\":\"" + testInt.value2() + "\"\n" + "}", "{\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + - " \"innerMap\":{\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + - " }\n" + + " \"" + testInt.value1() + "\":\"" + testInt.value2() + "\",\n" + + " \"" + testList.value1() + "\":[\n" + + " \"" + testList.value2().get(0) + "\",\n" + + " \"" + testList.value2().get(1)+ "\",\n" + + " ]\n" + "}" ) .contains(actualValue) ); - // TODO } @Test public void formatNestedListAndMap() { Tuple testString1 = new NotEmptyTuple<>("testStringKey1", "testString1"); - Tuple testString2 = new NotEmptyTuple<>("testStringKey2", "testString2"); - Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); - MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( - Map.entry("innerMap", new MapStorageValue(Map.ofEntries( + Tuple testInt1 = new NotEmptyTuple<>("testStringKey2", 50); + Integer testInt2 = 30; + ListStorageValue listValue = new ListStorageValue(List.of( + new MapStorageValue(Map.ofEntries( Map.entry(testString1.value1(), new StringStorageValue(testString1.value2())), - Map.entry(testInt.value1(), new IntegerStorageValue(testInt.value2())) - ))), - Map.entry(testString2.value1(), new StringStorageValue(testString2.value2())) + Map.entry(testInt1.value1(), new IntegerStorageValue(testInt1.value2())) + )), + new IntegerStorageValue(testInt2) )); ValueFormatter valueFormatter = new ValueToStringFormatter(); - String actualValue = valueFormatter.format(mapValue); + String actualValue = valueFormatter.format(listValue); assertTrue(List.of( - "{\n" + - " \"innerMap\":{\n" + + "[\n" + + " {\n" + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + + " \"" + testInt1.value1() + "\":" + testInt1.value2() + "\n" + " },\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + - "}", + " " + testInt2 + "\n" + + "]", - "{\n" + - " \"innerMap\":{\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + + "[\n" + + " {\n" + + " \"" + testInt1.value1() + "\":" + testInt1.value2() + ",\n" + " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + " },\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\"\n" + - "}", - - "{\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + - " \"innerMap\":{\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\",\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + - " }\n" + - "}", - - "{\n" + - " \"" + testString2.value1() + "\":\"" + testString2.value2() + "\",\n" + - " \"innerMap\":{\n" + - " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + - " \"" + testString1.value1() + "\":\"" + testString1.value2() + "\"\n" + - " }\n" + - "}" + " " + testInt2 + "\n" + + "]" ) .contains(actualValue) ); - // TODO } //#endregion From 62b93aa138c184b8e554cb531be6950fa0855adb Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 13 Jun 2026 00:51:17 +0100 Subject: [PATCH 087/162] Passing list parsing and formatting ValueToStringformatter tests --- .../ValueToStringFormatter.java | 4 +-- .../ValueToStringFormatterTests.java | 26 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index 4e9294e..7099b1c 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -93,7 +93,7 @@ private ListStorageValue parseListFormat(String formattedData) { List> list = new LinkedList<>(); Matcher entryMatcher = Pattern.compile( - "(?\\{.*\\}|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", + "(?\\{.*\\}|\\[.*\\]|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", Pattern.DOTALL | Pattern.MULTILINE ) .matcher(formattedData); @@ -130,7 +130,7 @@ private MapStorageValue parseMapFormat(String formattedData) { Map> map = new HashMap<>(); Matcher entryMatcher = Pattern.compile( - "\\\"(?[a-zA-Z0-9_\\-]*?)\\\"" + ANY_WHITESPACE + ":" + ANY_WHITESPACE + "(?\\{.*\\}|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", + "\\\"(?[a-zA-Z0-9_\\-]*?)\\\"" + ANY_WHITESPACE + ":" + ANY_WHITESPACE + "(?\\{.*\\}|\\[.*\\]|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", Pattern.DOTALL | Pattern.MULTILINE ) .matcher(formattedData); diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index 4762ae3..14d19ba 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -170,10 +170,10 @@ public void parseFormattedNestedList() { @Test public void parseFormattedNestedMapAndList() { Tuple> testList = new NotEmptyTuple<>( - "testStringKey1", + "testListKey1", List.of( - "testString2", - "testString3" + "testString1", + "testString2" ) ); Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); @@ -182,7 +182,7 @@ public void parseFormattedNestedMapAndList() { " \"" + testList.value2().get(0) + "\",\n" + " \"" + testList.value2().get(1)+ "\",\n" + " ],\n" + - " \"" + testInt.value1() + "\":\"" + testInt.value2() + "\"\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + "}"; ValueFormatter valueFormatter = new ValueToStringFormatter(); @@ -394,8 +394,8 @@ public void formatNestedList() { String expectedValue = "[\n" + " [\n" + - " \"" + testString1 + "\",\n" + - " \"" + testString2 + "\"\n" + + " \"" + testString1 + "\",\n" + + " \"" + testString2 + "\"\n" + " ],\n" + " " + testInt + "\n" + "]"; @@ -405,10 +405,10 @@ public void formatNestedList() { @Test public void formatNestedMapAndList() { Tuple> testList = new NotEmptyTuple<>( - "testStringKey1", + "testListKey", List.of( - "testString2", - "testString3" + "testString1", + "testString2" ) ); Tuple testInt = new NotEmptyTuple<>("testIntKey", 30); @@ -427,16 +427,16 @@ public void formatNestedMapAndList() { "{\n" + " \"" + testList.value1() + "\":[\n" + " \"" + testList.value2().get(0) + "\",\n" + - " \"" + testList.value2().get(1)+ "\",\n" + + " \"" + testList.value2().get(1)+ "\"\n" + " ],\n" + - " \"" + testInt.value1() + "\":\"" + testInt.value2() + "\"\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + "\n" + "}", "{\n" + - " \"" + testInt.value1() + "\":\"" + testInt.value2() + "\",\n" + + " \"" + testInt.value1() + "\":" + testInt.value2() + ",\n" + " \"" + testList.value1() + "\":[\n" + " \"" + testList.value2().get(0) + "\",\n" + - " \"" + testList.value2().get(1)+ "\",\n" + + " \"" + testList.value2().get(1)+ "\"\n" + " ]\n" + "}" ) From 6a854d5472174089005c453d408630720d79e455 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 14 Jun 2026 01:22:31 +0100 Subject: [PATCH 088/162] ValueToStringFormatter more complex parse and format including tests --- .../ValueToStringFormatter.java | 69 +++--- .../ValueToStringFormatterTests.java | 233 ++++++++++++++++++ 2 files changed, 271 insertions(+), 31 deletions(-) diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index 7099b1c..36e7294 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -84,22 +84,14 @@ private String formatValue(ListStorageValue value) { } private ListStorageValue parseListFormat(String formattedData) { - if (!formattedData.endsWith("]")) throw new RuntimeException("The list " + formattedData + " must end with ]"); - if (formattedData.matches("\\[" + ANY_WHITESPACE + "\\]")) return new ListStorageValue(List.of()); - - formattedData = formattedData.substring(1, formattedData.length() - 1); - formattedData = formattedData.strip(); - - List> list = new LinkedList<>(); - - Matcher entryMatcher = Pattern.compile( - "(?\\{.*\\}|\\[.*\\]|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", - Pattern.DOTALL | Pattern.MULTILINE - ) - .matcher(formattedData); - - while (entryMatcher.find()) { - list.add(parse(entryMatcher.group("value"))); + formattedData = formattedData.substring(1, formattedData.length() - 1).trim(); + List> list = new ArrayList<>(); + int i = 0; + + while (i < formattedData.length()) { + int endOfValue = findNextElementBoundary(formattedData, i); + list.add(parse(formattedData.substring(i, endOfValue).trim())); + i = endOfValue + 1; // Skip the comma } return new ListStorageValue(list); @@ -124,27 +116,42 @@ private MapStorageValue parseMapFormat(String formattedData) { if (!formattedData.endsWith("}")) throw new RuntimeException("The map " + formattedData + " must end with }"); if (formattedData.matches("\\{" + ANY_WHITESPACE + "\\}")) return new MapStorageValue(Map.of()); - formattedData = formattedData.substring(1, formattedData.length() - 1); - formattedData = formattedData.strip(); - + formattedData = formattedData.substring(1, formattedData.length() - 1).trim(); Map> map = new HashMap<>(); - - Matcher entryMatcher = Pattern.compile( - "\\\"(?[a-zA-Z0-9_\\-]*?)\\\"" + ANY_WHITESPACE + ":" + ANY_WHITESPACE + "(?\\{.*\\}|\\[.*\\]|\\\".*?[^\\\\]\\\"|[0-9]+)(?=" + ANY_WHITESPACE + "(?:,|$))", - Pattern.DOTALL | Pattern.MULTILINE - ) - .matcher(formattedData); - - while (entryMatcher.find()) { - map.put( - entryMatcher.group("key"), - parse(entryMatcher.group("value")) - ); + int i = 0; + + while (i < formattedData.length()) { + int colonIndex = formattedData.indexOf(':', i); + String key = formattedData.substring(i, colonIndex).trim().replace("\"", ""); + + int startOfValue = colonIndex + 1; + int endOfValue = findNextElementBoundary(formattedData, startOfValue); + + map.put(key, parse(formattedData.substring(startOfValue, endOfValue).trim())); + i = endOfValue + 1; // Skip the comma } return new MapStorageValue(map); } + private int findNextElementBoundary(String formattedData, int start) { + int depth = 0; + boolean inQuotes = false; + + for (int i = start; i < formattedData.length(); i++) { + char c = formattedData.charAt(i); + + if (c == '"' && (i == 0 || formattedData.charAt(i - 1) != '\\')) inQuotes = !inQuotes; + if (inQuotes) continue; + + if (c == '{' || c == '[') depth++; + else if (c == '}' || c == ']') depth--; + else if (c == ',' && depth == 0) return i; + } + + return formattedData.length(); + } + private String indent(String string) { return INDENT + string.replace("\n", "\n" + INDENT); } diff --git a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java index 14d19ba..2aabfc3 100644 --- a/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java +++ b/src/test/java/storage/value_formatters/ValueToStringFormatterTests.java @@ -224,6 +224,61 @@ public void parseFormattedNestedListAndMap() { assertEquals(expectedValue, actualValue1); } + @Test + public void parseFormattedComplexObjectCombination() { + String formattedString = "{\n" + + " \"key1\":[" + + " \"string1\"," + + " [" + + " 0," + + " \"string2\"" + + " ]" + + " ]," + + " \"key2\":[" + + " \"string3\"," + + " [" + + " 1," + + " \"string4\"" + + " ]" + + " ]," + + " \"key3\":[" + + " \"string5\"," + + " [" + + " 0," + + " \"\"" + + " ]" + + " ]" + + "}"; + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + StorageValue actualValue1 = valueFormatter.parse(formattedString); + + MapStorageValue expectedValue = new MapStorageValue(Map.ofEntries( + Map.entry("key1", new ListStorageValue(List.of( + new StringStorageValue("string1"), + new ListStorageValue(List.of( + new IntegerStorageValue(0), + new StringStorageValue("string2") + )) + ))), + Map.entry("key2", new ListStorageValue(List.of( + new StringStorageValue("string3"), + new ListStorageValue(List.of( + new IntegerStorageValue(1), + new StringStorageValue("string4") + )) + ))), + Map.entry("key3", new ListStorageValue(List.of( + new StringStorageValue("string5"), + new ListStorageValue(List.of( + new IntegerStorageValue(0), + new StringStorageValue("") + )) + ))) + )); + assertEquals(expectedValue, actualValue1); + } + //#endregion //#region formatting @@ -481,5 +536,183 @@ public void formatNestedListAndMap() { ); } + @Test + public void formatComplexObjectCombination() { + MapStorageValue mapValue = new MapStorageValue(Map.ofEntries( + Map.entry("key1", new ListStorageValue(List.of( + new StringStorageValue("string1"), + new ListStorageValue(List.of( + new IntegerStorageValue(0), + new StringStorageValue("string2") + )) + ))), + Map.entry("key2", new ListStorageValue(List.of( + new StringStorageValue("string3"), + new ListStorageValue(List.of( + new IntegerStorageValue(1), + new StringStorageValue("string4") + )) + ))), + Map.entry("key3", new ListStorageValue(List.of( + new StringStorageValue("string5"), + new ListStorageValue(List.of( + new IntegerStorageValue(0), + new StringStorageValue("") + )) + ))) + )); + ValueFormatter valueFormatter = new ValueToStringFormatter(); + + String actualValue = valueFormatter.format(mapValue); + + assertTrue(List.of( + "{\n" + + " \"key1\":[\n" + + " \"string1\",\n" + + " [\n" + + " 0,\n" + + " \"string2\"\n" + + " ]\n" + + " ],\n" + + " \"key2\":[\n" + + " \"string3\",\n" + + " [\n" + + " 1,\n" + + " \"string4\"\n" + + " ]\n" + + " ],\n" + + " \"key3\":[\n" + + " \"string5\",\n" + + " [\n" + + " 0,\n" + + " \"\"\n" + + " ]\n" + + " ]\n" + + "}", + + "{\n" + + " \"key2\":[\n" + + " \"string3\",\n" + + " [\n" + + " 1,\n" + + " \"string4\"\n" + + " ]\n" + + " ],\n" + + " \"key1\":[\n" + + " \"string1\",\n" + + " [\n" + + " 0,\n" + + " \"string2\"\n" + + " ]\n" + + " ],\n" + + " \"key3\":[\n" + + " \"string5\",\n" + + " [\n" + + " 0,\n" + + " \"\"\n" + + " ]\n" + + " ]\n" + + "}", + + "{\n" + + " \"key3\":[\n" + + " \"string5\",\n" + + " [\n" + + " 0,\n" + + " \"\"\n" + + " ]\n" + + " ],\n" + + " \"key1\":[\n" + + " \"string1\",\n" + + " [\n" + + " 0,\n" + + " \"string2\"\n" + + " ]\n" + + " ],\n" + + " \"key2\":[\n" + + " \"string3\",\n" + + " [\n" + + " 1,\n" + + " \"string4\"\n" + + " ]\n" + + " ]\n" + + "}", + + "{\n" + + " \"key1\":[\n" + + " \"string1\",\n" + + " [\n" + + " 0,\n" + + " \"string2\"\n" + + " ]\n" + + " ],\n" + + " \"key3\":[\n" + + " \"string5\",\n" + + " [\n" + + " 0,\n" + + " \"\"\n" + + " ]\n" + + " ],\n" + + " \"key2\":[\n" + + " \"string3\",\n" + + " [\n" + + " 1,\n" + + " \"string4\"\n" + + " ]\n" + + " ]\n" + + "}", + + "{\n" + + " \"key2\":[\n" + + " \"string3\",\n" + + " [\n" + + " 1,\n" + + " \"string4\"\n" + + " ]\n" + + " ],\n" + + " \"key3\":[\n" + + " \"string5\",\n" + + " [\n" + + " 0,\n" + + " \"\"\n" + + " ]\n" + + " ],\n" + + " \"key1\":[\n" + + " \"string1\",\n" + + " [\n" + + " 0,\n" + + " \"string2\"\n" + + " ]\n" + + " ]\n" + + "}", + + "{\n" + + " \"key3\":[\n" + + " \"string5\",\n" + + " [\n" + + " 0,\n" + + " \"\"\n" + + " ]\n" + + " ],\n" + + " \"key2\":[\n" + + " \"string3\",\n" + + " [\n" + + " 1,\n" + + " \"string4\"\n" + + " ]\n" + + " ],\n" + + " \"key1\":[\n" + + " \"string1\",\n" + + " [\n" + + " 0,\n" + + " \"string2\"\n" + + " ]\n" + + " ]\n" + + "}" + ) + .contains(actualValue) + ); + } + //#endregion } From e7cfd6d3d97b136399f93aeab1d748bb62b1eec3 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 17 Jun 2026 23:34:47 +0100 Subject: [PATCH 089/162] Storing and loading of custom components Basic and specific, without testing --- .../storage/CompilerStorage.java | 2 +- .../StorableCustomCompilerFactory.java | 39 ++++++++++++++----- .../storage/ReflectiveFactoryRepository.java | 25 ++++++++---- .../storage/StorableCustomCompiler.java | 6 +-- .../ValueToStringFormatter.java | 1 - 5 files changed, 51 insertions(+), 22 deletions(-) diff --git a/src/main/java/component_construction/storage/CompilerStorage.java b/src/main/java/component_construction/storage/CompilerStorage.java index ae20cb7..b46ea0b 100644 --- a/src/main/java/component_construction/storage/CompilerStorage.java +++ b/src/main/java/component_construction/storage/CompilerStorage.java @@ -14,7 +14,7 @@ public void store(StorableCustomCompiler compiler) { } public StorableCustomCompiler load() { - //TODO: Store using Loadable or LoadableBy<> if defined + //TODO: Load using Loadable or LoadableBy<> if defined StorageValue storageValue = storage.load(); return storableCustomCompilerFactory.produce(storageValue); } diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index b540b1b..8363deb 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -1,16 +1,18 @@ package component_construction.storage.Factories; -import java.util.Map; +import java.util.*; + import component_construction.storage.*; import storage.storage_values.*; import component_construction.custom_components.*; public class StorableCustomCompilerFactory implements Factory { - ReflectiveFactoryRepository lexicalAnalyserFactoryRepository = new ReflectiveFactoryRepository<>(); - ReflectiveFactoryRepository syntaxAnalyserFactoryRepository = new ReflectiveFactoryRepository<>(); - ReflectiveFactoryRepository codeGeneratorFactoryRepository = new ReflectiveFactoryRepository<>(); + ReflectiveFactoryRepository lexicalAnalyserFactoryRepository = new ReflectiveFactoryRepository<>(CustomLexicalAnalyser.class); + ReflectiveFactoryRepository syntaxAnalyserFactoryRepository = new ReflectiveFactoryRepository<>(CustomSyntaxAnalyser.class);; + ReflectiveFactoryRepository codeGeneratorFactoryRepository = new ReflectiveFactoryRepository<>(CustomCodeGenerator.class);; @Override + // TODO: Explain requirements for storage/loading public StorableCustomCompiler produce(StorageValue loadValue) { MapStorageValue map = (MapStorageValue) loadValue; Map> mapValue = map.getValue(); @@ -20,9 +22,11 @@ public StorableCustomCompiler produce(StorageValue loadValue) { CustomCodeGenerator customCodeGenerator; try { + ComponentDescription lexicalAnalyserDescription = getComponentDescription(mapValue.get("lexicalAnalyser")); + customLexicalAnalyser = lexicalAnalyserFactoryRepository.instantiate( - "lexicalAnalyser", - mapValue.get("lexicalAnalyser") + lexicalAnalyserDescription.name, + lexicalAnalyserDescription.description ); } catch (ClassNotFoundException e) { @@ -30,9 +34,11 @@ public StorableCustomCompiler produce(StorageValue loadValue) { } try { + ComponentDescription syntaxAnalyserDescription = getComponentDescription(mapValue.get("syntaxAnalyser")); + customSyntaxAnalyser = syntaxAnalyserFactoryRepository.instantiate( - "syntaxAnalyser", - mapValue.get("syntaxAnalyser") + syntaxAnalyserDescription.name, + syntaxAnalyserDescription.description ); } catch (ClassNotFoundException e) { @@ -40,9 +46,11 @@ public StorableCustomCompiler produce(StorageValue loadValue) { } try { + ComponentDescription codeGeneratorDescription = getComponentDescription(mapValue.get("syntaxAnalyser")); + customCodeGenerator = codeGeneratorFactoryRepository.instantiate( - "codeGenerator", - mapValue.get("codeGenerator") + codeGeneratorDescription.name, + codeGeneratorDescription.description ); } catch (ClassNotFoundException e) { @@ -55,5 +63,16 @@ public StorableCustomCompiler produce(StorageValue loadValue) { customCodeGenerator ); } + + // TODO: Handle errors + private ComponentDescription getComponentDescription(StorageValue description) { + List> entry = ((ListStorageValue)description).getValue(); + + return new ComponentDescription( + ((StringStorageValue)entry.get(0)).getValue(), + (ListStorageValue)entry.get(1) + ); + } + private record ComponentDescription(String name, ListStorageValue description) {} } diff --git a/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java b/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java index 70eccef..e1607d3 100644 --- a/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java +++ b/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java @@ -4,11 +4,15 @@ import java.util.*; import component_construction.storage.Factories.Factory; -import helper_objects.TypeReference; import storage.storage_values.StorageValue; public class ReflectiveFactoryRepository { protected Map> factories = new HashMap<>(); + protected Class innerType; + + public ReflectiveFactoryRepository(Class innerType) { + this.innerType = innerType; + } /** * @@ -21,6 +25,16 @@ public ReflectiveFactoryRepository addFactory(String name, Factory generat return this; } + /** + * Instantiates the named entity using the given value. + *

+ * If no factory exists for the named entity, the name will be treated as a class name as expected by {@code Class.forName(...)}. + * The named class must include a constructor of the form {@code public NamedClass(StorageValue state) { ... }} in order to be instantiated. + * @param name The entity name + * @param loadValue The StorageValue to be loaded into the specified entity + * @return The constructed entity + * @throws ClassNotFoundException + */ public T instantiate(String name, StorageValue loadValue) throws ClassNotFoundException { if (!factories.containsKey(name)) { // Assume name is the name of a class with type T @@ -50,13 +64,10 @@ private T createInstanceOf(String className, StorageValue state) throws Class throw e; //TODO: More descriptive exception } - Class expectedClass = TypeReference.instantiate().getContainedClass(); - - //TODO: Call default constructor for loading (Must be made as a standard if not registering a factory) try { return clazz - .asSubclass(expectedClass) - .getDeclaredConstructor(state.getClass()) + .asSubclass(innerType) + .getDeclaredConstructor(StorageValue.class) .newInstance(state); } catch ( @@ -68,7 +79,7 @@ private T createInstanceOf(String className, StorageValue state) throws Class | SecurityException e ) { - throw new RuntimeException(e); //TODO: Combine into more descriptive/useful exception + throw new RuntimeException(e); //TODO: Combine into more descriptive/useful exception per fail case } } } diff --git a/src/main/java/component_construction/storage/StorableCustomCompiler.java b/src/main/java/component_construction/storage/StorableCustomCompiler.java index e98f86c..3ba568c 100644 --- a/src/main/java/component_construction/storage/StorableCustomCompiler.java +++ b/src/main/java/component_construction/storage/StorableCustomCompiler.java @@ -20,15 +20,15 @@ public StorableCustomCompiler( public MapStorageValue getStorageRepresentation() { return new MapStorageValue(Map.of( "lexicalAnalyser", new ListStorageValue( - new StringStorageValue(lexicalAnalyser.getClass().getSimpleName()), + new StringStorageValue(lexicalAnalyser.getClass().getName()), ((CustomLexicalAnalyser)lexicalAnalyser).getStorageRepresentation() ), "syntaxAnalyser", new ListStorageValue( - new StringStorageValue(syntaxAnalyser.getClass().getSimpleName()), + new StringStorageValue(syntaxAnalyser.getClass().getName()), ((CustomSyntaxAnalyser)syntaxAnalyser).getStorageRepresentation() ), "codeGenerator", new ListStorageValue( - new StringStorageValue(codeGenerator.getClass().getSimpleName()), + new StringStorageValue(codeGenerator.getClass().getName()), ((CustomCodeGenerator)codeGenerator).getStorageRepresentation() ) )); diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index 36e7294..d9a543d 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -2,7 +2,6 @@ import java.util.*; import java.util.Map.Entry; -import java.util.regex.*; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.*; From f92e2b5e43ab7171d44d9543be230d0c5b334a7d Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 29 Jun 2026 00:07:42 +0100 Subject: [PATCH 090/162] Gradle version update --- .gitignore | 2 +- build.gradle | 20 ++++++++++++++---- gradle/wrapper/gradle-wrapper.jar | Bin 43462 -> 48966 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 15 +++++++------- gradlew.bat | 25 ++++++++++++----------- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index d35b73a..3f9d58b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ .gradle build -bin \ No newline at end of file +bin diff --git a/build.gradle b/build.gradle index b454d11..3d78ca6 100644 --- a/build.gradle +++ b/build.gradle @@ -17,16 +17,21 @@ sourceSets { srcDirs = ['src/test/java'] } } + playground { + java { + srcDirs = ['src/playground/java'] + } + } } dependencies { - implementation platform('org.junit:junit-bom:5.10.3') - implementation 'org.junit.jupiter:junit-jupiter' - testImplementation platform('org.junit:junit-bom:5.10.3') testImplementation 'org.junit.jupiter:junit-jupiter' - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + playgroundImplementation sourceSets.main.output + // playgroundImplementation configurations.implementation + // playgroundRuntimeOnly configurations.runtimeClasspath } import org.gradle.api.tasks.testing.logging.TestExceptionFormat @@ -64,3 +69,10 @@ tasks.named('test') { } } } + +tasks.register('playground', JavaExec) { + group = 'application' + description = 'Runs the playground main method' + classpath = sourceSets.playground.runtimeClasspath + mainClass = 'Test' +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd4917707c1f8861d8cb53dd15194d4248596..d997cfc60f4cff0e7451d19d49a82fa986695d07 100644 GIT binary patch delta 40580 zcmXVXQ(z@+*KEukJDJ$FZJQI@w)e!gZF^!)%!zH=c5>$Z{&Uk;ebdictEyL3J;U>0 z!(U+aHi$s_$w{~%CS-^mAEN7ctd*Ikbe(b)h!hcE-Fllf(Qth5(_>Zhve8i%RQDyd zS(~by`;*MYVQix{Tr9;M&OK`XqPe6@Hi>)eAgM77I(KJw6y?HFyds2p>w=vFHBA9{ zX2MRr3W7G0WEeFy^N28_pqM|0nEg?nZfAB1fdN@;zFyBZ#2U7CYe((wQcDLl{1n$a zn360sjP>+{b_xgxNIOWCa@3xk$XC8&XohrrBg2`(+xYA!~zL|k)2K;~~%XO@zM;|-Ap2}gg0r%H#2&PN$1 zHd}4e{1AK4=fG{Ao3@&T9>JzZKBSJFrAU^rpBS*0!4|bTP&rYiS=17Vg9;RPWRr8n z|I=xq++OGs@4vIyd6N@M;z!m1s;(=bDWmI!wE*nGWZ}hc0=e`pWo5 z$&sTO%UHusdtFO2GE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pj_exrP;)jhN#+6_@s)?CX# zfN>hHfPyng^ZnI5GAAfRrrou9^`~v@kaZQN+Wtpm_8s#7Oep^v|@#CgUsb|m?jvsB4gPbb7 zWjGZ(cUZuyCI(bqVFlXLrlQI4Dk>EI7y>fl<<#QQr~s8$fsk&c0hm8gZFLNOU{%3y zZ(10Lsf0ii=6GnZQ3-S%88`ER!CKfl#ux)CDZ?NI`cz2;(J*iT*p7kzz$4JXDiiR( znW;N4&`A{-@&eJQ%jGHp4Mb&kwTUE>4hY3m<8iSR?XYu{^ijA?;wpjOAxi22LL_HrDn`vfDGl=X@aQZ_VUs3%%Q2DGw9zy;S~ zIx_XBDI@@xVBis(B{+v~1THuhi4BVYfP?`#c8eepQAC|{mJgTehJc)UGY~ag0RS3C zZJh@KWwR-W8v5@70MNyNEH4CXXj}s^0~8S$-J}EnWDH!vL10FcG_>)|8Zj&(-e?1r z-6h~Uqn5riPXQ4jv}y?e8W^Fgrxsx?5UoN1fI0@clng`LBo~S;_nPoH$_1p=M3Wwf zF46$N0Mn`{O$_1xw /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..c4bdd3a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,22 +59,21 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell From 2b9d5a2f8b194ce7b8dfb628a2fd4fa7a729cfc5 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 5 Jul 2026 23:48:20 +0100 Subject: [PATCH 091/162] Dynamic and reflective class loading Requires testing --- .../storage/CompilerStorage.java | 8 +- .../StorableCustomCompilerFactory.java | 68 +++++++++++---- .../storage/FactoryRepository.java | 39 +++++++++ .../storage/LoadableBy.java | 35 +++++++- .../storage/Loader.java | 26 ++++++ .../storage/ReflectiveClassConstructor.java | 64 ++++++++++++++ .../storage/ReflectiveFactoryRepository.java | 85 ------------------- .../storage/StorableBy.java | 5 -- .../storage/StorableCustomCompiler.java | 1 + src/test/java/storage/StorageTests.java | 2 + 10 files changed, 220 insertions(+), 113 deletions(-) create mode 100644 src/main/java/component_construction/storage/FactoryRepository.java create mode 100644 src/main/java/component_construction/storage/Loader.java create mode 100644 src/main/java/component_construction/storage/ReflectiveClassConstructor.java delete mode 100644 src/main/java/component_construction/storage/ReflectiveFactoryRepository.java delete mode 100644 src/main/java/component_construction/storage/StorableBy.java diff --git a/src/main/java/component_construction/storage/CompilerStorage.java b/src/main/java/component_construction/storage/CompilerStorage.java index b46ea0b..466f244 100644 --- a/src/main/java/component_construction/storage/CompilerStorage.java +++ b/src/main/java/component_construction/storage/CompilerStorage.java @@ -5,17 +5,17 @@ import storage.storage_values.StorageValue; public class CompilerStorage { - private Storage storage = new Storage(); - private StorableCustomCompilerFactory storableCustomCompilerFactory = new StorableCustomCompilerFactory(); + protected Storage storage = new Storage(); + protected StorableCustomCompilerFactory storableCustomCompilerFactory = new StorableCustomCompilerFactory(); public void store(StorableCustomCompiler compiler) { - //TODO: Store using Storable or StorableBy<> if defined storage.store(compiler); } public StorableCustomCompiler load() { - //TODO: Load using Loadable or LoadableBy<> if defined StorageValue storageValue = storage.load(); return storableCustomCompilerFactory.produce(storageValue); } + + // TODO: Include other load variations } \ No newline at end of file diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 8363deb..276d95e 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -1,16 +1,18 @@ package component_construction.storage.Factories; import java.util.*; - +import component_construction.custom_components.*; import component_construction.storage.*; +import storage.external_interfaces.Loadable; import storage.storage_values.*; -import component_construction.custom_components.*; -public class StorableCustomCompilerFactory implements Factory { - ReflectiveFactoryRepository lexicalAnalyserFactoryRepository = new ReflectiveFactoryRepository<>(CustomLexicalAnalyser.class); - ReflectiveFactoryRepository syntaxAnalyserFactoryRepository = new ReflectiveFactoryRepository<>(CustomSyntaxAnalyser.class);; - ReflectiveFactoryRepository codeGeneratorFactoryRepository = new ReflectiveFactoryRepository<>(CustomCodeGenerator.class);; +public class StorableCustomCompilerFactory implements Loader { + protected ReflectiveClassConstructor reflectiveClassLoader = new ReflectiveClassConstructor(); + protected FactoryRepository lexicalAnalyserFactoryRepository = new FactoryRepository<>(); + protected FactoryRepository syntaxAnalyserFactoryRepository = new FactoryRepository<>(); + protected FactoryRepository codeGeneratorFactoryRepository = new FactoryRepository<>(); + @SuppressWarnings("unchecked") @Override // TODO: Explain requirements for storage/loading public StorableCustomCompiler produce(StorageValue loadValue) { @@ -21,15 +23,47 @@ public StorableCustomCompiler produce(StorageValue loadValue) { CustomSyntaxAnalyser customSyntaxAnalyser; CustomCodeGenerator customCodeGenerator; + //TODO: Abstract common code into easy to use method try { ComponentDescription lexicalAnalyserDescription = getComponentDescription(mapValue.get("lexicalAnalyser")); - customLexicalAnalyser = lexicalAnalyserFactoryRepository.instantiate( - lexicalAnalyserDescription.name, - lexicalAnalyserDescription.description - ); + if (lexicalAnalyserFactoryRepository.containsKey(lexicalAnalyserDescription.name())) { + customLexicalAnalyser = lexicalAnalyserFactoryRepository.instantiate( + lexicalAnalyserDescription.name(), + lexicalAnalyserDescription.description() + ); + } + + Class clazz = (Class) Class + .forName(lexicalAnalyserDescription.name()) + .asSubclass(CustomLexicalAnalyser.class); + + if (LoadableBy.class.isAssignableFrom(clazz)) { + Class>> loadableBy = (Class>>) clazz.asSubclass(LoadableBy.class); + Class> targetLoader = LoadableBy.getTargetLoader(loadableBy); + Loader loader = Loader.construct(targetLoader); + customLexicalAnalyser = loader.produce(lexicalAnalyserDescription.description()); + } + else if (Loadable.class.isAssignableFrom(clazz)) { + customLexicalAnalyser = reflectiveClassLoader.construct( + lexicalAnalyserDescription.name(), + CustomLexicalAnalyser.class + ); + + ((Loadable)customLexicalAnalyser) + .load(lexicalAnalyserDescription.description()); + } + // Use constructor + else { + customLexicalAnalyser = reflectiveClassLoader.construct( + lexicalAnalyserDescription.name(), + CustomLexicalAnalyser.class, + StorageValue.class, + lexicalAnalyserDescription.description() + ); + } } - catch (ClassNotFoundException e) { + catch (ClassNotFoundException e) { //TODO: Check for other exceptions throw new RuntimeException(e); // TODO: Create custom exception } @@ -37,8 +71,8 @@ public StorableCustomCompiler produce(StorageValue loadValue) { ComponentDescription syntaxAnalyserDescription = getComponentDescription(mapValue.get("syntaxAnalyser")); customSyntaxAnalyser = syntaxAnalyserFactoryRepository.instantiate( - syntaxAnalyserDescription.name, - syntaxAnalyserDescription.description + syntaxAnalyserDescription.name(), + syntaxAnalyserDescription.description() ); } catch (ClassNotFoundException e) { @@ -49,8 +83,8 @@ public StorableCustomCompiler produce(StorageValue loadValue) { ComponentDescription codeGeneratorDescription = getComponentDescription(mapValue.get("syntaxAnalyser")); customCodeGenerator = codeGeneratorFactoryRepository.instantiate( - codeGeneratorDescription.name, - codeGeneratorDescription.description + codeGeneratorDescription.name(), + codeGeneratorDescription.description() ); } catch (ClassNotFoundException e) { @@ -65,7 +99,7 @@ public StorableCustomCompiler produce(StorageValue loadValue) { } // TODO: Handle errors - private ComponentDescription getComponentDescription(StorageValue description) { + protected ComponentDescription getComponentDescription(StorageValue description) { List> entry = ((ListStorageValue)description).getValue(); return new ComponentDescription( @@ -74,5 +108,5 @@ private ComponentDescription getComponentDescription(StorageValue description ); } - private record ComponentDescription(String name, ListStorageValue description) {} + protected record ComponentDescription(String name, ListStorageValue description) {} } diff --git a/src/main/java/component_construction/storage/FactoryRepository.java b/src/main/java/component_construction/storage/FactoryRepository.java new file mode 100644 index 0000000..8d549f4 --- /dev/null +++ b/src/main/java/component_construction/storage/FactoryRepository.java @@ -0,0 +1,39 @@ +package component_construction.storage; + +import java.lang.reflect.InvocationTargetException; +import java.util.*; + +import component_construction.storage.Factories.Factory; +import storage.storage_values.StorageValue; + +public class FactoryRepository { + protected Map> factories = new HashMap<>(); + + /** + * + * @param name + * @param generator + * @return This object for method chaining + */ + public FactoryRepository addFactory(String name, Factory generator) { + factories.put(name, generator); + return this; + } + + public boolean containsKey(String name) { + return factories.containsKey(name); + } + + /** + * Instantiates the named entity using the given value. + * @param name The entity name + * @param loadValue The StorageValue to be loaded into the specified entity + * @return The constructed entity + * @throws ClassNotFoundException + */ + public T instantiate(String name, StorageValue loadValue) throws ClassNotFoundException { + return factories + .get(name) + .produce(loadValue); + } +} diff --git a/src/main/java/component_construction/storage/LoadableBy.java b/src/main/java/component_construction/storage/LoadableBy.java index 0fe9534..fcf03ed 100644 --- a/src/main/java/component_construction/storage/LoadableBy.java +++ b/src/main/java/component_construction/storage/LoadableBy.java @@ -1,5 +1,36 @@ package component_construction.storage; -import component_construction.storage.Factories.Factory; +import java.lang.reflect.*; -public interface LoadableBy> {} +/** + * A class specifying a designated loader for the current class. + * Loaders will be loaded using reflection. + * @param + */ +public interface LoadableBy> { + + @SuppressWarnings("unchecked") + public static Class> getTargetLoader(Class>> loadableByClass) { + for (Type currentInterface : loadableByClass.getGenericInterfaces()) { + if (!(currentInterface instanceof ParameterizedType)) continue; + + ParameterizedType paramType = (ParameterizedType) currentInterface; + + if (!paramType.getRawType().equals(LoadableBy.class)) continue; + + Type actualTypeArgument = paramType.getActualTypeArguments()[0]; + + //TODO: Scrutinise below code, along with warning supression + + // If T is a standard class/interface, return it + if (actualTypeArgument instanceof Class) + return (Class>) actualTypeArgument; + // Handle nested generic loaders (e.g., MyLoader) + else if (actualTypeArgument instanceof ParameterizedType) + return (Class>) ((ParameterizedType) actualTypeArgument).getRawType(); + } + + throw new IllegalArgumentException("Class " + loadableByClass.getName() + " does not directly implement LoadableBy with a concrete generic type."); + } + +} diff --git a/src/main/java/component_construction/storage/Loader.java b/src/main/java/component_construction/storage/Loader.java new file mode 100644 index 0000000..d9b476a --- /dev/null +++ b/src/main/java/component_construction/storage/Loader.java @@ -0,0 +1,26 @@ +package component_construction.storage; + +import java.lang.reflect.InvocationTargetException; +import component_construction.storage.Factories.Factory; + +public interface Loader extends Factory { + + public static Loader construct(Class> loaderClass) { + try { + return loaderClass + .getConstructor() + .newInstance(); + } + catch ( + InstantiationException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException + | NoSuchMethodException + e + ) { + throw new RuntimeException(); //TODO: Custom error + } + } + +} diff --git a/src/main/java/component_construction/storage/ReflectiveClassConstructor.java b/src/main/java/component_construction/storage/ReflectiveClassConstructor.java new file mode 100644 index 0000000..6c1aeca --- /dev/null +++ b/src/main/java/component_construction/storage/ReflectiveClassConstructor.java @@ -0,0 +1,64 @@ +package component_construction.storage; + +import java.lang.reflect.InvocationTargetException; +import java.util.*; +import java.util.stream.Collectors; + +public class ReflectiveClassConstructor { + + //TODO: Fix exceptions and add to method declarations + //TODO: Document + + public T construct(String className, Class targetType) throws ClassNotFoundException { + return construct( + className, + targetType, + new Class[] {}, + new Object[] {} + ); + } + + public T construct(String className, Class targetType, Class parameterType, Object parameter) throws ClassNotFoundException { + return construct( + className, + targetType, + new Class[] { parameterType }, + new Object[] { parameter } + ); + } + + public T construct(String className, Class targetType, Class[] parameterTypes, Object[] parameters) throws ClassNotFoundException { + try { + return Class + .forName(className) + .asSubclass(targetType) + .getDeclaredConstructor(parameterTypes) + .newInstance(parameters); + } + catch (ClassNotFoundException e) { + throw new ClassNotFoundException("Target class footprint not found: " + className, e); + } + catch (NoSuchMethodException e) { + String typesString = Arrays.stream(parameterTypes) + .map(Class::getSimpleName) + .collect(Collectors.joining(", ")); + + throw new IllegalArgumentException( + "No constructor found in " + className + " matching types: [" + typesString + "]", e + ); + } + catch (IllegalAccessException e) { + throw new RuntimeException("Constructor is private or inaccessible in class: " + className, e); + } + catch (InstantiationException e) { + throw new RuntimeException("Cannot instantiate abstract class or interface: " + className, e); + } + catch (InvocationTargetException e) { + throw new RuntimeException("The constructor for " + className + " threw an exception", e.getCause()); + } + catch (IllegalArgumentException | SecurityException e) { + throw new RuntimeException("Reflection configuration error for class: " + className, e); + } + } + +} diff --git a/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java b/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java deleted file mode 100644 index e1607d3..0000000 --- a/src/main/java/component_construction/storage/ReflectiveFactoryRepository.java +++ /dev/null @@ -1,85 +0,0 @@ -package component_construction.storage; - -import java.lang.reflect.InvocationTargetException; -import java.util.*; - -import component_construction.storage.Factories.Factory; -import storage.storage_values.StorageValue; - -public class ReflectiveFactoryRepository { - protected Map> factories = new HashMap<>(); - protected Class innerType; - - public ReflectiveFactoryRepository(Class innerType) { - this.innerType = innerType; - } - - /** - * - * @param name - * @param generator - * @return This object for method chaining - */ - public ReflectiveFactoryRepository addFactory(String name, Factory generator) { - factories.put(name, generator); - return this; - } - - /** - * Instantiates the named entity using the given value. - *

- * If no factory exists for the named entity, the name will be treated as a class name as expected by {@code Class.forName(...)}. - * The named class must include a constructor of the form {@code public NamedClass(StorageValue state) { ... }} in order to be instantiated. - * @param name The entity name - * @param loadValue The StorageValue to be loaded into the specified entity - * @return The constructed entity - * @throws ClassNotFoundException - */ - public T instantiate(String name, StorageValue loadValue) throws ClassNotFoundException { - if (!factories.containsKey(name)) { - // Assume name is the name of a class with type T - return createInstanceOf(name, loadValue); - } - - return factories - .get(name) - .produce(loadValue); - } - - /** - * - * @param - * @param className Must include the package definition e.g "com.example.ExampleClass" - * @param state - * @return - * @throws Exception - */ - private T createInstanceOf(String className, StorageValue state) throws ClassNotFoundException { - Class clazz; - - try { - clazz = Class.forName(className); - } - catch (ClassNotFoundException e) { - throw e; //TODO: More descriptive exception - } - - try { - return clazz - .asSubclass(innerType) - .getDeclaredConstructor(StorageValue.class) - .newInstance(state); - } - catch ( - InstantiationException - | IllegalAccessException - | IllegalArgumentException - | InvocationTargetException - | NoSuchMethodException - | SecurityException - e - ) { - throw new RuntimeException(e); //TODO: Combine into more descriptive/useful exception per fail case - } - } -} diff --git a/src/main/java/component_construction/storage/StorableBy.java b/src/main/java/component_construction/storage/StorableBy.java deleted file mode 100644 index 5d6e42d..0000000 --- a/src/main/java/component_construction/storage/StorableBy.java +++ /dev/null @@ -1,5 +0,0 @@ -package component_construction.storage; - -import storage.external_interfaces.Storable; - -public interface StorableBy {} \ No newline at end of file diff --git a/src/main/java/component_construction/storage/StorableCustomCompiler.java b/src/main/java/component_construction/storage/StorableCustomCompiler.java index 3ba568c..74b3602 100644 --- a/src/main/java/component_construction/storage/StorableCustomCompiler.java +++ b/src/main/java/component_construction/storage/StorableCustomCompiler.java @@ -33,4 +33,5 @@ public MapStorageValue getStorageRepresentation() { ) )); } + } diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 3828768..ed0cd9d 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1407,4 +1407,6 @@ public void loadStringFromTargetPath_FormatterError(Path testFile) throws IOExce ); assertInstanceOf(ExampleException.class, exception.getCause()); } + + // TODO: Test LoadableBy } From d87e1e77b86923cb1f8a9df97c9f2be14cf97857 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 8 Jul 2026 00:37:20 +0100 Subject: [PATCH 092/162] File rearrange and test file creation --- .../storage/CompilerStorage.java | 2 +- .../storage/Factories/Factory.java | 2 +- .../Factories/StorableCustomCompilerFactory.java | 3 ++- .../storage/StorableCustomCompiler.java | 3 ++- .../StorableCustomCompilerBuilder.java | 3 ++- .../storage/{ => dynamic_loading}/LoadableBy.java | 2 +- .../storage/{ => dynamic_loading}/Loader.java | 4 ++-- .../ReflectiveClassConstructor.java | 2 +- .../storage/{ => factories}/FactoryRepository.java | 4 +--- .../storage/CompilerStorageTests.java | 12 ++++++++++++ .../storage/StorableCustomCompilerTests.java | 5 +++++ .../builders/StorableCustomCompilerBuilderTests.java | 5 +++++ .../storage/dynamic_loading/LoadableByTests.java | 5 +++++ .../storage/dynamic_loading/LoaderTests.java | 5 +++++ .../ReflectiveClassConstructorTests.java | 5 +++++ .../StorableCustomCompilerFactoryTests.java | 5 +++++ 16 files changed, 55 insertions(+), 12 deletions(-) rename src/main/java/component_construction/storage/{ => builders}/StorableCustomCompilerBuilder.java (93%) rename src/main/java/component_construction/storage/{ => dynamic_loading}/LoadableBy.java (96%) rename src/main/java/component_construction/storage/{ => dynamic_loading}/Loader.java (84%) rename src/main/java/component_construction/storage/{ => dynamic_loading}/ReflectiveClassConstructor.java (97%) rename src/main/java/component_construction/storage/{ => factories}/FactoryRepository.java (86%) create mode 100644 src/test/java/component_construction/storage/CompilerStorageTests.java create mode 100644 src/test/java/component_construction/storage/StorableCustomCompilerTests.java create mode 100644 src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java create mode 100644 src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java create mode 100644 src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java create mode 100644 src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java create mode 100644 src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java diff --git a/src/main/java/component_construction/storage/CompilerStorage.java b/src/main/java/component_construction/storage/CompilerStorage.java index 466f244..5c23424 100644 --- a/src/main/java/component_construction/storage/CompilerStorage.java +++ b/src/main/java/component_construction/storage/CompilerStorage.java @@ -1,6 +1,6 @@ package component_construction.storage; -import component_construction.storage.Factories.StorableCustomCompilerFactory; +import component_construction.storage.factories.StorableCustomCompilerFactory; import storage.Storage; import storage.storage_values.StorageValue; diff --git a/src/main/java/component_construction/storage/Factories/Factory.java b/src/main/java/component_construction/storage/Factories/Factory.java index 710f489..799c8d6 100644 --- a/src/main/java/component_construction/storage/Factories/Factory.java +++ b/src/main/java/component_construction/storage/Factories/Factory.java @@ -1,4 +1,4 @@ -package component_construction.storage.Factories; +package component_construction.storage.factories; import storage.storage_values.StorageValue; diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 276d95e..4eaaa2d 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -1,8 +1,9 @@ -package component_construction.storage.Factories; +package component_construction.storage.factories; import java.util.*; import component_construction.custom_components.*; import component_construction.storage.*; +import component_construction.storage.dynamic_loading.*; import storage.external_interfaces.Loadable; import storage.storage_values.*; diff --git a/src/main/java/component_construction/storage/StorableCustomCompiler.java b/src/main/java/component_construction/storage/StorableCustomCompiler.java index 74b3602..f2ce0cc 100644 --- a/src/main/java/component_construction/storage/StorableCustomCompiler.java +++ b/src/main/java/component_construction/storage/StorableCustomCompiler.java @@ -2,7 +2,8 @@ import java.util.Map; import component_construction.custom_components.*; -import component_construction.storage.Factories.StorableCustomCompilerFactory; +import component_construction.storage.dynamic_loading.LoadableBy; +import component_construction.storage.factories.StorableCustomCompilerFactory; import storage.external_interfaces.Storable; import storage.storage_values.*; diff --git a/src/main/java/component_construction/storage/StorableCustomCompilerBuilder.java b/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java similarity index 93% rename from src/main/java/component_construction/storage/StorableCustomCompilerBuilder.java rename to src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java index 0806c5a..ecbcfde 100644 --- a/src/main/java/component_construction/storage/StorableCustomCompilerBuilder.java +++ b/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java @@ -1,8 +1,9 @@ -package component_construction.storage; +package component_construction.storage.builders; import code_generation.CodeGenerator; import component_construction.builders.CompilerBuilderTemplate; import component_construction.custom_components.*; +import component_construction.storage.StorableCustomCompiler; import grammar_objects.GrammarParts; import lexical_analysis.LexicalAnalyser; import syntax_analysis.SyntaxAnalyser; diff --git a/src/main/java/component_construction/storage/LoadableBy.java b/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java similarity index 96% rename from src/main/java/component_construction/storage/LoadableBy.java rename to src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java index fcf03ed..1891d47 100644 --- a/src/main/java/component_construction/storage/LoadableBy.java +++ b/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java @@ -1,4 +1,4 @@ -package component_construction.storage; +package component_construction.storage.dynamic_loading; import java.lang.reflect.*; diff --git a/src/main/java/component_construction/storage/Loader.java b/src/main/java/component_construction/storage/dynamic_loading/Loader.java similarity index 84% rename from src/main/java/component_construction/storage/Loader.java rename to src/main/java/component_construction/storage/dynamic_loading/Loader.java index d9b476a..a0a872c 100644 --- a/src/main/java/component_construction/storage/Loader.java +++ b/src/main/java/component_construction/storage/dynamic_loading/Loader.java @@ -1,7 +1,7 @@ -package component_construction.storage; +package component_construction.storage.dynamic_loading; import java.lang.reflect.InvocationTargetException; -import component_construction.storage.Factories.Factory; +import component_construction.storage.factories.Factory; public interface Loader extends Factory { diff --git a/src/main/java/component_construction/storage/ReflectiveClassConstructor.java b/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java similarity index 97% rename from src/main/java/component_construction/storage/ReflectiveClassConstructor.java rename to src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java index 6c1aeca..ce6ea11 100644 --- a/src/main/java/component_construction/storage/ReflectiveClassConstructor.java +++ b/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java @@ -1,4 +1,4 @@ -package component_construction.storage; +package component_construction.storage.dynamic_loading; import java.lang.reflect.InvocationTargetException; import java.util.*; diff --git a/src/main/java/component_construction/storage/FactoryRepository.java b/src/main/java/component_construction/storage/factories/FactoryRepository.java similarity index 86% rename from src/main/java/component_construction/storage/FactoryRepository.java rename to src/main/java/component_construction/storage/factories/FactoryRepository.java index 8d549f4..95d2467 100644 --- a/src/main/java/component_construction/storage/FactoryRepository.java +++ b/src/main/java/component_construction/storage/factories/FactoryRepository.java @@ -1,9 +1,7 @@ -package component_construction.storage; +package component_construction.storage.factories; -import java.lang.reflect.InvocationTargetException; import java.util.*; -import component_construction.storage.Factories.Factory; import storage.storage_values.StorageValue; public class FactoryRepository { diff --git a/src/test/java/component_construction/storage/CompilerStorageTests.java b/src/test/java/component_construction/storage/CompilerStorageTests.java new file mode 100644 index 0000000..09ae0ed --- /dev/null +++ b/src/test/java/component_construction/storage/CompilerStorageTests.java @@ -0,0 +1,12 @@ +package component_construction.storage; + +public class CompilerStorageTests { + // TODO: Test + + //store(null) + //store(StorableCustomCompiler) + + //load() valid format + //load() incomplete format + //load() incrrect format +} diff --git a/src/test/java/component_construction/storage/StorableCustomCompilerTests.java b/src/test/java/component_construction/storage/StorableCustomCompilerTests.java new file mode 100644 index 0000000..b452969 --- /dev/null +++ b/src/test/java/component_construction/storage/StorableCustomCompilerTests.java @@ -0,0 +1,5 @@ +package component_construction.storage; + +public class StorableCustomCompilerTests { + // TODO +} diff --git a/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java b/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java new file mode 100644 index 0000000..a53ebc3 --- /dev/null +++ b/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java @@ -0,0 +1,5 @@ +package component_construction.storage.builders; + +public class StorableCustomCompilerBuilderTests { + // TODO +} diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java b/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java new file mode 100644 index 0000000..4cd6e9d --- /dev/null +++ b/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java @@ -0,0 +1,5 @@ +package component_construction.storage.dynamic_loading; + +public class LoadableByTests { + // TODO +} diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java b/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java new file mode 100644 index 0000000..9959c71 --- /dev/null +++ b/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java @@ -0,0 +1,5 @@ +package component_construction.storage.dynamic_loading; + +public class LoaderTests { + // TODO +} diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java new file mode 100644 index 0000000..678ecb2 --- /dev/null +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -0,0 +1,5 @@ +package component_construction.storage.dynamic_loading; + +public class ReflectiveClassConstructorTests { + // TODO +} diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java new file mode 100644 index 0000000..d0f6816 --- /dev/null +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -0,0 +1,5 @@ +package component_construction.storage.factories; + +public class StorableCustomCompilerFactoryTests { + // TODO +} From a28d2b3b54c7144ff642f8f3ee45eeadb72f0085 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 12 Jul 2026 00:45:23 +0100 Subject: [PATCH 093/162] Start ReflectiveClassConstructorTests Includes test helper objects --- .../ReflectiveClassConstructorTests.java | 63 ++++++++++++++++++- .../storage_entities/TestDynamicObject.java | 31 +++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/test/java/test_aids/storage_entities/TestDynamicObject.java diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index 678ecb2..93fa48b 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -1,5 +1,66 @@ package component_construction.storage.dynamic_loading; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; +import test_aids.storage_entities.TestDynamicObject; +import test_aids.storage_entities.TestDynamicObject.*; + public class ReflectiveClassConstructorTests { - // TODO + + @Test + public void construct_noParameters_class() throws ClassNotFoundException { + TestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObject.class + ); + TestDynamicObject expectedObject = new TestDynamicObject(); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_noParameters_staticInnerClass() throws ClassNotFoundException { + StaticInnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + StaticInnerTestDynamicObject.class.getName(), + StaticInnerTestDynamicObject.class + ); + StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_noParameters_innerClass() throws ClassNotFoundException { + TestDynamicObject parentObject = new TestDynamicObject(); + + InnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + InnerTestDynamicObject.class.getName(), + InnerTestDynamicObject.class, + new Class[] {parentObject.getClass()}, + new Object[] {parentObject} + ); + InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_oneParameter() { + //TODO + } + + //TODO: static and regular inner classes + + @Test + public void construct_manyParameters() { + //TODO + } + + //TODO: static and regular inner classes + + //TODO: non existant class attempts + //TODO: load as subclass type } diff --git a/src/test/java/test_aids/storage_entities/TestDynamicObject.java b/src/test/java/test_aids/storage_entities/TestDynamicObject.java new file mode 100644 index 0000000..a3a389f --- /dev/null +++ b/src/test/java/test_aids/storage_entities/TestDynamicObject.java @@ -0,0 +1,31 @@ +package test_aids.storage_entities; + +public class TestDynamicObject { + public TestDynamicObject() {} + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof TestDynamicObject)) return false; + return true; + } + + public class InnerTestDynamicObject { + public InnerTestDynamicObject() {} + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof InnerTestDynamicObject)) return false; + return true; + } + } + + public static class StaticInnerTestDynamicObject { + public StaticInnerTestDynamicObject() {} + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof StaticInnerTestDynamicObject)) return false; + return true; + } + } +} From b14cb5a16cf8a0071f34c8fb2894d35b5cd90389 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 14 Jul 2026 00:07:26 +0100 Subject: [PATCH 094/162] Dynamic construction tests one parameter without error cases --- .../ReflectiveClassConstructorTests.java | 112 +++++++++++++++++- .../storage_entities/TestDynamicObject.java | 66 +++++++++++ 2 files changed, 175 insertions(+), 3 deletions(-) diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index 93fa48b..7c6737b 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -48,11 +48,117 @@ public void construct_noParameters_innerClass() throws ClassNotFoundException { } @Test - public void construct_oneParameter() { - //TODO + public void construct_oneParameter_class_intParam() throws ClassNotFoundException { + TestDynamicObject expectedObject = new TestDynamicObject(); + expectedObject.a = 1; + + TestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObject.class, + new Class[] {int.class}, + new Object[] {expectedObject.a} + ); + + assertEquals(expectedObject, actualObject); } - //TODO: static and regular inner classes + @Test + public void construct_oneParameter_staticInnerClass_intParam() throws ClassNotFoundException { + StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); + expectedObject.e = 1; + + StaticInnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + StaticInnerTestDynamicObject.class.getName(), + StaticInnerTestDynamicObject.class, + new Class[] {int.class}, + new Object[] {expectedObject.e} + ); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_oneParameter_innerClass_intParam() throws ClassNotFoundException { + TestDynamicObject parentObject = new TestDynamicObject(); + InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); + expectedObject.c = 1; + + InnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + InnerTestDynamicObject.class.getName(), + InnerTestDynamicObject.class, + new Class[] { + parentObject.getClass(), + int.class + }, + new Object[] { + parentObject, + expectedObject.c + } + ); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_oneParameter_class_stringParam() throws ClassNotFoundException { + TestDynamicObject expectedObject = new TestDynamicObject(); + expectedObject.b = "Test"; + + TestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObject.class, + new Class[] {String.class}, + new Object[] {expectedObject.b} + ); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_oneParameter_staticInnerClass_stringParam() throws ClassNotFoundException { + StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); + expectedObject.f = "Test"; + + StaticInnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + StaticInnerTestDynamicObject.class.getName(), + StaticInnerTestDynamicObject.class, + new Class[] {String.class}, + new Object[] {expectedObject.f} + ); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_oneParameter_innerClass_stringParam() throws ClassNotFoundException { + TestDynamicObject parentObject = new TestDynamicObject(); + InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); + expectedObject.d = "Test"; + + InnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + InnerTestDynamicObject.class.getName(), + InnerTestDynamicObject.class, + new Class[] { + parentObject.getClass(), + String.class + }, + new Object[] { + parentObject, + expectedObject.d + } + ); + + assertEquals(expectedObject, actualObject); + } + + // Incorrect Type + // Incorrect Paramter @Test public void construct_manyParameters() { diff --git a/src/test/java/test_aids/storage_entities/TestDynamicObject.java b/src/test/java/test_aids/storage_entities/TestDynamicObject.java index a3a389f..dc3223c 100644 --- a/src/test/java/test_aids/storage_entities/TestDynamicObject.java +++ b/src/test/java/test_aids/storage_entities/TestDynamicObject.java @@ -1,30 +1,96 @@ package test_aids.storage_entities; public class TestDynamicObject { + public int a; + public String b; + public TestDynamicObject() {} + public TestDynamicObject(int a) { + this.a = a; + } + + public TestDynamicObject(String b) { + this.b = b; + } + + public TestDynamicObject(int a, String b) { + this.a = a; + this.b = b; + } + @Override public boolean equals(Object obj) { if (!(obj instanceof TestDynamicObject)) return false; + + TestDynamicObject other = (TestDynamicObject)obj; + + if (this.a != other.a) return false; + if (this.b != other.b) return false; + return true; } public class InnerTestDynamicObject { + public int c; + public String d; + public InnerTestDynamicObject() {} + public InnerTestDynamicObject(int c) { + this.c = c; + } + + public InnerTestDynamicObject(String d) { + this.d = d; + } + + public InnerTestDynamicObject(int c, String d) { + this.c = c; + this.d = d; + } + @Override public boolean equals(Object obj) { if (!(obj instanceof InnerTestDynamicObject)) return false; + + InnerTestDynamicObject other = (InnerTestDynamicObject)obj; + + if (this.c != other.c) return false; + if (this.d != other.d) return false; + return true; } } public static class StaticInnerTestDynamicObject { + public int e; + public String f; + public StaticInnerTestDynamicObject() {} + public StaticInnerTestDynamicObject(int e) { + this.e = e; + } + + public StaticInnerTestDynamicObject(String f) { + this.f = f; + } + + public StaticInnerTestDynamicObject(int e, String f) { + this.e = e; + this.f = f; + } + @Override public boolean equals(Object obj) { if (!(obj instanceof StaticInnerTestDynamicObject)) return false; + + StaticInnerTestDynamicObject other = (StaticInnerTestDynamicObject)obj; + + if (this.e != other.e) return false; + if (this.f != other.f) return false; + return true; } } From 1a38b3dfde09a76b0e1cd068a7490694d49dbe33 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 14 Jul 2026 23:54:21 +0100 Subject: [PATCH 095/162] Incorrect type arngument --- .../ReflectiveClassConstructorTests.java | 107 +++++++++++++++++- 1 file changed, 105 insertions(+), 2 deletions(-) diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index 7c6737b..ed9c9c2 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -1,6 +1,8 @@ package component_construction.storage.dynamic_loading; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.junit.jupiter.api.Test; import test_aids.storage_entities.TestDynamicObject; import test_aids.storage_entities.TestDynamicObject.*; @@ -157,8 +159,109 @@ public void construct_oneParameter_innerClass_stringParam() throws ClassNotFound assertEquals(expectedObject, actualObject); } - // Incorrect Type - // Incorrect Paramter + @Test + public void construct_oneParameter_class_falseBooleanType() throws ClassNotFoundException { + TestDynamicObject expectedObject = new TestDynamicObject(); + expectedObject.a = 1; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObject.class, + new Class[] {boolean.class}, + new Object[] {expectedObject.a} + ) + ); + } + + @Test + public void construct_oneParameter_staticInnerClass_falseBooleanType() throws ClassNotFoundException { + StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); + expectedObject.e = 1; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + StaticInnerTestDynamicObject.class.getName(), + StaticInnerTestDynamicObject.class, + new Class[] {boolean.class}, + new Object[] {expectedObject.e} + ) + ); + } + + @Test + public void construct_oneParameter_innerClass_falseBooleanType() throws ClassNotFoundException { + TestDynamicObject parentObject = new TestDynamicObject(); + InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); + expectedObject.c = 1; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + InnerTestDynamicObject.class.getName(), + InnerTestDynamicObject.class, + new Class[] { + parentObject.getClass(), + boolean.class + }, + new Object[] { + parentObject, + expectedObject.c + } + ) + ); + } + + @Test + public void construct_oneParameter_class_falseBooleanParam() throws ClassNotFoundException { + TestDynamicObject expectedObject = new TestDynamicObject(); + expectedObject.a = 1; + + TestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObject.class, + new Class[] {int.class}, + new Object[] {false} + ); + } + + @Test + public void construct_oneParameter_staticInnerClass_falseBooleanParam() throws ClassNotFoundException { + StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); + expectedObject.e = 1; + + StaticInnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + StaticInnerTestDynamicObject.class.getName(), + StaticInnerTestDynamicObject.class, + new Class[] {int.class}, + new Object[] {false} + ); + } + + @Test + public void construct_oneParameter_innerClass_falseBooleanParam() throws ClassNotFoundException { + TestDynamicObject parentObject = new TestDynamicObject(); + InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); + expectedObject.c = 1; + + InnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + InnerTestDynamicObject.class.getName(), + InnerTestDynamicObject.class, + new Class[] { + parentObject.getClass(), + int.class + }, + new Object[] { + parentObject, + false + } + ); + } @Test public void construct_manyParameters() { From fcfd156c0b5efb082fea091e7b7f6ab5f4ae7e24 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 15 Jul 2026 00:15:41 +0100 Subject: [PATCH 096/162] Incorrect parameter types --- .../ReflectiveClassConstructor.java | 26 ++++++++++++++----- .../ReflectiveClassConstructorTests.java | 24 ++++++++++------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java b/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java index ce6ea11..45abe9b 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java +++ b/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java @@ -39,12 +39,15 @@ public T construct(String className, Class targetType, Class[] paramet throw new ClassNotFoundException("Target class footprint not found: " + className, e); } catch (NoSuchMethodException e) { - String typesString = Arrays.stream(parameterTypes) - .map(Class::getSimpleName) - .collect(Collectors.joining(", ")); - throw new IllegalArgumentException( - "No constructor found in " + className + " matching types: [" + typesString + "]", e + "No constructor found in " + className + " matching types: [" + getTypesString(parameterTypes) + "]", + e + ); + } + catch (IllegalArgumentException e) { + throw new IllegalArgumentException( + "Type mismatch between declared types [" + getTypesString(parameterTypes) + "] and parameter types [" + getParameterTypesString(parameters) + "]", + e ); } catch (IllegalAccessException e) { @@ -56,9 +59,20 @@ public T construct(String className, Class targetType, Class[] paramet catch (InvocationTargetException e) { throw new RuntimeException("The constructor for " + className + " threw an exception", e.getCause()); } - catch (IllegalArgumentException | SecurityException e) { + catch (SecurityException e) { throw new RuntimeException("Reflection configuration error for class: " + className, e); } } + protected String getTypesString(Class[] parameterTypes) { + return Arrays.stream(parameterTypes) + .map(Class::getSimpleName) + .collect(Collectors.joining(", ")); + } + + protected String getParameterTypesString(Object[] parameters) { + return Arrays.stream(parameters) + .map(parameter -> parameter.getClass().getSimpleName()) + .collect(Collectors.joining(", ")); + } } diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index ed9c9c2..46627f5 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -219,13 +219,15 @@ public void construct_oneParameter_class_falseBooleanParam() throws ClassNotFoun TestDynamicObject expectedObject = new TestDynamicObject(); expectedObject.a = 1; - TestDynamicObject actualObject = new ReflectiveClassConstructor() + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() .construct( TestDynamicObject.class.getName(), TestDynamicObject.class, new Class[] {int.class}, new Object[] {false} - ); + ) + ); } @Test @@ -233,13 +235,15 @@ public void construct_oneParameter_staticInnerClass_falseBooleanParam() throws C StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); expectedObject.e = 1; - StaticInnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() .construct( StaticInnerTestDynamicObject.class.getName(), StaticInnerTestDynamicObject.class, new Class[] {int.class}, new Object[] {false} - ); + ) + ); } @Test @@ -248,7 +252,8 @@ public void construct_oneParameter_innerClass_falseBooleanParam() throws ClassNo InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); expectedObject.c = 1; - InnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() .construct( InnerTestDynamicObject.class.getName(), InnerTestDynamicObject.class, @@ -260,7 +265,8 @@ public void construct_oneParameter_innerClass_falseBooleanParam() throws ClassNo parentObject, false } - ); + ) + ); } @Test @@ -268,8 +274,8 @@ public void construct_manyParameters() { //TODO } - //TODO: static and regular inner classes + //TODO: Static and regular inner classes - //TODO: non existant class attempts - //TODO: load as subclass type + //TODO: Non existant class attempts + //TODO: Load as subclass type } From d90b979bf6168b8d309c0c00718c60ef6234251d Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 16 Jul 2026 00:28:59 +0100 Subject: [PATCH 097/162] No parameters non-existent class given --- .../ReflectiveClassConstructor.java | 2 +- .../ReflectiveClassConstructorTests.java | 41 ++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java b/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java index 45abe9b..fda2c92 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java +++ b/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java @@ -36,7 +36,7 @@ public T construct(String className, Class targetType, Class[] paramet .newInstance(parameters); } catch (ClassNotFoundException e) { - throw new ClassNotFoundException("Target class footprint not found: " + className, e); + throw new ClassNotFoundException("Target class not found: " + className, e); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index 46627f5..c175f25 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -1,7 +1,6 @@ package component_construction.storage.dynamic_loading; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import test_aids.storage_entities.TestDynamicObject; @@ -9,6 +8,11 @@ public class ReflectiveClassConstructorTests { + protected String TestDynamicObjectNamespace = TestDynamicObject.class.getPackageName(); + protected String nonExistantTestDynamicObjectPath = TestDynamicObjectNamespace + ".NonExistantTestDynamicObject"; + protected String nonExistantStaticInnerTestDynamicObjectPath = TestDynamicObjectNamespace + ".NonExistantTestDynamicObject$StaticInnerTestDynamicObject"; + protected String nonExistantInnerTestDynamicObjectPath = TestDynamicObjectNamespace + ".NonExistantTestDynamicObject$InnerTestDynamicObject"; + @Test public void construct_noParameters_class() throws ClassNotFoundException { TestDynamicObject actualObject = new ReflectiveClassConstructor() @@ -49,6 +53,39 @@ public void construct_noParameters_innerClass() throws ClassNotFoundException { assertEquals(expectedObject, actualObject); } + @Test + public void construct_noParameters_nonExistantClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantTestDynamicObjectPath, + TestDynamicObject.class + ) + ); + } + + @Test + public void construct_noParameters_nonExistantStaticInnerClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantStaticInnerTestDynamicObjectPath, + TestDynamicObject.class + ) + ); + } + + @Test + public void construct_noParameters_nonExistantInnerClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantInnerTestDynamicObjectPath, + TestDynamicObject.class + ) + ); + } + @Test public void construct_oneParameter_class_intParam() throws ClassNotFoundException { TestDynamicObject expectedObject = new TestDynamicObject(); From c8129ba76d5c640d2e89dfcef4329f404102edb3 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 16 Jul 2026 00:45:28 +0100 Subject: [PATCH 098/162] One Parameter non-existent class given --- .../ReflectiveClassConstructorTests.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index c175f25..14c33ca 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -306,6 +306,45 @@ public void construct_oneParameter_innerClass_falseBooleanParam() throws ClassNo ); } + @Test + public void construct_oneParameter_nonExistantClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantTestDynamicObjectPath, + TestDynamicObject.class, + new Class[] {int.class}, + new Object[] {1} + ) + ); + } + + @Test + public void construct_oneParameter_nonExistantStaticInnerClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantStaticInnerTestDynamicObjectPath, + TestDynamicObject.class, + new Class[] {int.class}, + new Object[] {1} + ) + ); + } + + @Test + public void construct_oneParameter_nonExistantInnerClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantInnerTestDynamicObjectPath, + TestDynamicObject.class, + new Class[] {int.class}, + new Object[] {1} + ) + ); + } + @Test public void construct_manyParameters() { //TODO From c5c2100111ddb9db48684e7f2717c7a571a6c113 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 17 Jul 2026 01:01:18 +0100 Subject: [PATCH 099/162] Many parameters and up and down cast attempts --- .../ReflectiveClassConstructorTests.java | 260 +++++++++++++++++- .../TestDynamicObjectSubclass.java | 24 ++ 2 files changed, 277 insertions(+), 7 deletions(-) create mode 100644 src/test/java/test_aids/storage_entities/TestDynamicObjectSubclass.java diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index 14c33ca..72b59b1 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -1,10 +1,15 @@ package component_construction.storage.dynamic_loading; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; + import test_aids.storage_entities.TestDynamicObject; -import test_aids.storage_entities.TestDynamicObject.*; +import test_aids.storage_entities.TestDynamicObject.InnerTestDynamicObject; +import test_aids.storage_entities.TestDynamicObject.StaticInnerTestDynamicObject; +import test_aids.storage_entities.TestDynamicObjectSubclass; public class ReflectiveClassConstructorTests { @@ -346,12 +351,253 @@ public void construct_oneParameter_nonExistantInnerClass() throws ClassNotFoundE } @Test - public void construct_manyParameters() { - //TODO + public void construct_manyParameters_class_correctParams() throws ClassNotFoundException { + TestDynamicObject expectedObject = new TestDynamicObject(); + expectedObject.a = 1; + expectedObject.b = "Test"; + + TestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObject.class, + new Class[] {int.class, String.class}, + new Object[] {expectedObject.a, expectedObject.b} + ); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_manyParameters_staticInnerClass_correctParams() throws ClassNotFoundException { + StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); + expectedObject.e = 1; + expectedObject.f = "Test"; + + StaticInnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + StaticInnerTestDynamicObject.class.getName(), + StaticInnerTestDynamicObject.class, + new Class[] {int.class, String.class}, + new Object[] {expectedObject.e, expectedObject.f} + ); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_manyParameters_innerClass_correctParams() throws ClassNotFoundException { + TestDynamicObject parentObject = new TestDynamicObject(); + InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); + expectedObject.c = 1; + expectedObject.d = "Test"; + + InnerTestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + InnerTestDynamicObject.class.getName(), + InnerTestDynamicObject.class, + new Class[] { + parentObject.getClass(), + int.class, + String.class + }, + new Object[] { + parentObject, + expectedObject.c, + expectedObject.d + } + ); + + assertEquals(expectedObject, actualObject); + } + + @Test + public void construct_manyParameters_class_falseBooleanType() throws ClassNotFoundException { + TestDynamicObject expectedObject = new TestDynamicObject(); + expectedObject.a = 1; + expectedObject.b = "Test"; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObject.class, + new Class[] {boolean.class, String.class}, + new Object[] {expectedObject.a, expectedObject.b} + ) + ); + } + + @Test + public void construct_manyParameters_staticInnerClass_falseBooleanType() throws ClassNotFoundException { + StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); + expectedObject.e = 1; + expectedObject.f = "Test"; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + StaticInnerTestDynamicObject.class.getName(), + StaticInnerTestDynamicObject.class, + new Class[] {boolean.class, String.class}, + new Object[] {expectedObject.e, expectedObject.f} + ) + ); + } + + @Test + public void construct_manyParameters_innerClass_falseBooleanType() throws ClassNotFoundException { + TestDynamicObject parentObject = new TestDynamicObject(); + InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); + expectedObject.c = 1; + expectedObject.d = "Test"; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + InnerTestDynamicObject.class.getName(), + InnerTestDynamicObject.class, + new Class[] { + parentObject.getClass(), + boolean.class, + String.class + }, + new Object[] { + parentObject, + expectedObject.c, + expectedObject.d + } + ) + ); + } + + @Test + public void construct_manyParameters_class_falseBooleanParam() throws ClassNotFoundException { + TestDynamicObject expectedObject = new TestDynamicObject(); + expectedObject.a = 1; + expectedObject.b = "Test"; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObject.class, + new Class[] {int.class, String.class}, + new Object[] {false, expectedObject.b} + ) + ); + } + + @Test + public void construct_manyParameters_staticInnerClass_falseBooleanParam() throws ClassNotFoundException { + StaticInnerTestDynamicObject expectedObject = new StaticInnerTestDynamicObject(); + expectedObject.e = 1; + expectedObject.f = "Test"; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + StaticInnerTestDynamicObject.class.getName(), + StaticInnerTestDynamicObject.class, + new Class[] {int.class, String.class}, + new Object[] {false, expectedObject.f} + ) + ); + } + + @Test + public void construct_manyParameters_innerClass_falseBooleanParam() throws ClassNotFoundException { + TestDynamicObject parentObject = new TestDynamicObject(); + InnerTestDynamicObject expectedObject = parentObject.new InnerTestDynamicObject(); + expectedObject.c = 1; + expectedObject.d = "Test"; + + assertThrows(IllegalArgumentException.class, () -> + new ReflectiveClassConstructor() + .construct( + InnerTestDynamicObject.class.getName(), + InnerTestDynamicObject.class, + new Class[] { + parentObject.getClass(), + int.class, + String.class + }, + new Object[] { + parentObject, + false, + expectedObject.d + } + ) + ); + } + + @Test + public void construct_manyParameters_nonExistantClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantTestDynamicObjectPath, + TestDynamicObject.class, + new Class[] {int.class, String.class}, + new Object[] {1, "Test"} + ) + ); } - //TODO: Static and regular inner classes + @Test + public void construct_manyParameters_nonExistantStaticInnerClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantStaticInnerTestDynamicObjectPath, + TestDynamicObject.class, + new Class[] {int.class, String.class}, + new Object[] {1, "Test"} + ) + ); + } - //TODO: Non existant class attempts - //TODO: Load as subclass type + @Test + public void construct_manyParameters_nonExistantInnerClass() throws ClassNotFoundException { + assertThrows(ClassNotFoundException.class, () -> + new ReflectiveClassConstructor() + .construct( + nonExistantInnerTestDynamicObjectPath, + TestDynamicObject.class, + new Class[] {int.class, String.class}, + new Object[] {1, "Test"} + ) + ); + } + + @Test + public void construct_subclassAsTargetType() throws ClassNotFoundException { + TestDynamicObjectSubclass expectedObject = new TestDynamicObjectSubclass( + 1, + "Test", + true + ); + + TestDynamicObject actualObject = new ReflectiveClassConstructor() + .construct( + TestDynamicObjectSubclass.class.getName(), + TestDynamicObject.class, + new Class[] { int.class, String.class, boolean.class }, + new Object[] { expectedObject.a, expectedObject.b, expectedObject.c } + ); + + assertEquals((TestDynamicObject)expectedObject, actualObject); + } + + @Test + public void construct_superclassAsTargetType() throws ClassNotFoundException { + assertThrows(ClassCastException.class, () -> + new ReflectiveClassConstructor() + .construct( + TestDynamicObject.class.getName(), + TestDynamicObjectSubclass.class, + new Class[] { int.class, String.class }, + new Object[] { 1, "Test" } + ) + ); + } } diff --git a/src/test/java/test_aids/storage_entities/TestDynamicObjectSubclass.java b/src/test/java/test_aids/storage_entities/TestDynamicObjectSubclass.java new file mode 100644 index 0000000..4bb66a3 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/TestDynamicObjectSubclass.java @@ -0,0 +1,24 @@ +package test_aids.storage_entities; + +public class TestDynamicObjectSubclass extends TestDynamicObject { + public boolean c; + + public TestDynamicObjectSubclass(int a, String b, boolean c) { + this.a = a; + this.b = b; + this.c = c; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof TestDynamicObjectSubclass)) return false; + + TestDynamicObjectSubclass other = (TestDynamicObjectSubclass)obj; + + if (this.a != other.a) return false; + if (this.b != other.b) return false; + if (this.c != other.c) return false; + + return true; + } +} From 1cd92ad4df6127fe59dc76fe57aa56cee8b4a867 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 19 Jul 2026 13:15:50 +0100 Subject: [PATCH 100/162] ReflectiveClassConstructor exception cleanup and documentation --- .../ReflectiveClassConstructor.java | 74 ++++++++++++++++--- .../ReflectiveClassConstructorTests.java | 7 +- 2 files changed, 64 insertions(+), 17 deletions(-) diff --git a/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java b/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java index fda2c92..58d68e0 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java +++ b/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java @@ -6,10 +6,23 @@ public class ReflectiveClassConstructor { - //TODO: Fix exceptions and add to method declarations - //TODO: Document - - public T construct(String className, Class targetType) throws ClassNotFoundException { + /** + * Constructs an object of the specified name and returns it as the target type, using reflection. + * @param The output target type + * @param className The name of the class to be loaded. Provided following the format provided by {@code someObject.class.getName()} + * @param targetType The specified target output type + * @return The constructed object of the target type + * @throws ClassNotFoundException The specified class could not be found + * @throws IllegalArgumentException One or more of the provided arguments has caused a failure to construct the specifed class + */ + public T construct( + String className, + Class targetType + ) + throws + ClassNotFoundException, + IllegalArgumentException + { return construct( className, targetType, @@ -18,7 +31,27 @@ public T construct(String className, Class targetType) throws ClassNotFou ); } - public T construct(String className, Class targetType, Class parameterType, Object parameter) throws ClassNotFoundException { + /** + * Constructs an object of the specified name and returns it as the target type, using reflection. + * @param The output target type + * @param className The name of the class to be loaded. Provided following the format provided by {@code someObject.class.getName()} + * @param targetType The specified target output type + * @param parameterType The type expected by the constructor for the specified class + * @param parameter The value to be passed to the constructor of the specified class. Note: Inner classes require an additional initial parameter to be a parent object of the outer class + * @return The constructed object of the target type + * @throws ClassNotFoundException The specified class could not be found + * @throws IllegalArgumentException One or more of the provided arguments has caused a failure to construct the specifed class + */ + public T construct( + String className, + Class targetType, + Class parameterType, + Object parameter + ) + throws + ClassNotFoundException, + IllegalArgumentException + { return construct( className, targetType, @@ -27,7 +60,27 @@ public T construct(String className, Class targetType, Class parameter ); } - public T construct(String className, Class targetType, Class[] parameterTypes, Object[] parameters) throws ClassNotFoundException { + /** + * Constructs an object of the specified name and returns it as the target type, using reflection. + * @param The output target type + * @param className The name of the class to be loaded. Provided following the format provided by {@code someObject.class.getName()} + * @param targetType The specified target output type + * @param parameterTypes The types expected by the constructor for the specified class + * @param parameters The values to be passes to the constructor of the specified class. Note: Inner classes require an additional initial parameter to be a parent object of the outer class + * @return The constructed object of the target type + * @throws ClassNotFoundException The specified class could not be found + * @throws IllegalArgumentException One or more of the provided arguments has caused a failure to construct the specifed class + */ + public T construct( + String className, + Class targetType, + Class[] parameterTypes, + Object[] parameters + ) + throws + ClassNotFoundException, + IllegalArgumentException + { try { return Class .forName(className) @@ -51,16 +104,13 @@ public T construct(String className, Class targetType, Class[] paramet ); } catch (IllegalAccessException e) { - throw new RuntimeException("Constructor is private or inaccessible in class: " + className, e); + throw new IllegalArgumentException("Constructor is private or inaccessible in class: " + className, e); } catch (InstantiationException e) { - throw new RuntimeException("Cannot instantiate abstract class or interface: " + className, e); + throw new IllegalArgumentException("Cannot instantiate abstract class or interface: " + className, e); } catch (InvocationTargetException e) { - throw new RuntimeException("The constructor for " + className + " threw an exception", e.getCause()); - } - catch (SecurityException e) { - throw new RuntimeException("Reflection configuration error for class: " + className, e); + throw new IllegalArgumentException("The constructor for " + className + " threw an exception", e.getCause()); } } diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index 72b59b1..c6f2d18 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -1,14 +1,11 @@ package component_construction.storage.dynamic_loading; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import test_aids.storage_entities.TestDynamicObject; -import test_aids.storage_entities.TestDynamicObject.InnerTestDynamicObject; -import test_aids.storage_entities.TestDynamicObject.StaticInnerTestDynamicObject; +import test_aids.storage_entities.TestDynamicObject.*; import test_aids.storage_entities.TestDynamicObjectSubclass; public class ReflectiveClassConstructorTests { From 64add620656c27c8e642369a3193be29e1c6a45e Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 19 Jul 2026 17:31:38 +0100 Subject: [PATCH 101/162] LoaderTests Standard usage --- .../storage/dynamic_loading/LoaderTests.java | 16 +++++++++++++++- .../test_aids/storage_entities/TestObject.java | 3 +++ .../storage_entities/TestObjectLoader.java | 13 +++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/test/java/test_aids/storage_entities/TestObject.java create mode 100644 src/test/java/test_aids/storage_entities/TestObjectLoader.java diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java b/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java index 9959c71..09dd03c 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java @@ -1,5 +1,19 @@ package component_construction.storage.dynamic_loading; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +import org.junit.jupiter.api.Test; +import test_aids.storage_entities.*; + public class LoaderTests { - // TODO + + @Test + @SuppressWarnings("unchecked") + public void construct() { + Loader expectedLoader = new TestObjectLoader(); + Class> loaderClass = (Class>)expectedLoader.getClass(); + + assertDoesNotThrow(() -> Loader.construct(loaderClass)); + } + } diff --git a/src/test/java/test_aids/storage_entities/TestObject.java b/src/test/java/test_aids/storage_entities/TestObject.java new file mode 100644 index 0000000..5c58b7e --- /dev/null +++ b/src/test/java/test_aids/storage_entities/TestObject.java @@ -0,0 +1,3 @@ +package test_aids.storage_entities; + +public record TestObject(int a) {} diff --git a/src/test/java/test_aids/storage_entities/TestObjectLoader.java b/src/test/java/test_aids/storage_entities/TestObjectLoader.java new file mode 100644 index 0000000..d856a9f --- /dev/null +++ b/src/test/java/test_aids/storage_entities/TestObjectLoader.java @@ -0,0 +1,13 @@ +package test_aids.storage_entities; + +import component_construction.storage.dynamic_loading.Loader; +import storage.storage_values.StorageValue; + +public class TestObjectLoader implements Loader { + + @Override + public TestObject produce(StorageValue loadValue) { + return new TestObject((int)loadValue.getValue()); + } + +} From 02f87a719b5bf2558cab72b378bc9465b1f575ad Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 19 Jul 2026 23:51:21 +0100 Subject: [PATCH 102/162] LoaderTests basic and missing required constructor --- .../storage/dynamic_loading/Loader.java | 10 +++++++--- .../MissingEmptyConstructorException.java | 10 ++++++++++ .../storage/dynamic_loading/LoaderTests.java | 17 ++++++++++++----- .../IncorrectlyFormedLoader.java | 17 +++++++++++++++++ 4 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 src/main/java/component_construction/storage/exceptions/MissingEmptyConstructorException.java create mode 100644 src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java diff --git a/src/main/java/component_construction/storage/dynamic_loading/Loader.java b/src/main/java/component_construction/storage/dynamic_loading/Loader.java index a0a872c..52092dd 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/Loader.java +++ b/src/main/java/component_construction/storage/dynamic_loading/Loader.java @@ -1,6 +1,8 @@ package component_construction.storage.dynamic_loading; import java.lang.reflect.InvocationTargetException; + +import component_construction.storage.exceptions.MissingEmptyConstructorException; import component_construction.storage.factories.Factory; public interface Loader extends Factory { @@ -10,13 +12,15 @@ public static Loader construct(Class> loaderClass) { return loaderClass .getConstructor() .newInstance(); - } + } + catch (NoSuchMethodException e) { + throw new MissingEmptyConstructorException(loaderClass); + } catch ( InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException - | NoSuchMethodException + | InvocationTargetException e ) { throw new RuntimeException(); //TODO: Custom error diff --git a/src/main/java/component_construction/storage/exceptions/MissingEmptyConstructorException.java b/src/main/java/component_construction/storage/exceptions/MissingEmptyConstructorException.java new file mode 100644 index 0000000..4c1a84c --- /dev/null +++ b/src/main/java/component_construction/storage/exceptions/MissingEmptyConstructorException.java @@ -0,0 +1,10 @@ +package component_construction.storage.exceptions; + +import component_construction.storage.dynamic_loading.Loader; + +public class MissingEmptyConstructorException extends RuntimeException { + + public MissingEmptyConstructorException(Class> loaderClass) { + super("The specified Loaded \"" + loaderClass.getName() + "\" is missing a required default/empty constructor"); + } +} diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java b/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java index 09dd03c..8a2bbfc 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java @@ -1,19 +1,26 @@ package component_construction.storage.dynamic_loading; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - +import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; + +import component_construction.storage.exceptions.MissingEmptyConstructorException; import test_aids.storage_entities.*; public class LoaderTests { - + @Test @SuppressWarnings("unchecked") public void construct() { - Loader expectedLoader = new TestObjectLoader(); - Class> loaderClass = (Class>)expectedLoader.getClass(); + Class> loaderClass = (Class>)(Class)TestObjectLoader.class; assertDoesNotThrow(() -> Loader.construct(loaderClass)); } + @Test + @SuppressWarnings("unchecked") + public void construct_IncorrectlyFormedLoader() { + Class> loaderClass = (Class>)(Class)IncorrectlyFormedLoader.class; + + assertThrows(MissingEmptyConstructorException.class, () -> Loader.construct(loaderClass)); + } } diff --git a/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java b/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java new file mode 100644 index 0000000..7c84c60 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java @@ -0,0 +1,17 @@ +package test_aids.storage_entities; + +import component_construction.storage.dynamic_loading.Loader; +import storage.storage_values.StorageValue; + +public class IncorrectlyFormedLoader implements Loader { + + public IncorrectlyFormedLoader(int a) { + // Exists only to prevent empty constructor call + } + + @Override + public Boolean produce(StorageValue loadValue) { + return true; + } + +} From c634188ad1d75c457478110732a3fab4613ae241 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 20 Jul 2026 00:00:57 +0100 Subject: [PATCH 103/162] Loader and LoaderTest cleanup --- .../storage/dynamic_loading/Loader.java | 4 ++-- .../storage/dynamic_loading/LoaderTests.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/component_construction/storage/dynamic_loading/Loader.java b/src/main/java/component_construction/storage/dynamic_loading/Loader.java index 52092dd..bb7ee29 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/Loader.java +++ b/src/main/java/component_construction/storage/dynamic_loading/Loader.java @@ -7,7 +7,7 @@ public interface Loader extends Factory { - public static Loader construct(Class> loaderClass) { + public static Loader construct(Class> loaderClass) throws MissingEmptyConstructorException, IllegalArgumentException { try { return loaderClass .getConstructor() @@ -23,7 +23,7 @@ public static Loader construct(Class> loaderClass) { | InvocationTargetException e ) { - throw new RuntimeException(); //TODO: Custom error + throw new IllegalArgumentException(e); } } diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java b/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java index 8a2bbfc..2909123 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java @@ -23,4 +23,5 @@ public void construct_IncorrectlyFormedLoader() { assertThrows(MissingEmptyConstructorException.class, () -> Loader.construct(loaderClass)); } + } From 594ce3337e53abf8c838331cc55f1119ba84fcfe Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 24 Jul 2026 22:20:53 +0100 Subject: [PATCH 104/162] Better IncorrectlyFormedLoader constructor privatisation --- .../test_aids/storage_entities/IncorrectlyFormedLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java b/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java index 7c84c60..3f12d4b 100644 --- a/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java +++ b/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java @@ -5,7 +5,7 @@ public class IncorrectlyFormedLoader implements Loader { - public IncorrectlyFormedLoader(int a) { + private IncorrectlyFormedLoader() { // Exists only to prevent empty constructor call } From 144ad16ec286aaf566b2c0b0803ac6711c71a40b Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 24 Jul 2026 23:14:16 +0100 Subject: [PATCH 105/162] Initial loadableBy tests --- .../dynamic_loading/LoadableByTests.java | 29 ++++++++++++++++++- .../loadableby_entities/GenericLoader.java | 18 ++++++++++++ .../loadableby_entities/LoadableObject.java | 6 ++++ .../NonLoadableObject.java | 6 ++++ .../loadableby_entities/StandardLoader.java | 13 +++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/LoadableObject.java create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/NonLoadableObject.java create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/StandardLoader.java diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java b/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java index 4cd6e9d..1652058 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java @@ -1,5 +1,32 @@ package component_construction.storage.dynamic_loading; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +import test_aids.storage_entities.loadableby_entities.*; + public class LoadableByTests { - // TODO + + @Test + @SuppressWarnings("unchecked") + public void getTargetLoader() { + Class>> loadableBy = (Class>>)(Class)LoadableObject.class; + Class> actualLoader = LoadableBy.getTargetLoader(loadableBy); + + assertEquals(StandardLoader.class, actualLoader); + } + + @Test + @SuppressWarnings("unchecked") + public void getTargetLoader_GenericLoader() { + Class>> loadableBy = (Class>>)(Class)GenericLoader.class; + + assertThrows(IllegalArgumentException.class, () -> LoadableBy.getTargetLoader(loadableBy)); + } + + // Additional interfaces of loadable class + // Another interface without generics - implements Runnable, LoadablyBy + // Another interface with generics - implements AnotherInterface, LoadablyBy + + // Nested Loaders? } diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java new file mode 100644 index 0000000..9dca51a --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java @@ -0,0 +1,18 @@ +package test_aids.storage_entities.loadableby_entities; + +import component_construction.storage.dynamic_loading.Loader; +import storage.storage_values.StorageValue; + +public class GenericLoader implements Loader { + + private GenericLoader() { + // Exists only to prevent empty constructor call + } + + @Override + @SuppressWarnings("unchecked") + public T produce(StorageValue loadValue) { + return (T)new NonLoadableObject((int)loadValue.getValue()); + } + +} diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/LoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/LoadableObject.java new file mode 100644 index 0000000..17c7571 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/LoadableObject.java @@ -0,0 +1,6 @@ +package test_aids.storage_entities.loadableby_entities; + +import component_construction.storage.dynamic_loading.LoadableBy; + +public record LoadableObject(int a) implements LoadableBy {} + diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/NonLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/NonLoadableObject.java new file mode 100644 index 0000000..17c2fbb --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/NonLoadableObject.java @@ -0,0 +1,6 @@ +package test_aids.storage_entities.loadableby_entities; + +import component_construction.storage.dynamic_loading.LoadableBy; + +public record NonLoadableObject(int a) implements LoadableBy> {} + diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/StandardLoader.java b/src/test/java/test_aids/storage_entities/loadableby_entities/StandardLoader.java new file mode 100644 index 0000000..ef8a34b --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/StandardLoader.java @@ -0,0 +1,13 @@ +package test_aids.storage_entities.loadableby_entities; + +import component_construction.storage.dynamic_loading.Loader; +import storage.storage_values.StorageValue; + +public class StandardLoader implements Loader { + + @Override + public LoadableObject produce(StorageValue loadValue) { + return new LoadableObject((int)loadValue.getValue()); + } + +} From 7ae28641b1f6cce91e5d6686abbb36dc09c2a0d1 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 26 Jul 2026 17:05:13 +0100 Subject: [PATCH 106/162] LoadableBy tests for classes with additional interfaces --- .../dynamic_loading/LoadableByTests.java | 29 +++++++++++++++++-- .../ConcretisedGenericTestLoadableObject.java | 5 ++++ .../GenercicTestInterface.java | 8 +++++ .../GenericTestInterface.java | 3 ++ .../GenericTestLoadableObject.java | 5 ++++ .../loadableby_entities/TestInterface.java | 3 ++ .../TestLoadableObject.java | 5 ++++ 7 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/ConcretisedGenericTestLoadableObject.java create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/GenercicTestInterface.java create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestInterface.java create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestLoadableObject.java create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/TestInterface.java create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/TestLoadableObject.java diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java b/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java index 1652058..3cf5e56 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java @@ -24,9 +24,32 @@ public void getTargetLoader_GenericLoader() { assertThrows(IllegalArgumentException.class, () -> LoadableBy.getTargetLoader(loadableBy)); } - // Additional interfaces of loadable class - // Another interface without generics - implements Runnable, LoadablyBy - // Another interface with generics - implements AnotherInterface, LoadablyBy + @Test + @SuppressWarnings("unchecked") + public void getTargetLoader_additionalInterface() { + Class>> loadableBy = (Class>>)(Class)TestLoadableObject.class; + Class> actualLoader = LoadableBy.getTargetLoader(loadableBy); + + assertEquals(StandardLoader.class, actualLoader); + } + + @Test + @SuppressWarnings("unchecked") + public void getTargetLoader_additionalGenericInterface() { + Class>>> loadableBy = (Class>>>)(Class)GenericTestLoadableObject.class; + Class>> actualLoader = LoadableBy.getTargetLoader(loadableBy); + + assertEquals(StandardLoader.class, actualLoader); + } + + @Test + @SuppressWarnings("unchecked") + public void getTargetLoader_additionalConcretisedGenericInterface() { + Class>>> loadableBy = (Class>>>)(Class)ConcretisedGenericTestLoadableObject.class; + Class>> actualLoader = LoadableBy.getTargetLoader(loadableBy); + + assertEquals(StandardLoader.class, actualLoader); + } // Nested Loaders? } diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/ConcretisedGenericTestLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/ConcretisedGenericTestLoadableObject.java new file mode 100644 index 0000000..448171d --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/ConcretisedGenericTestLoadableObject.java @@ -0,0 +1,5 @@ +package test_aids.storage_entities.loadableby_entities; + +import component_construction.storage.dynamic_loading.LoadableBy; + +public class ConcretisedGenericTestLoadableObject extends StandardLoader implements GenercicTestInterface, LoadableBy {} \ No newline at end of file diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/GenercicTestInterface.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenercicTestInterface.java new file mode 100644 index 0000000..a10a6a5 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenercicTestInterface.java @@ -0,0 +1,8 @@ +package test_aids.storage_entities.loadableby_entities; + +/** + * GenercicTestInterface + */ +public interface GenercicTestInterface { + +} diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestInterface.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestInterface.java new file mode 100644 index 0000000..2e33787 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestInterface.java @@ -0,0 +1,3 @@ +package test_aids.storage_entities.loadableby_entities; + +public interface GenericTestInterface {} diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestLoadableObject.java new file mode 100644 index 0000000..6dbd8c6 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestLoadableObject.java @@ -0,0 +1,5 @@ +package test_aids.storage_entities.loadableby_entities; + +import component_construction.storage.dynamic_loading.LoadableBy; + +public class GenericTestLoadableObject extends StandardLoader implements GenercicTestInterface, LoadableBy {} \ No newline at end of file diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/TestInterface.java b/src/test/java/test_aids/storage_entities/loadableby_entities/TestInterface.java new file mode 100644 index 0000000..c16c9ae --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/TestInterface.java @@ -0,0 +1,3 @@ +package test_aids.storage_entities.loadableby_entities; + +public interface TestInterface {} diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/TestLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/TestLoadableObject.java new file mode 100644 index 0000000..8a433a1 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/TestLoadableObject.java @@ -0,0 +1,5 @@ +package test_aids.storage_entities.loadableby_entities; + +import component_construction.storage.dynamic_loading.LoadableBy; + +public class TestLoadableObject extends StandardLoader implements TestInterface, LoadableBy {} \ No newline at end of file From 7a83abdb4f7c9b61f6e57a1cbc96477362405364 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 26 Jul 2026 18:27:26 +0100 Subject: [PATCH 107/162] LoadableBy getTargetLoader rework --- .../storage/dynamic_loading/LoadableBy.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java b/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java index 1891d47..1eaacc6 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java +++ b/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java @@ -2,35 +2,41 @@ import java.lang.reflect.*; +import component_construction.storage.exceptions.IncorrectlyFormattedException; + /** * A class specifying a designated loader for the current class. * Loaders will be loaded using reflection. - * @param + * @param The concrete Loader class */ public interface LoadableBy> { @SuppressWarnings("unchecked") - public static Class> getTargetLoader(Class>> loadableByClass) { + public static > Class getTargetLoader(Class> loadableByClass) throws IllegalArgumentException, IncorrectlyFormattedException { + ParameterizedType loadableByInterface = null; + for (Type currentInterface : loadableByClass.getGenericInterfaces()) { if (!(currentInterface instanceof ParameterizedType)) continue; ParameterizedType paramType = (ParameterizedType) currentInterface; - if (!paramType.getRawType().equals(LoadableBy.class)) continue; - Type actualTypeArgument = paramType.getActualTypeArguments()[0]; - - //TODO: Scrutinise below code, along with warning supression - - // If T is a standard class/interface, return it - if (actualTypeArgument instanceof Class) - return (Class>) actualTypeArgument; - // Handle nested generic loaders (e.g., MyLoader) - else if (actualTypeArgument instanceof ParameterizedType) - return (Class>) ((ParameterizedType) actualTypeArgument).getRawType(); + loadableByInterface = paramType; + break; } - throw new IllegalArgumentException("Class " + loadableByClass.getName() + " does not directly implement LoadableBy with a concrete generic type."); - } + if (loadableByInterface == null) + throw new IllegalArgumentException("Class " + loadableByClass.getName() + " does not directly implement LoadableBy."); + + Type actualTypeArgument = loadableByInterface.getActualTypeArguments()[0]; + if (actualTypeArgument instanceof ParameterizedType) + throw new IncorrectlyFormattedException("Class " + loadableByClass.getName() + " provides a nested generic loader (" + actualTypeArgument.getTypeName() + "). Loaders must be direct, concrete Class objects."); + + if (!(actualTypeArgument instanceof Class)) + throw new IncorrectlyFormattedException("Class " + loadableByClass.getName() + " provides an abstract or unbound type token (" + actualTypeArgument.getTypeName() + "). The loader must be a direct, concrete Class object."); + + return (Class) actualTypeArgument; + } + } From 87974ab8df550d787e71ebfd1758baf28b5969d0 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 26 Jul 2026 18:43:58 +0100 Subject: [PATCH 108/162] Generic Loader tests --- .../IncorrectlyFormattedException.java | 8 ++++++++ .../storage/dynamic_loading/LoadableByTests.java | 16 ++++++++++++---- .../loadableby_entities/GenericLoader.java | 2 +- ...bject.java => GenericallyLoadableObject.java} | 2 +- .../WildcardLoadableObject.java | 6 ++++++ 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/main/java/component_construction/storage/exceptions/IncorrectlyFormattedException.java rename src/test/java/test_aids/storage_entities/loadableby_entities/{NonLoadableObject.java => GenericallyLoadableObject.java} (52%) create mode 100644 src/test/java/test_aids/storage_entities/loadableby_entities/WildcardLoadableObject.java diff --git a/src/main/java/component_construction/storage/exceptions/IncorrectlyFormattedException.java b/src/main/java/component_construction/storage/exceptions/IncorrectlyFormattedException.java new file mode 100644 index 0000000..58dcd77 --- /dev/null +++ b/src/main/java/component_construction/storage/exceptions/IncorrectlyFormattedException.java @@ -0,0 +1,8 @@ +package component_construction.storage.exceptions; + +public class IncorrectlyFormattedException extends RuntimeException { + + public IncorrectlyFormattedException(String message) { + super(message); + } +} diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java b/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java index 3cf5e56..431b359 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; +import component_construction.storage.exceptions.IncorrectlyFormattedException; import test_aids.storage_entities.loadableby_entities.*; public class LoadableByTests { @@ -18,10 +19,18 @@ public void getTargetLoader() { @Test @SuppressWarnings("unchecked") - public void getTargetLoader_GenericLoader() { - Class>> loadableBy = (Class>>)(Class)GenericLoader.class; + public void getTargetLoader_genericLoader() { + Class>> loadableBy = (Class>>)(Class)GenericallyLoadableObject.class; - assertThrows(IllegalArgumentException.class, () -> LoadableBy.getTargetLoader(loadableBy)); + assertThrows(IncorrectlyFormattedException.class, () -> LoadableBy.getTargetLoader(loadableBy)); + } + + @Test + @SuppressWarnings("unchecked") + public void getTargetLoader_wildcardLoader() { + Class>> loadableBy = (Class>>)(Class)WildcardLoadableObject.class; + + assertThrows(IncorrectlyFormattedException.class, () -> LoadableBy.getTargetLoader(loadableBy)); } @Test @@ -51,5 +60,4 @@ public void getTargetLoader_additionalConcretisedGenericInterface() { assertEquals(StandardLoader.class, actualLoader); } - // Nested Loaders? } diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java index 9dca51a..d71c96c 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java @@ -12,7 +12,7 @@ private GenericLoader() { @Override @SuppressWarnings("unchecked") public T produce(StorageValue loadValue) { - return (T)new NonLoadableObject((int)loadValue.getValue()); + return (T)new GenericallyLoadableObject((int)loadValue.getValue()); } } diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/NonLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericallyLoadableObject.java similarity index 52% rename from src/test/java/test_aids/storage_entities/loadableby_entities/NonLoadableObject.java rename to src/test/java/test_aids/storage_entities/loadableby_entities/GenericallyLoadableObject.java index 17c2fbb..3175abb 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/NonLoadableObject.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericallyLoadableObject.java @@ -2,5 +2,5 @@ import component_construction.storage.dynamic_loading.LoadableBy; -public record NonLoadableObject(int a) implements LoadableBy> {} +public record GenericallyLoadableObject(int a) implements LoadableBy> {} diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/WildcardLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/WildcardLoadableObject.java new file mode 100644 index 0000000..4c206f0 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/WildcardLoadableObject.java @@ -0,0 +1,6 @@ +package test_aids.storage_entities.loadableby_entities; + +import component_construction.storage.dynamic_loading.*; + +public record WildcardLoadableObject(int a) implements LoadableBy> {} + From 9b4c7fe82befa68e3251b12c074f2936b9fe58e6 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 2 Aug 2026 00:01:56 +0100 Subject: [PATCH 109/162] Unfinished StorableCustomCompilerFactory changes --- .../StorableCustomCompilerFactory.java | 161 +++++++++--------- 1 file changed, 85 insertions(+), 76 deletions(-) diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 4eaaa2d..eb6ca1d 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -1,96 +1,40 @@ package component_construction.storage.factories; import java.util.*; + import component_construction.custom_components.*; -import component_construction.storage.*; +import component_construction.storage.StorableCustomCompiler; import component_construction.storage.dynamic_loading.*; import storage.external_interfaces.Loadable; import storage.storage_values.*; public class StorableCustomCompilerFactory implements Loader { protected ReflectiveClassConstructor reflectiveClassLoader = new ReflectiveClassConstructor(); - protected FactoryRepository lexicalAnalyserFactoryRepository = new FactoryRepository<>(); - protected FactoryRepository syntaxAnalyserFactoryRepository = new FactoryRepository<>(); - protected FactoryRepository codeGeneratorFactoryRepository = new FactoryRepository<>(); + protected Map> lexicalAnalyserFactoryRepository = new HashMap<>(); + protected Map> syntaxAnalyserFactoryRepository = new HashMap<>(); + protected Map> codeGeneratorFactoryRepository = new HashMap<>(); - @SuppressWarnings("unchecked") @Override // TODO: Explain requirements for storage/loading public StorableCustomCompiler produce(StorageValue loadValue) { MapStorageValue map = (MapStorageValue) loadValue; Map> mapValue = map.getValue(); - CustomLexicalAnalyser customLexicalAnalyser; - CustomSyntaxAnalyser customSyntaxAnalyser; - CustomCodeGenerator customCodeGenerator; - - //TODO: Abstract common code into easy to use method - try { - ComponentDescription lexicalAnalyserDescription = getComponentDescription(mapValue.get("lexicalAnalyser")); - - if (lexicalAnalyserFactoryRepository.containsKey(lexicalAnalyserDescription.name())) { - customLexicalAnalyser = lexicalAnalyserFactoryRepository.instantiate( - lexicalAnalyserDescription.name(), - lexicalAnalyserDescription.description() - ); - } - - Class clazz = (Class) Class - .forName(lexicalAnalyserDescription.name()) - .asSubclass(CustomLexicalAnalyser.class); - - if (LoadableBy.class.isAssignableFrom(clazz)) { - Class>> loadableBy = (Class>>) clazz.asSubclass(LoadableBy.class); - Class> targetLoader = LoadableBy.getTargetLoader(loadableBy); - Loader loader = Loader.construct(targetLoader); - customLexicalAnalyser = loader.produce(lexicalAnalyserDescription.description()); - } - else if (Loadable.class.isAssignableFrom(clazz)) { - customLexicalAnalyser = reflectiveClassLoader.construct( - lexicalAnalyserDescription.name(), - CustomLexicalAnalyser.class - ); - - ((Loadable)customLexicalAnalyser) - .load(lexicalAnalyserDescription.description()); - } - // Use constructor - else { - customLexicalAnalyser = reflectiveClassLoader.construct( - lexicalAnalyserDescription.name(), - CustomLexicalAnalyser.class, - StorageValue.class, - lexicalAnalyserDescription.description() - ); - } - } - catch (ClassNotFoundException e) { //TODO: Check for other exceptions - throw new RuntimeException(e); // TODO: Create custom exception - } - - try { - ComponentDescription syntaxAnalyserDescription = getComponentDescription(mapValue.get("syntaxAnalyser")); - - customSyntaxAnalyser = syntaxAnalyserFactoryRepository.instantiate( - syntaxAnalyserDescription.name(), - syntaxAnalyserDescription.description() - ); - } - catch (ClassNotFoundException e) { - throw new RuntimeException(e); // TODO: Create custom exception - } - - try { - ComponentDescription codeGeneratorDescription = getComponentDescription(mapValue.get("syntaxAnalyser")); - - customCodeGenerator = codeGeneratorFactoryRepository.instantiate( - codeGeneratorDescription.name(), - codeGeneratorDescription.description() - ); - } - catch (ClassNotFoundException e) { - throw new RuntimeException(e); // TODO: Create custom exception - } + CustomLexicalAnalyser customLexicalAnalyser = buildComponent( + lexicalAnalyserFactoryRepository, + mapValue.get("lexicalAnalyser"), + CustomLexicalAnalyser.class + ); + CustomSyntaxAnalyser customSyntaxAnalyser = buildComponent( + syntaxAnalyserFactoryRepository, + mapValue.get("syntaxAnalyser"), + CustomSyntaxAnalyser.class + ); + CustomCodeGenerator customCodeGenerator = buildComponent( + codeGeneratorFactoryRepository, + mapValue.get("codeGenerator"), + CustomCodeGenerator.class + ); return new StorableCustomCompiler( customLexicalAnalyser, @@ -110,4 +54,69 @@ protected ComponentDescription getComponentDescription(StorageValue descripti } protected record ComponentDescription(String name, ListStorageValue description) {} + + @SuppressWarnings("unchecked") + protected T buildComponent(Map> repository, StorageValue description, Class selectedType) { + ComponentDescription componentDescription = getComponentDescription(description); + + if (repository.containsKey(componentDescription.name())) { + return repository + .get(componentDescription.name()) + .produce(componentDescription.description()); + } + + Class clazz; + + try { + clazz = (Class) Class + .forName(componentDescription.name()) + .asSubclass(selectedType); + } + catch (ClassNotFoundException e) { + //TODO + throw new RuntimeException(); + } + catch (ClassCastException e) { + //TODO + throw new RuntimeException(); + } + + if (LoadableBy.class.isAssignableFrom(clazz)) { + Class>> loadableBy = (Class>>) clazz.asSubclass(LoadableBy.class); + Class> targetLoader = LoadableBy.getTargetLoader(loadableBy); + Loader loader = Loader.construct(targetLoader); + return loader.produce(componentDescription.description()); + } + + if (Loadable.class.isAssignableFrom(clazz)) { + T component; + + try { + component = reflectiveClassLoader.construct( + componentDescription.name(), + selectedType + ); + } catch (ClassNotFoundException | IllegalArgumentException e) { + //TODO + throw new RuntimeException(); + } + + component.load(componentDescription.description()); + + return component; + } + + // Use constructor + try { + return reflectiveClassLoader.construct( + componentDescription.name(), + selectedType, + StorageValue.class, + componentDescription.description() + ); + } catch (ClassNotFoundException | IllegalArgumentException e) { + //TODO + throw new RuntimeException(); + } + } } From 4c59af06034cbc497a4807d0a2be6030c66a1ad9 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 8 Aug 2026 00:27:35 +0100 Subject: [PATCH 110/162] Start of StorableCustomCompilerFactoryTests --- .../StorableCustomCompilerFactory.java | 57 ++++++---- .../ReflectiveClassConstructorTests.java | 4 +- .../StorableCustomCompilerFactoryTests.java | 102 +++++++++++++++++- .../TestCustomCodeGenerator.java | 24 +++++ .../TestCustomLexicalAnalyser.java | 24 +++++ .../TestCustomSyntaxAnalyser.java | 25 +++++ 6 files changed, 209 insertions(+), 27 deletions(-) create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index eb6ca1d..bf09468 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -14,50 +14,61 @@ public class StorableCustomCompilerFactory implements Loader> syntaxAnalyserFactoryRepository = new HashMap<>(); protected Map> codeGeneratorFactoryRepository = new HashMap<>(); + public StorableCustomCompilerFactory addLexicalAnalyserFactory(String name, Factory factory) { + lexicalAnalyserFactoryRepository.put(name, factory); + return this; + } + + public StorableCustomCompilerFactory addSyntaxAnalyserFactory(String name, Factory factory) { + syntaxAnalyserFactoryRepository.put(name, factory); + return this; + } + + public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factory factory) { + codeGeneratorFactoryRepository.put(name, factory); + return this; + } + @Override // TODO: Explain requirements for storage/loading public StorableCustomCompiler produce(StorageValue loadValue) { MapStorageValue map = (MapStorageValue) loadValue; Map> mapValue = map.getValue(); - CustomLexicalAnalyser customLexicalAnalyser = buildComponent( - lexicalAnalyserFactoryRepository, - mapValue.get("lexicalAnalyser"), - CustomLexicalAnalyser.class - ); - CustomSyntaxAnalyser customSyntaxAnalyser = buildComponent( - syntaxAnalyserFactoryRepository, - mapValue.get("syntaxAnalyser"), - CustomSyntaxAnalyser.class - ); - CustomCodeGenerator customCodeGenerator = buildComponent( - codeGeneratorFactoryRepository, - mapValue.get("codeGenerator"), - CustomCodeGenerator.class - ); - return new StorableCustomCompiler( - customLexicalAnalyser, - customSyntaxAnalyser, - customCodeGenerator + buildComponent( + lexicalAnalyserFactoryRepository, + mapValue.get("lexicalAnalyser"), + CustomLexicalAnalyser.class + ), + buildComponent( + syntaxAnalyserFactoryRepository, + mapValue.get("syntaxAnalyser"), + CustomSyntaxAnalyser.class + ), + buildComponent( + codeGeneratorFactoryRepository, + mapValue.get("codeGenerator"), + CustomCodeGenerator.class + ) ); } // TODO: Handle errors - protected ComponentDescription getComponentDescription(StorageValue description) { + protected ComponentInformation getComponentDescription(StorageValue description) { List> entry = ((ListStorageValue)description).getValue(); - return new ComponentDescription( + return new ComponentInformation( ((StringStorageValue)entry.get(0)).getValue(), (ListStorageValue)entry.get(1) ); } - protected record ComponentDescription(String name, ListStorageValue description) {} + protected record ComponentInformation(String name, ListStorageValue description) {} @SuppressWarnings("unchecked") protected T buildComponent(Map> repository, StorageValue description, Class selectedType) { - ComponentDescription componentDescription = getComponentDescription(description); + ComponentInformation componentDescription = getComponentDescription(description); if (repository.containsKey(componentDescription.name())) { return repository diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java index c6f2d18..0268a9d 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java @@ -1,12 +1,10 @@ package component_construction.storage.dynamic_loading; import static org.junit.jupiter.api.Assertions.*; - import org.junit.jupiter.api.Test; -import test_aids.storage_entities.TestDynamicObject; +import test_aids.storage_entities.*; import test_aids.storage_entities.TestDynamicObject.*; -import test_aids.storage_entities.TestDynamicObjectSubclass; public class ReflectiveClassConstructorTests { diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index d0f6816..4567886 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -1,5 +1,105 @@ package component_construction.storage.factories; +import static org.junit.jupiter.api.Assertions.*; +import java.util.*; +import org.junit.jupiter.api.Test; + +import component_construction.custom_components.*; +import storage.storage_values.*; +import test_aids.storage_entities.custom_components.*; + public class StorableCustomCompilerFactoryTests { - // TODO + + protected record TypedComponent(String name, ListStorageValue description, Factory factory) {} + + protected static final TypedComponent lexicalComponent = new TypedComponent<>( + "TestCustomLexicalAnalyser", + new ListStorageValue( + new StringStorageValue("TestCustomLexicalAnalyser") + ), + (description) -> { + assertEquals( + new ListStorageValue( + new StringStorageValue("TestCustomLexicalAnalyser") + ), + description + ); + + return new TestCustomLexicalAnalyser(); + } + ); + + protected static final TypedComponent syntaxComponent = new TypedComponent<>( + "TestCustomSyntaxAnalyser", + new ListStorageValue( + new StringStorageValue("TestCustomSyntaxAnalyser") + ), + (description) -> { + assertEquals( + new ListStorageValue( + new StringStorageValue("TestCustomSyntaxAnalyser") + ), + description + ); + + return new TestCustomSyntaxAnalyser(); + } + ); + + protected static final TypedComponent codeGeneratorComponent = new TypedComponent<>( + "TestCustomCodeGenerator", + new ListStorageValue( + new StringStorageValue("TestCustomCodeGenerator") + ), + (description) -> { + assertEquals( + new ListStorageValue( + new StringStorageValue("TestCustomCodeGenerator") + ), + description + ); + + return new TestCustomCodeGenerator(); + } + ); + + @Test + public void produce() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addLexicalAnalyserFactory( + lexicalComponent.name(), + lexicalComponent.factory() + ) + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + assertDoesNotThrow(() -> factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue("TestCustomLexicalAnalyser"), + lexicalComponent.description() + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue("TestCustomSyntaxAnalyser"), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue("TestCustomCodeGenerator"), + codeGeneratorComponent.description() + ) + )) + )); + } + + //In repositories + //LoadableBy components + //Loadable components + //Default/Empty constructor without interfaces + //Incorrect StorageValue type (i.e. not Map in produce()) } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java new file mode 100644 index 0000000..4b1175a --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java @@ -0,0 +1,24 @@ +package test_aids.storage_entities.custom_components; + +import component_construction.custom_components.CustomCodeGenerator; +import storage.storage_values.StorageValue; +import syntax_analysis.parsing.ParseState; + +public class TestCustomCodeGenerator implements CustomCodeGenerator { + + @Override + public String generate(ParseState parseRoot) { + throw new UnsupportedOperationException("Unimplemented method 'generate'"); + } + + @Override + public StorageValue getStorageRepresentation() { + throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); + } + + @Override + public void load(StorageValue data) { + throw new UnsupportedOperationException("Unimplemented method 'load'"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java new file mode 100644 index 0000000..a7677bb --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java @@ -0,0 +1,24 @@ +package test_aids.storage_entities.custom_components; + +import component_construction.custom_components.CustomLexicalAnalyser; +import grammar_objects.Token; +import storage.storage_values.StorageValue; + +public class TestCustomLexicalAnalyser implements CustomLexicalAnalyser { + + @Override + public Token[] analyse(String sentence) { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + + @Override + public StorageValue getStorageRepresentation() { + throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); + } + + @Override + public void load(StorageValue data) { + throw new UnsupportedOperationException("Unimplemented method 'load'"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java new file mode 100644 index 0000000..91f7f46 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java @@ -0,0 +1,25 @@ +package test_aids.storage_entities.custom_components; + +import component_construction.custom_components.CustomSyntaxAnalyser; +import grammar_objects.Token; +import storage.storage_values.StorageValue; +import syntax_analysis.parsing.*; + +public class TestCustomSyntaxAnalyser implements CustomSyntaxAnalyser { + + @Override + public ParseState analyse(Token[] inputTokens) throws ParseFailedException { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + + @Override + public StorageValue getStorageRepresentation() { + throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); + } + + @Override + public void load(StorageValue data) { + throw new UnsupportedOperationException("Unimplemented method 'load'"); + } + +} From 861e247bcef60d542f957d62210d1d3771cb890b Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 11 Aug 2026 23:31:02 +0100 Subject: [PATCH 111/162] Produce components with and without using existing class names --- .../StorableCustomCompilerFactoryTests.java | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index 4567886..94d7fb5 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -13,14 +13,14 @@ public class StorableCustomCompilerFactoryTests { protected record TypedComponent(String name, ListStorageValue description, Factory factory) {} protected static final TypedComponent lexicalComponent = new TypedComponent<>( - "TestCustomLexicalAnalyser", + "TestLexicalAnalyser", new ListStorageValue( - new StringStorageValue("TestCustomLexicalAnalyser") + new StringStorageValue("TestLexicalAnalyser") ), (description) -> { assertEquals( new ListStorageValue( - new StringStorageValue("TestCustomLexicalAnalyser") + new StringStorageValue("TestLexicalAnalyser") ), description ); @@ -30,14 +30,14 @@ protected record TypedComponent(String name, ListStorageValue description, Fa ); protected static final TypedComponent syntaxComponent = new TypedComponent<>( - "TestCustomSyntaxAnalyser", + "TestSyntaxAnalyser", new ListStorageValue( - new StringStorageValue("TestCustomSyntaxAnalyser") + new StringStorageValue("TestSyntaxAnalyser") ), (description) -> { assertEquals( new ListStorageValue( - new StringStorageValue("TestCustomSyntaxAnalyser") + new StringStorageValue("TestSyntaxAnalyser") ), description ); @@ -47,14 +47,14 @@ protected record TypedComponent(String name, ListStorageValue description, Fa ); protected static final TypedComponent codeGeneratorComponent = new TypedComponent<>( - "TestCustomCodeGenerator", + "TestCodeGenerator", new ListStorageValue( - new StringStorageValue("TestCustomCodeGenerator") + new StringStorageValue("TestCodeGenerator") ), (description) -> { assertEquals( new ListStorageValue( - new StringStorageValue("TestCustomCodeGenerator") + new StringStorageValue("TestCodeGenerator") ), description ); @@ -79,6 +79,40 @@ public void produce() { codeGeneratorComponent.factory() ); + assertDoesNotThrow(() -> factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue(lexicalComponent.name()), + lexicalComponent.description() + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + )); + } + + @Test + public void produce_existingNamedClassComponents() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addLexicalAnalyserFactory( + "TestCustomLexicalAnalyser", + lexicalComponent.factory() + ) + .addSyntaxAnalyserFactory( + "TestCustomSyntaxAnalyser", + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + "TestCustomCodeGenerator", + codeGeneratorComponent.factory() + ); + assertDoesNotThrow(() -> factory.produce( new MapStorageValue(Map.of( "lexicalAnalyser", new ListStorageValue( @@ -96,8 +130,7 @@ public void produce() { )) )); } - - //In repositories + //LoadableBy components //Loadable components //Default/Empty constructor without interfaces From 9e981c7739285cdaa5f4bae59fa9b0538122d2ec Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Wed, 12 Aug 2026 00:13:35 +0100 Subject: [PATCH 112/162] LoadableBy usage for CustomLexicalAnalyser reflective loading --- .../StorableCustomCompilerFactoryTests.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index 94d7fb5..9eec20b 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -7,6 +7,7 @@ import component_construction.custom_components.*; import storage.storage_values.*; import test_aids.storage_entities.custom_components.*; +import test_aids.storage_entities.custom_components.loadableBy.LoadableByCustomLexicalAnalyser; public class StorableCustomCompilerFactoryTests { @@ -130,8 +131,37 @@ public void produce_existingNamedClassComponents() { )) )); } + + @Test + public void produce_LoadableByLexicalAnalyser() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue(LoadableByCustomLexicalAnalyser.class.getName()), + lexicalComponent.description() + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + ); + } - //LoadableBy components //Loadable components //Default/Empty constructor without interfaces //Incorrect StorageValue type (i.e. not Map in produce()) From e0b74f77534e451ce857a8c598c1b1ca4ec9c1eb Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 21 Aug 2026 23:09:05 +0100 Subject: [PATCH 113/162] ReflectivelyLoadable --- .../StorableCustomCompilerFactory.java | 17 ++++++++++++----- .../dynamic_loading/ReflectivelyLoadable.java | 9 +++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index bf09468..ae9caa1 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -5,7 +5,6 @@ import component_construction.custom_components.*; import component_construction.storage.StorableCustomCompiler; import component_construction.storage.dynamic_loading.*; -import storage.external_interfaces.Loadable; import storage.storage_values.*; public class StorableCustomCompilerFactory implements Loader { @@ -65,9 +64,17 @@ protected ComponentInformation getComponentDescription(StorageValue descripti } protected record ComponentInformation(String name, ListStorageValue description) {} - + @SuppressWarnings("unchecked") - protected T buildComponent(Map> repository, StorageValue description, Class selectedType) { + /** + * Components must be: registered with a factory; LoadableBy; Loadable; Or, have a constructor taking the exact parameters provided. + * @param + * @param repository + * @param description + * @param selectedType + * @return + */ + protected T buildComponent(Map> repository, StorageValue description, Class selectedType) { ComponentInformation componentDescription = getComponentDescription(description); if (repository.containsKey(componentDescription.name())) { @@ -99,7 +106,7 @@ protected T buildComponent(Map> reposito return loader.produce(componentDescription.description()); } - if (Loadable.class.isAssignableFrom(clazz)) { + if (ReflectivelyLoadable.class.isAssignableFrom(clazz)) { T component; try { @@ -112,7 +119,7 @@ protected T buildComponent(Map> reposito throw new RuntimeException(); } - component.load(componentDescription.description()); + ((ReflectivelyLoadable)component).load(componentDescription.description()); return component; } diff --git a/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java b/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java new file mode 100644 index 0000000..ac69fec --- /dev/null +++ b/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java @@ -0,0 +1,9 @@ +package component_construction.storage.dynamic_loading; + +import storage.external_interfaces.Loadable; + +/** + * Classes of this type must have a constructor that may be used to reflectively construct objects. + * ReflectivelyLoadable + */ +public interface ReflectivelyLoadable extends Loadable {} \ No newline at end of file From c708fb30fc928f4bee1063e0d3698aba4bc2ab39 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 21 Aug 2026 23:09:52 +0100 Subject: [PATCH 114/162] Update FactoryRepository and tests --- .../storage/factories/FactoryRepository.java | 16 ++++--- .../factories/FactoryRepositoryTest.java | 42 +++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 src/test/java/component_construction/storage/factories/FactoryRepositoryTest.java diff --git a/src/main/java/component_construction/storage/factories/FactoryRepository.java b/src/main/java/component_construction/storage/factories/FactoryRepository.java index 95d2467..3c2dcd5 100644 --- a/src/main/java/component_construction/storage/factories/FactoryRepository.java +++ b/src/main/java/component_construction/storage/factories/FactoryRepository.java @@ -4,20 +4,26 @@ import storage.storage_values.StorageValue; +//TODO: Remove? public class FactoryRepository { protected Map> factories = new HashMap<>(); /** - * - * @param name - * @param generator + * Adds a factory to this repository + * @param name The name of the factory + * @param factory The factory * @return This object for method chaining */ - public FactoryRepository addFactory(String name, Factory generator) { - factories.put(name, generator); + public FactoryRepository addFactory(String name, Factory factory) { + factories.put(name, factory); return this; } + /** + * Checks if this repository contains a factory for a given key + * @param name The name/key of the factory + * @return Whether or not this repository contains the specified key + */ public boolean containsKey(String name) { return factories.containsKey(name); } diff --git a/src/test/java/component_construction/storage/factories/FactoryRepositoryTest.java b/src/test/java/component_construction/storage/factories/FactoryRepositoryTest.java new file mode 100644 index 0000000..7b92cd9 --- /dev/null +++ b/src/test/java/component_construction/storage/factories/FactoryRepositoryTest.java @@ -0,0 +1,42 @@ +package component_construction.storage.factories; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +public class FactoryRepositoryTest { + protected Factory testFactory1 = (loadValue) -> loadValue.getValue().toString(); + protected Factory testFactory2 = (loadValue) -> loadValue.getValue().toString() + "2"; + + @Test + public void addFactory() { + FactoryRepository repository = new FactoryRepository(); + + FactoryRepository actualRepository = assertDoesNotThrow( + () -> repository.addFactory("testFactory1", testFactory1) + ); + + assertEquals(repository, actualRepository); + } + + @Test + public void containsKey_key1() { + FactoryRepository repository = new FactoryRepository(); + repository.addFactory("testFactory1", testFactory1); + repository.addFactory("testFactory2", testFactory2); + + assertTrue(repository.containsKey("testFactory1")); + } + + @Test + public void containsKey_key2() { + FactoryRepository repository = new FactoryRepository(); + repository.addFactory("testFactory1", testFactory1); + repository.addFactory("testFactory2", testFactory2); + + assertTrue(repository.containsKey("testFactory2")); + } + + //TODO: Consider, why not use a factory? + // instantiate +} From c33ca5b4794d5d40f8b901879c05cb0bd71eca50 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 21 Aug 2026 23:11:11 +0100 Subject: [PATCH 115/162] CustomLexicalAnalyser test aids --- .../LoadableCustomLexicalAnalyser.java | 28 +++++++++++++++++++ .../LoadableByCustomLexicalAnalyser.java | 27 ++++++++++++++++++ ...LoadableByCustomLexicalAnalyserLoader.java | 16 +++++++++++ 3 files changed, 71 insertions(+) create mode 100644 src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java new file mode 100644 index 0000000..c0e7093 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java @@ -0,0 +1,28 @@ +package test_aids.storage_entities.custom_components; + +import component_construction.custom_components.CustomLexicalAnalyser; +import grammar_objects.Token; +import storage.external_interfaces.Loadable; +import storage.storage_values.StorageValue; + +public class LoadableCustomLexicalAnalyser implements CustomLexicalAnalyser, Loadable { + + @Override + public Token[] analyse(String sentence) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + + @Override + public StorageValue getStorageRepresentation() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); + } + + @Override + public void load(StorageValue data) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'load'"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java new file mode 100644 index 0000000..ba0ed7c --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java @@ -0,0 +1,27 @@ +package test_aids.storage_entities.custom_components.loadableBy; + +import component_construction.custom_components.CustomLexicalAnalyser; +import component_construction.storage.dynamic_loading.LoadableBy; +import grammar_objects.Token; +import storage.storage_values.StorageValue; + +public class LoadableByCustomLexicalAnalyser implements CustomLexicalAnalyser, LoadableBy { + + public StorageValue loadedData; + + @Override + public Token[] analyse(String sentence) { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + + @Override + public StorageValue getStorageRepresentation() { + throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); + } + + @Override + public void load(StorageValue data) { + loadedData = data; + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java new file mode 100644 index 0000000..14a574f --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java @@ -0,0 +1,16 @@ +package test_aids.storage_entities.custom_components.loadableBy; + +import component_construction.storage.dynamic_loading.Loader; +import storage.storage_values.StorageValue; + +public class LoadableByCustomLexicalAnalyserLoader implements Loader { + + @Override + public LoadableByCustomLexicalAnalyser produce(StorageValue loadValue) { + LoadableByCustomLexicalAnalyser lex = new LoadableByCustomLexicalAnalyser(); + lex.load(loadValue); + + return lex; + } + +} From bc751d3d2e46d2b9e1530839e7951996194bcac2 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 21 Aug 2026 23:42:03 +0100 Subject: [PATCH 116/162] Removal of CustomX components By not forcing these interfaces there is more flexibility in storage/loading of components, at the expense of some understandability. Components may implement Storable but not some loading mechanism or vice-versa, this could be confusing but easily rectified with good documentation, validation and exception handling. --- .../CustomCodeGenerator.java | 6 ----- .../CustomLexicalAnalyser.java | 6 ----- .../CustomSyntaxAnalyser.java | 6 ----- .../StorableCustomCompilerFactory.java | 22 +++++++++-------- .../storage/StorableCustomCompiler.java | 23 ++++++++++++------ .../StorableCustomCompilerBuilder.java | 24 +++++++------------ .../LoadableCustomLexicalAnalyser.java | 10 ++------ .../TestCustomCodeGenerator.java | 15 ++---------- .../TestCustomLexicalAnalyser.java | 15 ++---------- .../TestCustomSyntaxAnalyser.java | 15 ++---------- .../LoadableByCustomLexicalAnalyser.java | 12 +++------- ...LoadableByCustomLexicalAnalyserLoader.java | 4 ++-- 12 files changed, 49 insertions(+), 109 deletions(-) delete mode 100644 src/main/java/component_construction/custom_components/CustomCodeGenerator.java delete mode 100644 src/main/java/component_construction/custom_components/CustomLexicalAnalyser.java delete mode 100644 src/main/java/component_construction/custom_components/CustomSyntaxAnalyser.java diff --git a/src/main/java/component_construction/custom_components/CustomCodeGenerator.java b/src/main/java/component_construction/custom_components/CustomCodeGenerator.java deleted file mode 100644 index f71a3b7..0000000 --- a/src/main/java/component_construction/custom_components/CustomCodeGenerator.java +++ /dev/null @@ -1,6 +0,0 @@ -package component_construction.custom_components; - -import code_generation.CodeGenerator; -import storage.external_interfaces.StorableAndLoadable; - -public interface CustomCodeGenerator extends CodeGenerator, StorableAndLoadable {} diff --git a/src/main/java/component_construction/custom_components/CustomLexicalAnalyser.java b/src/main/java/component_construction/custom_components/CustomLexicalAnalyser.java deleted file mode 100644 index dd7c05d..0000000 --- a/src/main/java/component_construction/custom_components/CustomLexicalAnalyser.java +++ /dev/null @@ -1,6 +0,0 @@ -package component_construction.custom_components; - -import lexical_analysis.LexicalAnalyser; -import storage.external_interfaces.StorableAndLoadable; - -public interface CustomLexicalAnalyser extends LexicalAnalyser, StorableAndLoadable {} \ No newline at end of file diff --git a/src/main/java/component_construction/custom_components/CustomSyntaxAnalyser.java b/src/main/java/component_construction/custom_components/CustomSyntaxAnalyser.java deleted file mode 100644 index e02f857..0000000 --- a/src/main/java/component_construction/custom_components/CustomSyntaxAnalyser.java +++ /dev/null @@ -1,6 +0,0 @@ -package component_construction.custom_components; - -import syntax_analysis.SyntaxAnalyser; -import storage.external_interfaces.StorableAndLoadable; - -public interface CustomSyntaxAnalyser extends SyntaxAnalyser, StorableAndLoadable {} \ No newline at end of file diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index ae9caa1..480cb1f 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -2,28 +2,30 @@ import java.util.*; -import component_construction.custom_components.*; +import code_generation.CodeGenerator; import component_construction.storage.StorableCustomCompiler; import component_construction.storage.dynamic_loading.*; +import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; +import syntax_analysis.SyntaxAnalyser; public class StorableCustomCompilerFactory implements Loader { protected ReflectiveClassConstructor reflectiveClassLoader = new ReflectiveClassConstructor(); - protected Map> lexicalAnalyserFactoryRepository = new HashMap<>(); - protected Map> syntaxAnalyserFactoryRepository = new HashMap<>(); - protected Map> codeGeneratorFactoryRepository = new HashMap<>(); + protected Map> lexicalAnalyserFactoryRepository = new HashMap<>(); + protected Map> syntaxAnalyserFactoryRepository = new HashMap<>(); + protected Map> codeGeneratorFactoryRepository = new HashMap<>(); - public StorableCustomCompilerFactory addLexicalAnalyserFactory(String name, Factory factory) { + public StorableCustomCompilerFactory addLexicalAnalyserFactory(String name, Factory factory) { lexicalAnalyserFactoryRepository.put(name, factory); return this; } - public StorableCustomCompilerFactory addSyntaxAnalyserFactory(String name, Factory factory) { + public StorableCustomCompilerFactory addSyntaxAnalyserFactory(String name, Factory factory) { syntaxAnalyserFactoryRepository.put(name, factory); return this; } - public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factory factory) { + public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factory factory) { codeGeneratorFactoryRepository.put(name, factory); return this; } @@ -38,17 +40,17 @@ public StorableCustomCompiler produce(StorageValue loadValue) { buildComponent( lexicalAnalyserFactoryRepository, mapValue.get("lexicalAnalyser"), - CustomLexicalAnalyser.class + LexicalAnalyser.class ), buildComponent( syntaxAnalyserFactoryRepository, mapValue.get("syntaxAnalyser"), - CustomSyntaxAnalyser.class + SyntaxAnalyser.class ), buildComponent( codeGeneratorFactoryRepository, mapValue.get("codeGenerator"), - CustomCodeGenerator.class + CodeGenerator.class ) ); } diff --git a/src/main/java/component_construction/storage/StorableCustomCompiler.java b/src/main/java/component_construction/storage/StorableCustomCompiler.java index f2ce0cc..188bda6 100644 --- a/src/main/java/component_construction/storage/StorableCustomCompiler.java +++ b/src/main/java/component_construction/storage/StorableCustomCompiler.java @@ -1,18 +1,27 @@ package component_construction.storage; import java.util.Map; + +import code_generation.CodeGenerator; import component_construction.custom_components.*; import component_construction.storage.dynamic_loading.LoadableBy; import component_construction.storage.factories.StorableCustomCompilerFactory; +import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; import storage.storage_values.*; +import syntax_analysis.SyntaxAnalyser; public class StorableCustomCompiler extends CustomCompiler implements Storable, LoadableBy { - public StorableCustomCompiler( - CustomLexicalAnalyser lexicalAnalyser, - CustomSyntaxAnalyser syntaxAnalyser, - CustomCodeGenerator codeGenerator + public < + L extends LexicalAnalyser & Storable, + S extends SyntaxAnalyser & Storable, + C extends CodeGenerator & Storable + > + StorableCustomCompiler( + LexicalAnalyser lexicalAnalyser, + SyntaxAnalyser syntaxAnalyser, + CodeGenerator codeGenerator ) { super(lexicalAnalyser, syntaxAnalyser, codeGenerator); } @@ -22,15 +31,15 @@ public MapStorageValue getStorageRepresentation() { return new MapStorageValue(Map.of( "lexicalAnalyser", new ListStorageValue( new StringStorageValue(lexicalAnalyser.getClass().getName()), - ((CustomLexicalAnalyser)lexicalAnalyser).getStorageRepresentation() + ((Storable)lexicalAnalyser).getStorageRepresentation() ), "syntaxAnalyser", new ListStorageValue( new StringStorageValue(syntaxAnalyser.getClass().getName()), - ((CustomSyntaxAnalyser)syntaxAnalyser).getStorageRepresentation() + ((Storable)syntaxAnalyser).getStorageRepresentation() ), "codeGenerator", new ListStorageValue( new StringStorageValue(codeGenerator.getClass().getName()), - ((CustomCodeGenerator)codeGenerator).getStorageRepresentation() + ((Storable)codeGenerator).getStorageRepresentation() ) )); } diff --git a/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java b/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java index ecbcfde..88d4ecf 100644 --- a/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java +++ b/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java @@ -21,23 +21,15 @@ public StorableCustomCompiler createCompiler() { GrammarParts parts = grammar.getParts(); - LexicalAnalyser lexicalAnalyser = lexicalAnalyserFactory.produceAnalyser( - whitespaceDelimiters, - stronglyReservedWords, - weaklyReservedWords, - dynamicTokenRegex - ); - SyntaxAnalyser syntaxAnalyser = syntaxAnalyserFactory.produceAnalyser(parts); - CodeGenerator codeGenerator = codeGeneratorFactory.produceGenerator(ruleConvertor); - - if(!(lexicalAnalyser instanceof CustomLexicalAnalyser)) throw new RuntimeException("TODO"); //TODO - if(!(syntaxAnalyser instanceof CustomSyntaxAnalyser)) throw new RuntimeException("TODO"); //TODO - if(!(codeGenerator instanceof CustomCodeGenerator)) throw new RuntimeException("TODO"); //TODO - return new StorableCustomCompiler( - (CustomLexicalAnalyser)lexicalAnalyser, - (CustomSyntaxAnalyser)syntaxAnalyser, - (CustomCodeGenerator)codeGenerator + lexicalAnalyserFactory.produceAnalyser( + whitespaceDelimiters, + stronglyReservedWords, + weaklyReservedWords, + dynamicTokenRegex + ), + syntaxAnalyserFactory.produceAnalyser(parts), + codeGeneratorFactory.produceGenerator(ruleConvertor) ); } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java index c0e7093..008cdd5 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java @@ -1,23 +1,17 @@ package test_aids.storage_entities.custom_components; -import component_construction.custom_components.CustomLexicalAnalyser; import grammar_objects.Token; +import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Loadable; import storage.storage_values.StorageValue; -public class LoadableCustomLexicalAnalyser implements CustomLexicalAnalyser, Loadable { +public class LoadableCustomLexicalAnalyser implements LexicalAnalyser, Loadable { @Override public Token[] analyse(String sentence) { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } - - @Override - public StorageValue getStorageRepresentation() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); - } @Override public void load(StorageValue data) { diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java index 4b1175a..aafd55e 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java @@ -1,24 +1,13 @@ package test_aids.storage_entities.custom_components; -import component_construction.custom_components.CustomCodeGenerator; -import storage.storage_values.StorageValue; +import code_generation.CodeGenerator; import syntax_analysis.parsing.ParseState; -public class TestCustomCodeGenerator implements CustomCodeGenerator { +public class TestCustomCodeGenerator implements CodeGenerator { @Override public String generate(ParseState parseRoot) { throw new UnsupportedOperationException("Unimplemented method 'generate'"); } - - @Override - public StorageValue getStorageRepresentation() { - throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); - } - - @Override - public void load(StorageValue data) { - throw new UnsupportedOperationException("Unimplemented method 'load'"); - } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java index a7677bb..fb85d9d 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java @@ -1,24 +1,13 @@ package test_aids.storage_entities.custom_components; -import component_construction.custom_components.CustomLexicalAnalyser; import grammar_objects.Token; -import storage.storage_values.StorageValue; +import lexical_analysis.LexicalAnalyser; -public class TestCustomLexicalAnalyser implements CustomLexicalAnalyser { +public class TestCustomLexicalAnalyser implements LexicalAnalyser { @Override public Token[] analyse(String sentence) { throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } - - @Override - public StorageValue getStorageRepresentation() { - throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); - } - - @Override - public void load(StorageValue data) { - throw new UnsupportedOperationException("Unimplemented method 'load'"); - } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java index 91f7f46..0699d3d 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java @@ -1,25 +1,14 @@ package test_aids.storage_entities.custom_components; -import component_construction.custom_components.CustomSyntaxAnalyser; import grammar_objects.Token; -import storage.storage_values.StorageValue; +import syntax_analysis.SyntaxAnalyser; import syntax_analysis.parsing.*; -public class TestCustomSyntaxAnalyser implements CustomSyntaxAnalyser { +public class TestCustomSyntaxAnalyser implements SyntaxAnalyser { @Override public ParseState analyse(Token[] inputTokens) throws ParseFailedException { throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } - - @Override - public StorageValue getStorageRepresentation() { - throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); - } - - @Override - public void load(StorageValue data) { - throw new UnsupportedOperationException("Unimplemented method 'load'"); - } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java index ba0ed7c..d57a62f 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java @@ -1,11 +1,11 @@ package test_aids.storage_entities.custom_components.loadableBy; -import component_construction.custom_components.CustomLexicalAnalyser; import component_construction.storage.dynamic_loading.LoadableBy; import grammar_objects.Token; +import lexical_analysis.LexicalAnalyser; import storage.storage_values.StorageValue; -public class LoadableByCustomLexicalAnalyser implements CustomLexicalAnalyser, LoadableBy { +public class LoadableByCustomLexicalAnalyser implements LexicalAnalyser, LoadableBy { public StorageValue loadedData; @@ -14,13 +14,7 @@ public Token[] analyse(String sentence) { throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } - @Override - public StorageValue getStorageRepresentation() { - throw new UnsupportedOperationException("Unimplemented method 'getStorageRepresentation'"); - } - - @Override - public void load(StorageValue data) { + public void loadInternals(StorageValue data) { loadedData = data; } diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java index 14a574f..ccb358a 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java @@ -8,8 +8,8 @@ public class LoadableByCustomLexicalAnalyserLoader implements Loader loadValue) { LoadableByCustomLexicalAnalyser lex = new LoadableByCustomLexicalAnalyser(); - lex.load(loadValue); - + lex.loadInternals(loadValue); + return lex; } From a1646c3948ef19d5b04248cf6972a746752d72e9 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 22 Aug 2026 00:08:02 +0100 Subject: [PATCH 117/162] ReflectivelyLoadable LexicalAnalyser test --- .../custom_components/LoadableCustomLexicalAnalyser.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java index 008cdd5..95a0b7f 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java @@ -1,11 +1,13 @@ package test_aids.storage_entities.custom_components; +import component_construction.storage.dynamic_loading.ReflectivelyLoadable; import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; -import storage.external_interfaces.Loadable; import storage.storage_values.StorageValue; -public class LoadableCustomLexicalAnalyser implements LexicalAnalyser, Loadable { +public class LoadableCustomLexicalAnalyser implements LexicalAnalyser, ReflectivelyLoadable { + + public StorageValue loadedData; @Override public Token[] analyse(String sentence) { @@ -15,8 +17,7 @@ public Token[] analyse(String sentence) { @Override public void load(StorageValue data) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'load'"); + loadedData = data; } } From 553a817584277d639477ab57a9a2c57844a9da00 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 22 Aug 2026 00:24:09 +0100 Subject: [PATCH 118/162] StorableCompilerBuilder imports fix --- .../storage/builders/StorableCustomCompilerBuilder.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java b/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java index 88d4ecf..0d16a52 100644 --- a/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java +++ b/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java @@ -1,12 +1,8 @@ package component_construction.storage.builders; -import code_generation.CodeGenerator; import component_construction.builders.CompilerBuilderTemplate; -import component_construction.custom_components.*; import component_construction.storage.StorableCustomCompiler; import grammar_objects.GrammarParts; -import lexical_analysis.LexicalAnalyser; -import syntax_analysis.SyntaxAnalyser; public class StorableCustomCompilerBuilder extends CompilerBuilderTemplate { From 89010c930dc26b08f425ce328e1aa37ff68bbb6e Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 24 Aug 2026 23:15:13 +0100 Subject: [PATCH 119/162] Constructable components Loadable reflectively via constructor. Includes removal of unnecessary classes (which appeared in previous commits) --- .../StorableCustomCompilerFactory.java | 2 +- .../StorableCustomCompilerFactoryTests.java | 75 +++++++++++++++++-- .../ConstructableLexicalAnalyser.java | 20 +++++ .../LoadableCustomLexicalAnalyser.java | 1 - 4 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 src/test/java/test_aids/storage_entities/custom_components/ConstructableLexicalAnalyser.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 480cb1f..f1464f2 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -69,7 +69,7 @@ protected record ComponentInformation(String name, ListStorageValue description) @SuppressWarnings("unchecked") /** - * Components must be: registered with a factory; LoadableBy; Loadable; Or, have a constructor taking the exact parameters provided. + * Components must be: registered with a factory; LoadableBy; Loadable; Or, have a constructor taking StorageValue. * @param * @param repository * @param description diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index 9eec20b..c03f9cc 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -1,11 +1,14 @@ package component_construction.storage.factories; import static org.junit.jupiter.api.Assertions.*; + import java.util.*; import org.junit.jupiter.api.Test; -import component_construction.custom_components.*; +import code_generation.CodeGenerator; +import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; +import syntax_analysis.SyntaxAnalyser; import test_aids.storage_entities.custom_components.*; import test_aids.storage_entities.custom_components.loadableBy.LoadableByCustomLexicalAnalyser; @@ -13,7 +16,7 @@ public class StorableCustomCompilerFactoryTests { protected record TypedComponent(String name, ListStorageValue description, Factory factory) {} - protected static final TypedComponent lexicalComponent = new TypedComponent<>( + protected static final TypedComponent lexicalComponent = new TypedComponent<>( "TestLexicalAnalyser", new ListStorageValue( new StringStorageValue("TestLexicalAnalyser") @@ -30,7 +33,7 @@ protected record TypedComponent(String name, ListStorageValue description, Fa } ); - protected static final TypedComponent syntaxComponent = new TypedComponent<>( + protected static final TypedComponent syntaxComponent = new TypedComponent<>( "TestSyntaxAnalyser", new ListStorageValue( new StringStorageValue("TestSyntaxAnalyser") @@ -47,7 +50,7 @@ protected record TypedComponent(String name, ListStorageValue description, Fa } ); - protected static final TypedComponent codeGeneratorComponent = new TypedComponent<>( + protected static final TypedComponent codeGeneratorComponent = new TypedComponent<>( "TestCodeGenerator", new ListStorageValue( new StringStorageValue("TestCodeGenerator") @@ -162,7 +165,67 @@ public void produce_LoadableByLexicalAnalyser() { ); } - //Loadable components - //Default/Empty constructor without interfaces + @Test + public void produce_LoadableLexicalAnalyser() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue(LoadableCustomLexicalAnalyser.class.getName()), + lexicalComponent.description() + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + ); + } + + @Test + public void produce_ConstructableLexicalAnalyser() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue(ConstructableLexicalAnalyser.class.getName()), + new ListStorageValue(List.of()) + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + ); + } + //Incorrect StorageValue type (i.e. not Map in produce()) + + //Check internal (loaded) values } diff --git a/src/test/java/test_aids/storage_entities/custom_components/ConstructableLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/ConstructableLexicalAnalyser.java new file mode 100644 index 0000000..91810f3 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/ConstructableLexicalAnalyser.java @@ -0,0 +1,20 @@ +package test_aids.storage_entities.custom_components; + +import grammar_objects.Token; +import lexical_analysis.LexicalAnalyser; +import storage.storage_values.StorageValue; + +public class ConstructableLexicalAnalyser implements LexicalAnalyser { + + public StorageValue loadedData; + + public ConstructableLexicalAnalyser(StorageValue data) { + loadedData = data; + } + + @Override + public Token[] analyse(String sentence) { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java index 95a0b7f..70d15cc 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java @@ -11,7 +11,6 @@ public class LoadableCustomLexicalAnalyser implements LexicalAnalyser, Reflectiv @Override public Token[] analyse(String sentence) { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } From e5b2f6b76047a5eca79128e58736a7053963534d Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 25 Aug 2026 20:58:45 +0100 Subject: [PATCH 120/162] Documentation improvement for StorableCustomCompilerFactory --- .../StorableCustomCompilerFactory.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index f1464f2..3870295 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -31,7 +31,19 @@ public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factor } @Override - // TODO: Explain requirements for storage/loading + /** + * Builds a StorableCustomCompiler from a map of specified StorageValues. + * + * The format of the loadValue for loading StorableCustomCompiler components is a @{code MapStorageValue} containing the keys "lexicalAnalyser", "syntaxAnalyser", and "codeGenerator" mapped to their respective {@code StorageValue} descriptions + * + * In order to be loadable, components must be one of: + * - registered with a factory + * - LoadableBy + * - Loadable + * - Have a constructor taking a single StorageValue parameter + * @param loadValue The StorageValue to be used for building a StorableCustomCompiler + * @return The produced {@code StorableCustomCompiler} + */ public StorableCustomCompiler produce(StorageValue loadValue) { MapStorageValue map = (MapStorageValue) loadValue; Map> mapValue = map.getValue(); @@ -69,12 +81,13 @@ protected record ComponentInformation(String name, ListStorageValue description) @SuppressWarnings("unchecked") /** - * Components must be: registered with a factory; LoadableBy; Loadable; Or, have a constructor taking StorageValue. - * @param - * @param repository - * @param description - * @param selectedType - * @return + * Builds a component with the provided description. + * Components must be: registered with a factory; LoadableBy; Loadable; Or, have a constructor taking a single StorageValue parameter. + * @param The abstract type of the component + * @param repository The repository to query for registered factories for the specific component type + * @param description The description with which to load the component with + * @param selectedType The subclass with which to produce and use the component + * @return The built component */ protected T buildComponent(Map> repository, StorageValue description, Class selectedType) { ComponentInformation componentDescription = getComponentDescription(description); From f4e7abc5d6103ff3dcd78f326f216c23f0bcbfa3 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 25 Aug 2026 21:39:56 +0100 Subject: [PATCH 121/162] Incorrect format no map storage value --- .../StorableCustomCompilerFactory.java | 22 +++++++++- .../exceptions/IncorrectLoadValueFormat.java | 8 ++++ .../StorableCustomCompilerFactoryTests.java | 40 ++++++++++++++++++- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 3870295..d6c57c2 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -5,6 +5,7 @@ import code_generation.CodeGenerator; import component_construction.storage.StorableCustomCompiler; import component_construction.storage.dynamic_loading.*; +import component_construction.storage.exceptions.IncorrectLoadValueFormat; import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; @@ -45,8 +46,7 @@ public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factor * @return The produced {@code StorableCustomCompiler} */ public StorableCustomCompiler produce(StorageValue loadValue) { - MapStorageValue map = (MapStorageValue) loadValue; - Map> mapValue = map.getValue(); + Map> mapValue = tryGetMapValue(loadValue); return new StorableCustomCompiler( buildComponent( @@ -67,6 +67,24 @@ public StorableCustomCompiler produce(StorageValue loadValue) { ); } + private Map> tryGetMapValue(StorageValue loadValue) { + MapStorageValue map; + Map> mapValue; + + try { + map = (MapStorageValue) loadValue; + } + catch (ClassCastException e) { + throw new IncorrectLoadValueFormat( + "Map>", + loadValue.getClass().getSimpleName() + ); + } + + mapValue = map.getValue(); + return mapValue; + } + // TODO: Handle errors protected ComponentInformation getComponentDescription(StorageValue description) { List> entry = ((ListStorageValue)description).getValue(); diff --git a/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java b/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java new file mode 100644 index 0000000..ac9c8fd --- /dev/null +++ b/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java @@ -0,0 +1,8 @@ +package component_construction.storage.exceptions; + +public class IncorrectLoadValueFormat extends RuntimeException { + + public IncorrectLoadValueFormat(String expectedFormat, String actualFormat) { + super("A load value was provided in an incorrect format. Expected - " + expectedFormat + ", Actual - " + actualFormat); + } +} diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index c03f9cc..7d6513f 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test; import code_generation.CodeGenerator; +import component_construction.storage.exceptions.IncorrectLoadValueFormat; import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; @@ -225,7 +226,44 @@ public void produce_ConstructableLexicalAnalyser() { ); } - //Incorrect StorageValue type (i.e. not Map in produce()) + @Test + public void produce_incorrectFormat_noMap() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + assertThrows(IncorrectLoadValueFormat.class, () -> factory.produce( + new ListStorageValue(List.of( + new ListStorageValue( + new StringStorageValue("lexicalAnalyser"), + new ListStorageValue( + new StringStorageValue(lexicalComponent.name()), + new ListStorageValue(List.of()) + ) + ), + new ListStorageValue( + new StringStorageValue("syntaxAnalyser"), + new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ) + ), + new ListStorageValue( + new StringStorageValue("codeGenerator"), + new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + ) + )) + )); + } //Check internal (loaded) values } From a08c533e95a8662440e98929f6e1ea7c1a2ca4ac Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 25 Aug 2026 22:58:23 +0100 Subject: [PATCH 122/162] Missing key --- .../StorableCustomCompilerFactory.java | 14 +++++++- .../exceptions/MissingKeyException.java | 26 +++++++++++++++ .../StorableCustomCompilerFactoryTests.java | 33 +++++++++++++++++-- 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 src/main/java/component_construction/storage/exceptions/MissingKeyException.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index d6c57c2..5b0f25f 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -5,7 +5,7 @@ import code_generation.CodeGenerator; import component_construction.storage.StorableCustomCompiler; import component_construction.storage.dynamic_loading.*; -import component_construction.storage.exceptions.IncorrectLoadValueFormat; +import component_construction.storage.exceptions.*; import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; @@ -15,6 +15,11 @@ public class StorableCustomCompilerFactory implements Loader> lexicalAnalyserFactoryRepository = new HashMap<>(); protected Map> syntaxAnalyserFactoryRepository = new HashMap<>(); protected Map> codeGeneratorFactoryRepository = new HashMap<>(); + protected final Set expectedKeys = Set.of( + "lexicalAnalyser", + "syntaxAnalyser", + "codeGenerator" + ); public StorableCustomCompilerFactory addLexicalAnalyserFactory(String name, Factory factory) { lexicalAnalyserFactoryRepository.put(name, factory); @@ -47,6 +52,13 @@ public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factor */ public StorableCustomCompiler produce(StorageValue loadValue) { Map> mapValue = tryGetMapValue(loadValue); + Set keys = mapValue.keySet(); + + if (!keys.containsAll(expectedKeys)) { + Set missingKeys = new HashSet(expectedKeys); + missingKeys.removeAll(keys); + throw new MissingKeyException(missingKeys); + } return new StorableCustomCompiler( buildComponent( diff --git a/src/main/java/component_construction/storage/exceptions/MissingKeyException.java b/src/main/java/component_construction/storage/exceptions/MissingKeyException.java new file mode 100644 index 0000000..8249b1d --- /dev/null +++ b/src/main/java/component_construction/storage/exceptions/MissingKeyException.java @@ -0,0 +1,26 @@ +package component_construction.storage.exceptions; + +import java.util.Collection; +import java.util.stream.Collectors; + +public class MissingKeyException extends RuntimeException { + public Collection missingKeys; + + public MissingKeyException(Collection missingKeys) { + super(); + this.missingKeys = missingKeys; + } + + @Override + public String getMessage() { + if (missingKeys.size() == 1) + return "The key \"" + missingKeys.iterator().next() + "\" is missing"; + + String missingKeysString = missingKeys + .stream() + .map(value -> "\"" + value + "\"") + .collect(Collectors.joining(", ")); + + return "The keys " + missingKeysString + " are missing"; + } +} diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index 7d6513f..a3c7ea7 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -1,12 +1,11 @@ package component_construction.storage.factories; import static org.junit.jupiter.api.Assertions.*; - import java.util.*; import org.junit.jupiter.api.Test; import code_generation.CodeGenerator; -import component_construction.storage.exceptions.IncorrectLoadValueFormat; +import component_construction.storage.exceptions.*; import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; @@ -265,5 +264,35 @@ public void produce_incorrectFormat_noMap() { )); } + @Test + public void produce_incorrectFormat_missingKey() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addLexicalAnalyserFactory( + lexicalComponent.name(), + lexicalComponent.factory() + ) + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + assertThrows(MissingKeyException.class, () -> factory.produce( + new MapStorageValue(Map.of( + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + )); + } + //Check internal (loaded) values } From 514f91a72680d7f034fc91b44b218f545dd7e370 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 25 Aug 2026 23:01:16 +0100 Subject: [PATCH 123/162] Multiple missing keys --- .../StorableCustomCompilerFactoryTests.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index a3c7ea7..f91eec8 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -294,5 +294,31 @@ public void produce_incorrectFormat_missingKey() { )); } + @Test + public void produce_incorrectFormat_multipleMissingKeys() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addLexicalAnalyserFactory( + lexicalComponent.name(), + lexicalComponent.factory() + ) + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + assertThrows(MissingKeyException.class, () -> factory.produce( + new MapStorageValue(Map.of( + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ) + )) + )); + } + //Check internal (loaded) values } From 3f30dfd89bb39e4e67aff056ef91cc37748bb2be Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 25 Aug 2026 23:02:55 +0100 Subject: [PATCH 124/162] Empty input map --- .../StorableCustomCompilerFactoryTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index f91eec8..9ce9ad8 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -320,5 +320,26 @@ public void produce_incorrectFormat_multipleMissingKeys() { )); } + @Test + public void produce_incorrectFormat_emptyMap() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addLexicalAnalyserFactory( + lexicalComponent.name(), + lexicalComponent.factory() + ) + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + assertThrows(MissingKeyException.class, () -> factory.produce( + new MapStorageValue(Map.of()) + )); + } + //Check internal (loaded) values } From f4986693856c6e72427d8fbb77b687f467a798e5 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 25 Aug 2026 23:09:22 +0100 Subject: [PATCH 125/162] Exception documentation and StorableCustomCompilerFactory class documentation --- .../storage/Factories/StorableCustomCompilerFactory.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 5b0f25f..b1ef1e1 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -10,6 +10,9 @@ import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; +/** + * A factory for producing StorableCustomCompilers. + */ public class StorableCustomCompilerFactory implements Loader { protected ReflectiveClassConstructor reflectiveClassLoader = new ReflectiveClassConstructor(); protected Map> lexicalAnalyserFactoryRepository = new HashMap<>(); @@ -49,8 +52,10 @@ public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factor * - Have a constructor taking a single StorageValue parameter * @param loadValue The StorageValue to be used for building a StorableCustomCompiler * @return The produced {@code StorableCustomCompiler} + * @throws IncorrectLoadValueFormat The provided load value was in an incorrect format + * @throws MissingKeyException The provided load value was missing one or more required keys */ - public StorableCustomCompiler produce(StorageValue loadValue) { + public StorableCustomCompiler produce(StorageValue loadValue) throws IncorrectLoadValueFormat, MissingKeyException { Map> mapValue = tryGetMapValue(loadValue); Set keys = mapValue.keySet(); @@ -79,7 +84,7 @@ public StorableCustomCompiler produce(StorageValue loadValue) { ); } - private Map> tryGetMapValue(StorageValue loadValue) { + private Map> tryGetMapValue(StorageValue loadValue) throws IncorrectLoadValueFormat { MapStorageValue map; Map> mapValue; From 8f90518de94cbe58d068aa468193eca5430de13b Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Fri, 28 Aug 2026 23:42:46 +0100 Subject: [PATCH 126/162] Produce Non Existent Component Class --- .../StorableCustomCompilerFactory.java | 6 ++-- .../NonExistentComponentException.java | 8 +++++ .../StorableCustomCompilerFactoryTests.java | 31 ++++++++++++++++++- 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index b1ef1e1..29113d1 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -127,11 +127,10 @@ protected record ComponentInformation(String name, ListStorageValue description) protected T buildComponent(Map> repository, StorageValue description, Class selectedType) { ComponentInformation componentDescription = getComponentDescription(description); - if (repository.containsKey(componentDescription.name())) { + if (repository.containsKey(componentDescription.name())) return repository .get(componentDescription.name()) .produce(componentDescription.description()); - } Class clazz; @@ -141,8 +140,7 @@ protected T buildComponent(Map> repository, StorageValue< .asSubclass(selectedType); } catch (ClassNotFoundException e) { - //TODO - throw new RuntimeException(); + throw new NonExistentComponentException(componentDescription.name()); } catch (ClassCastException e) { //TODO diff --git a/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java b/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java new file mode 100644 index 0000000..7b48b6c --- /dev/null +++ b/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java @@ -0,0 +1,8 @@ +package component_construction.storage.exceptions; + +public class NonExistentComponentException extends RuntimeException { + + public NonExistentComponentException(String attemptedComponentClassName) { + super("The component class \"" + attemptedComponentClassName + "\" could not be found or does not exist. Check the provided component name correctly references the intended class."); + } +} diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index 9ce9ad8..fb0772b 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; import code_generation.CodeGenerator; +import component_construction.storage.StorableCustomCompiler; import component_construction.storage.exceptions.*; import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; @@ -341,5 +342,33 @@ public void produce_incorrectFormat_emptyMap() { )); } - //Check internal (loaded) values + @Test + public void produce_nonExistentComponentClass() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + NonExistentComponentException a = assertThrows(NonExistentComponentException.class, () -> factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue("NonExistantClass"), + new ListStorageValue(List.of()) + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + )); + } } From 99cdc7fdae1537f0dfed6de59f67a1ab79812a12 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 29 Aug 2026 00:47:33 +0100 Subject: [PATCH 127/162] Produce Non Component Class and exception documentation --- .../StorableCustomCompilerFactory.java | 20 ++++++++--- .../exceptions/ComponentCastException.java | 8 +++++ .../StorableCustomCompilerFactoryTests.java | 34 ++++++++++++++++++- .../TestCustomFalseLexicalAnalyser.java | 14 ++++++++ 4 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 src/main/java/component_construction/storage/exceptions/ComponentCastException.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomFalseLexicalAnalyser.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 29113d1..1055d51 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -54,8 +54,15 @@ public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factor * @return The produced {@code StorableCustomCompiler} * @throws IncorrectLoadValueFormat The provided load value was in an incorrect format * @throws MissingKeyException The provided load value was missing one or more required keys + * @throws NonExistentComponentException A specified component class does not exist + * @throws ComponentCastException A specified component class could not be cast to its intended type */ - public StorableCustomCompiler produce(StorageValue loadValue) throws IncorrectLoadValueFormat, MissingKeyException { + public StorableCustomCompiler produce(StorageValue loadValue) throws + IncorrectLoadValueFormat, + MissingKeyException, + NonExistentComponentException, + ComponentCastException + { Map> mapValue = tryGetMapValue(loadValue); Set keys = mapValue.keySet(); @@ -123,8 +130,14 @@ protected record ComponentInformation(String name, ListStorageValue description) * @param description The description with which to load the component with * @param selectedType The subclass with which to produce and use the component * @return The built component + * @throws NonExistentComponentException The specified component class does not exist + * @throws ComponentCastException The specified component class could not be cast to the selectedType */ - protected T buildComponent(Map> repository, StorageValue description, Class selectedType) { + protected T buildComponent( + Map> repository, + StorageValue description, + Class selectedType + ) throws NonExistentComponentException, ComponentCastException { ComponentInformation componentDescription = getComponentDescription(description); if (repository.containsKey(componentDescription.name())) @@ -143,8 +156,7 @@ protected T buildComponent(Map> repository, StorageValue< throw new NonExistentComponentException(componentDescription.name()); } catch (ClassCastException e) { - //TODO - throw new RuntimeException(); + throw new ComponentCastException(componentDescription.name(), selectedType.getName()); } if (LoadableBy.class.isAssignableFrom(clazz)) { diff --git a/src/main/java/component_construction/storage/exceptions/ComponentCastException.java b/src/main/java/component_construction/storage/exceptions/ComponentCastException.java new file mode 100644 index 0000000..6e69a03 --- /dev/null +++ b/src/main/java/component_construction/storage/exceptions/ComponentCastException.java @@ -0,0 +1,8 @@ +package component_construction.storage.exceptions; + +public class ComponentCastException extends RuntimeException { + + public ComponentCastException(String componentClassName, String expectedType) { + super("The provided component class \"" + componentClassName + "\" could not be cast to the expected type \"" + expectedType + "\". Ensure \"" + componentClassName + "\" implements \"" + expectedType + "\"."); + } +} diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index fb0772b..44a20bb 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -354,7 +354,7 @@ public void produce_nonExistentComponentClass() { codeGeneratorComponent.factory() ); - NonExistentComponentException a = assertThrows(NonExistentComponentException.class, () -> factory.produce( + assertThrows(NonExistentComponentException.class, () -> factory.produce( new MapStorageValue(Map.of( "lexicalAnalyser", new ListStorageValue( new StringStorageValue("NonExistantClass"), @@ -371,4 +371,36 @@ public void produce_nonExistentComponentClass() { )) )); } + + @Test + public void produce_nonComponentClass() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + assertThrows(ComponentCastException.class, () -> factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue(TestCustomFalseLexicalAnalyser.class.getName()), + new ListStorageValue(List.of()) + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + )); + } + + // TODO: Handle all exceptions } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomFalseLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomFalseLexicalAnalyser.java new file mode 100644 index 0000000..03c6bea --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomFalseLexicalAnalyser.java @@ -0,0 +1,14 @@ +package test_aids.storage_entities.custom_components; + +import grammar_objects.Token; + +/** + * Identical class to {@code TestCustomLexicalAnalyser} but does not implement {@code LexicalAnalyser} + */ +public class TestCustomFalseLexicalAnalyser { + + public Token[] analyse(String sentence) { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + +} From ab49217a8fbfec0c048e2ff3ae9bb4cbc5a8d47a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 30 Aug 2026 01:14:45 +0100 Subject: [PATCH 128/162] Produce with component missing correct constructor --- .../StorableCustomCompilerFactory.java | 29 +++++++++++++----- .../exceptions/ReflectiveLoadFailure.java | 9 ++++++ .../StorableCustomCompilerFactoryTests.java | 30 ++++++++++++++++++- .../NonConstructableLexicalAnalyser.java | 20 +++++++++++++ 4 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 src/main/java/component_construction/storage/exceptions/ReflectiveLoadFailure.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/NonConstructableLexicalAnalyser.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 1055d51..b8a5a3a 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -56,12 +56,14 @@ public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factor * @throws MissingKeyException The provided load value was missing one or more required keys * @throws NonExistentComponentException A specified component class does not exist * @throws ComponentCastException A specified component class could not be cast to its intended type + * @throws ReflectiveLoadFailure A specified component class does not contain a constructor taing a single {@code StorageValue} parameter */ public StorableCustomCompiler produce(StorageValue loadValue) throws IncorrectLoadValueFormat, MissingKeyException, NonExistentComponentException, - ComponentCastException + ComponentCastException, + ReflectiveLoadFailure { Map> mapValue = tryGetMapValue(loadValue); Set keys = mapValue.keySet(); @@ -132,12 +134,17 @@ protected record ComponentInformation(String name, ListStorageValue description) * @return The built component * @throws NonExistentComponentException The specified component class does not exist * @throws ComponentCastException The specified component class could not be cast to the selectedType + * @throws ReflectiveLoadFailure The specified component class does not contain a constructor taing a single {@code StorageValue} parameter */ protected T buildComponent( Map> repository, StorageValue description, Class selectedType - ) throws NonExistentComponentException, ComponentCastException { + ) throws + NonExistentComponentException, + ComponentCastException, + ReflectiveLoadFailure + { ComponentInformation componentDescription = getComponentDescription(description); if (repository.containsKey(componentDescription.name())) @@ -174,9 +181,11 @@ protected T buildComponent( componentDescription.name(), selectedType ); - } catch (ClassNotFoundException | IllegalArgumentException e) { - //TODO - throw new RuntimeException(); + } + catch (ClassNotFoundException | IllegalArgumentException e) { + // ClassNotFoundException cannot occur as the cast succeeded earlier in this method + // There are also no arguments to cause an IllegalArgumentException + return null; } ((ReflectivelyLoadable)component).load(componentDescription.description()); @@ -192,9 +201,13 @@ protected T buildComponent( StorageValue.class, componentDescription.description() ); - } catch (ClassNotFoundException | IllegalArgumentException e) { - //TODO - throw new RuntimeException(); + } + catch (ClassNotFoundException e) { + // ClassNotFoundException cannot occur as the cast succeeded earlier in this method + return null; + } + catch (IllegalArgumentException e) { + throw new ReflectiveLoadFailure("Failed to construct an object of class \"" + componentDescription.name() + "\" as no constructor exists taking \"StorageValue\" as its only parameter.", e); } } } diff --git a/src/main/java/component_construction/storage/exceptions/ReflectiveLoadFailure.java b/src/main/java/component_construction/storage/exceptions/ReflectiveLoadFailure.java new file mode 100644 index 0000000..e35f350 --- /dev/null +++ b/src/main/java/component_construction/storage/exceptions/ReflectiveLoadFailure.java @@ -0,0 +1,9 @@ +package component_construction.storage.exceptions; + +public class ReflectiveLoadFailure extends RuntimeException { + + public ReflectiveLoadFailure(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index 44a20bb..af3b3b0 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -402,5 +402,33 @@ public void produce_nonComponentClass() { )); } - // TODO: Handle all exceptions + @Test + public void produce_componentMissingCorrectConstructor() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + assertThrows(ReflectiveLoadFailure.class, () -> factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new ListStorageValue( + new StringStorageValue(NonConstructableLexicalAnalyser.class.getName()), + new ListStorageValue(List.of()) + ), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + )); + } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/NonConstructableLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/NonConstructableLexicalAnalyser.java new file mode 100644 index 0000000..6da59b5 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/NonConstructableLexicalAnalyser.java @@ -0,0 +1,20 @@ +package test_aids.storage_entities.custom_components; + +import grammar_objects.Token; +import lexical_analysis.LexicalAnalyser; +import storage.storage_values.StorageValue; + +public class NonConstructableLexicalAnalyser implements LexicalAnalyser { + + public StorageValue loadedData; + + public NonConstructableLexicalAnalyser() {} + + public NonConstructableLexicalAnalyser(int a, String b) {} + + @Override + public Token[] analyse(String sentence) { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + +} From 8040f96c52540a293416f7b0aeaee46893437e5a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 30 Aug 2026 02:12:37 +0100 Subject: [PATCH 129/162] Produce using incorrect Format with non list component description Includes minor documentation formatting and inclusion of the cause Throwable for IncorrectLoadValueFormat --- .../StorableCustomCompilerFactory.java | 46 +++++++++++++------ .../exceptions/IncorrectLoadValueFormat.java | 7 ++- .../StorableCustomCompilerFactoryTests.java | 30 ++++++++++++ 3 files changed, 68 insertions(+), 15 deletions(-) diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index b8a5a3a..8908b05 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -41,22 +41,23 @@ public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factor @Override /** - * Builds a StorableCustomCompiler from a map of specified StorageValues. + * Builds a {@code StorableCustomCompiler} from a map of specified StorageValues. * - * The format of the loadValue for loading StorableCustomCompiler components is a @{code MapStorageValue} containing the keys "lexicalAnalyser", "syntaxAnalyser", and "codeGenerator" mapped to their respective {@code StorageValue} descriptions + * The format of the loadValue for loading {@code StorableCustomCompiler} components is a {@code MapStorageValue} containing the keys "lexicalAnalyser", "syntaxAnalyser", and "codeGenerator" mapped to their respective {@code StorageValue} descriptions * * In order to be loadable, components must be one of: * - registered with a factory - * - LoadableBy - * - Loadable - * - Have a constructor taking a single StorageValue parameter - * @param loadValue The StorageValue to be used for building a StorableCustomCompiler + * - {@code LoadableBy} + * - {@code Loadable} + * - Have a constructor taking a single {@code StorageValue} parameter + * @param loadValue The StorageValue to be used for building a {@code StorableCustomCompiler} * @return The produced {@code StorableCustomCompiler} * @throws IncorrectLoadValueFormat The provided load value was in an incorrect format * @throws MissingKeyException The provided load value was missing one or more required keys * @throws NonExistentComponentException A specified component class does not exist * @throws ComponentCastException A specified component class could not be cast to its intended type * @throws ReflectiveLoadFailure A specified component class does not contain a constructor taing a single {@code StorageValue} parameter + * @throws IncorrectLoadValueFormat A provided component's description was not the expected type {@code ListStorageValue} */ public StorableCustomCompiler produce(StorageValue loadValue) throws IncorrectLoadValueFormat, @@ -102,8 +103,9 @@ private Map> tryGetMapValue(StorageValue loadValue) t } catch (ClassCastException e) { throw new IncorrectLoadValueFormat( - "Map>", - loadValue.getClass().getSimpleName() + "MapStorageValue which maps String -> ListStorageValue", + loadValue.getClass().getSimpleName(), + e ); } @@ -111,9 +113,25 @@ private Map> tryGetMapValue(StorageValue loadValue) t return mapValue; } - // TODO: Handle errors - protected ComponentInformation getComponentDescription(StorageValue description) { - List> entry = ((ListStorageValue)description).getValue(); + /** + * Converts a given description into a {@code ComponentInformation} object + * @param description The component's description as a {@code ListStorageValue} + * @return The ComponentInformation representation of the description + * @throws IncorrectLoadValueFormat The provided component description was not the expected type {@code ListStorageValue} + */ + protected ComponentInformation getComponentDescription(StorageValue description) throws IncorrectLoadValueFormat { + List> entry; + + try { + entry = ((ListStorageValue)description).getValue(); + } + catch (ClassCastException e) { + throw new IncorrectLoadValueFormat( + "MapStorageValue which maps String -> ListStorageValue", + "MapStorageValue which maps String -> " + description.getClass().getSimpleName(), + e + ); + } return new ComponentInformation( ((StringStorageValue)entry.get(0)).getValue(), @@ -126,7 +144,7 @@ protected record ComponentInformation(String name, ListStorageValue description) @SuppressWarnings("unchecked") /** * Builds a component with the provided description. - * Components must be: registered with a factory; LoadableBy; Loadable; Or, have a constructor taking a single StorageValue parameter. + * Components must be: registered with a factory; LoadableBy; Loadable; Or, have a constructor taking a single {@code StorageValue} parameter. * @param The abstract type of the component * @param repository The repository to query for registered factories for the specific component type * @param description The description with which to load the component with @@ -135,6 +153,7 @@ protected record ComponentInformation(String name, ListStorageValue description) * @throws NonExistentComponentException The specified component class does not exist * @throws ComponentCastException The specified component class could not be cast to the selectedType * @throws ReflectiveLoadFailure The specified component class does not contain a constructor taing a single {@code StorageValue} parameter + * @throws IncorrectLoadValueFormat The provided component description was not the expected type {@code ListStorageValue} */ protected T buildComponent( Map> repository, @@ -143,7 +162,8 @@ protected T buildComponent( ) throws NonExistentComponentException, ComponentCastException, - ReflectiveLoadFailure + ReflectiveLoadFailure, + IncorrectLoadValueFormat { ComponentInformation componentDescription = getComponentDescription(description); diff --git a/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java b/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java index ac9c8fd..7692f36 100644 --- a/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java +++ b/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java @@ -2,7 +2,10 @@ public class IncorrectLoadValueFormat extends RuntimeException { - public IncorrectLoadValueFormat(String expectedFormat, String actualFormat) { - super("A load value was provided in an incorrect format. Expected - " + expectedFormat + ", Actual - " + actualFormat); + public IncorrectLoadValueFormat(String expectedFormat, String actualFormat, Throwable cause) { + super( + "A load value was provided in an incorrect format. Expected - " + expectedFormat + ", Actual - " + actualFormat, + cause + ); } } diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index af3b3b0..22e11fd 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -342,6 +342,36 @@ public void produce_incorrectFormat_emptyMap() { )); } + @Test + public void produce_incorrectFormat_nonListComponentDescription() { + StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() + .addSyntaxAnalyserFactory( + syntaxComponent.name(), + syntaxComponent.factory() + ) + .addCodeGeneratorFactory( + codeGeneratorComponent.name(), + codeGeneratorComponent.factory() + ); + + assertThrows(IncorrectLoadValueFormat.class, () -> factory.produce( + new MapStorageValue(Map.of( + "lexicalAnalyser", new MapStorageValue(Map.of( + lexicalComponent.name(), + lexicalComponent.description() + )), + "syntaxAnalyser", new ListStorageValue( + new StringStorageValue(syntaxComponent.name()), + syntaxComponent.description() + ), + "codeGenerator", new ListStorageValue( + new StringStorageValue(codeGeneratorComponent.name()), + codeGeneratorComponent.description() + ) + )) + )); + } + @Test public void produce_nonExistentComponentClass() { StorableCustomCompilerFactory factory = new StorableCustomCompilerFactory() From b9dbac2c935e88e7794adf9e6e72245d24008948 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 1 Sep 2026 22:56:22 +0100 Subject: [PATCH 130/162] Including cause within exceptions --- .../storage/Factories/StorableCustomCompilerFactory.java | 4 ++-- .../storage/exceptions/ComponentCastException.java | 7 +++++-- .../storage/exceptions/NonExistentComponentException.java | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 8908b05..8439d45 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -180,10 +180,10 @@ protected T buildComponent( .asSubclass(selectedType); } catch (ClassNotFoundException e) { - throw new NonExistentComponentException(componentDescription.name()); + throw new NonExistentComponentException(componentDescription.name(), e); } catch (ClassCastException e) { - throw new ComponentCastException(componentDescription.name(), selectedType.getName()); + throw new ComponentCastException(componentDescription.name(), selectedType.getName(), e); } if (LoadableBy.class.isAssignableFrom(clazz)) { diff --git a/src/main/java/component_construction/storage/exceptions/ComponentCastException.java b/src/main/java/component_construction/storage/exceptions/ComponentCastException.java index 6e69a03..0b260f3 100644 --- a/src/main/java/component_construction/storage/exceptions/ComponentCastException.java +++ b/src/main/java/component_construction/storage/exceptions/ComponentCastException.java @@ -2,7 +2,10 @@ public class ComponentCastException extends RuntimeException { - public ComponentCastException(String componentClassName, String expectedType) { - super("The provided component class \"" + componentClassName + "\" could not be cast to the expected type \"" + expectedType + "\". Ensure \"" + componentClassName + "\" implements \"" + expectedType + "\"."); + public ComponentCastException(String componentClassName, String expectedType, Throwable cause) { + super( + "The provided component class \"" + componentClassName + "\" could not be cast to the expected type \"" + expectedType + "\". Ensure \"" + componentClassName + "\" implements \"" + expectedType + "\".", + cause + ); } } diff --git a/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java b/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java index 7b48b6c..cd77563 100644 --- a/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java +++ b/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java @@ -2,7 +2,10 @@ public class NonExistentComponentException extends RuntimeException { - public NonExistentComponentException(String attemptedComponentClassName) { - super("The component class \"" + attemptedComponentClassName + "\" could not be found or does not exist. Check the provided component name correctly references the intended class."); + public NonExistentComponentException(String attemptedComponentClassName, Throwable cause) { + super( + "The component class \"" + attemptedComponentClassName + "\" could not be found or does not exist. Check the provided component name correctly references the intended class.", + cause + ); } } From 6362581033e3f2f854b667ce386fb18a24d47b4c Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 3 Sep 2026 00:29:04 +0100 Subject: [PATCH 131/162] Null handling in Storage --- src/main/java/storage/Storage.java | 25 ++++- .../NullStorageObjectException.java | 9 ++ src/test/java/storage/StorageTests.java | 105 ++++++++++++++++-- 3 files changed, 126 insertions(+), 13 deletions(-) create mode 100644 src/main/java/storage/exceptions/NullStorageObjectException.java diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 3bcaa60..30b267f 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -167,8 +167,11 @@ public Storage setFileEditor(StreamEditor fileEditor) { * @throws StoreFailureException * @throws FormattingException * @throws StorageFormatMismatchException + * @throws NullStorageObjectException */ - public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException { + public void convertAndStore(Storable storageObject, ValueFormatter formatter, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException, NullStorageObjectException { + if(storageObject == null) throw new NullStorageObjectException(); + convertAndStore_Inner(storageObject.getStorageRepresentation(), new ChosenFormatter(formatter), streamWriter, outputStream); } @@ -179,8 +182,11 @@ public void convertAndStore(Storable storageObject, ValueFormatter format * @throws StoreFailureException * @throws FormattingException * @throws StorageFormatMismatchException + * @throws NullStorageObjectException */ - public void store(Storable storageObject, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException { + public void store(Storable storageObject, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException, NullStorageObjectException { + if(storageObject == null) throw new NullStorageObjectException(); + convertAndStore_Inner(storageObject.getStorageRepresentation(), formatter, streamWriter, outputStream); } @@ -260,8 +266,11 @@ public StorageValue loadWithType(InputStream inputStream) throws LoadFail * @throws UncheckedIOException * @throws RuntimeException * @throws UncheckedIOException + * @throws NullStorageObjectException */ - public void store(Storable storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException { + public void store(Storable storageObject) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException, NullStorageObjectException { + if(storageObject == null) throw new NullStorageObjectException(); + usingTargetFileOutputStream( (outputStream) -> convertAndStore_Inner(storageObject.getStorageRepresentation(), formatter, streamWriter, outputStream) ); @@ -275,8 +284,11 @@ public void store(Storable storageObject) throws UnsupportedValueException, Unch * @throws UncheckedIOException * @throws RuntimeException * @throws UncheckedIOException + * @throws NullStorageObjectException */ - public void store(Storable storageObject, String filePath) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException { + public void store(Storable storageObject, String filePath) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException, NullStorageObjectException { + if(storageObject == null) throw new NullStorageObjectException(); + usingFileOutputStream( new File(filePath), (outputStream) -> convertAndStore_Inner(storageObject.getStorageRepresentation(), formatter, streamWriter, outputStream) @@ -291,8 +303,11 @@ public void store(Storable storageObject, String filePath) throws UnsupportedVal * @throws FormattingException * @throws StorageFormatMismatchException * @throws UncheckedIOException + * @throws NullStorageObjectException */ - public void store(StorageValue storageObject) throws StoreFailureException, FormattingException, StorageFormatMismatchException, UncheckedIOException { + public void store(StorageValue storageObject) throws StoreFailureException, FormattingException, StorageFormatMismatchException, UncheckedIOException, NullStorageObjectException { + if(storageObject == null) throw new NullStorageObjectException(); + usingTargetFileOutputStream( (outputStream) -> convertAndStore_Inner(storageObject, formatter, streamWriter, outputStream) ); diff --git a/src/main/java/storage/exceptions/NullStorageObjectException.java b/src/main/java/storage/exceptions/NullStorageObjectException.java new file mode 100644 index 0000000..b460783 --- /dev/null +++ b/src/main/java/storage/exceptions/NullStorageObjectException.java @@ -0,0 +1,9 @@ +package storage.exceptions; + +public class NullStorageObjectException extends RuntimeException { + + public NullStorageObjectException() { + super("The provided storage object was null. Enusre a valid Storable is provided."); + } + +} diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index ed0cd9d..339c0b2 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -93,6 +93,19 @@ public void setRelativeTargetPath() { assertEquals(expectedPath, actualPath); } + @Test + @UseTestFile + public void storeNull(Path testFile) throws IOException { + StorageValue storageValue = null; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + assertThrows(NullStorageObjectException.class, () -> storage.store(storageValue)); + } + @Test @UseTestFile public void storeString(Path testFile) throws IOException { @@ -303,7 +316,26 @@ public void loadString_FormatterError(Path testFile) throws IOException { @Test @UseTestFile - void convertAndStoreString(Path testFile) throws IOException { + void convertAndStoreNull(Path testFile) throws IOException { + Storable storable = null; + ValueFormatter formatter = new TestStringValueFormatter(); + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + assertThrows(NullStorageObjectException.class, () -> { + try (outputStream) { + storage.convertAndStore(storable, formatter, outputStream); + } + }); + } + + @Test + @UseTestFile + void convertAndStoreString(Path testFile) throws IOException { String expectedString = "testString"; Storable storable = new TestStorable(expectedString); @@ -326,7 +358,7 @@ void convertAndStoreString(Path testFile) throws IOException { @Test @UseTestFile - void convertAndStoreInteger(Path testFile) throws IOException { + void convertAndStoreInteger(Path testFile) throws IOException { int expectedInteger = 10; Storable storable = new TestStorable(expectedInteger); @@ -411,7 +443,7 @@ public void convertAndStoreString_FormatterError(Path testFile) throws IOExcepti @Test @UseTestFile - void convertAndLoadStringInto(Path testFile) throws IOException { + void convertAndLoadStringInto(Path testFile) throws IOException { String expectedString = "testString"; TestLoadable loadable = new TestLoadable(); @@ -435,7 +467,7 @@ void convertAndLoadStringInto(Path testFile) throws IOException { @Test @UseTestFile - void convertAndLoadIntegerInto(Path testFile) throws IOException { + void convertAndLoadIntegerInto(Path testFile) throws IOException { int expectedInteger= 10; TestLoadable loadable = new TestLoadable(); @@ -530,7 +562,7 @@ public void convertAndLoadStringInto_FormatterError(Path testFile) throws IOExce @Test @UseTestFile - void convertThenFormatAndLoadStringInto(Path testFile) throws IOException { + void convertThenFormatAndLoadStringInto(Path testFile) throws IOException { String expectedString = "testString"; TestLoadable loadable = new TestLoadable(); @@ -554,7 +586,7 @@ void convertThenFormatAndLoadStringInto(Path testFile) throws IOException { @Test @UseTestFile - void convertThenFormatAndLoadIntegerInto(Path testFile) throws IOException { + void convertThenFormatAndLoadIntegerInto(Path testFile) throws IOException { int expectedInteger = 10; TestLoadable loadable = new TestLoadable(); @@ -650,6 +682,25 @@ public void convertThenFormatAndLoadStringInto_FormatterError(Path testFile) thr } } + @Test + @UseTestFile + public void storeNullToStream(Path testFile) throws IOException { + Storable storable = null; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + assertThrows(NullStorageObjectException.class, () -> { + try (outputStream) { + storage.store(storable, outputStream); + } + }); + } + @Test @UseTestFile public void storeStringToStream(Path testFile) throws IOException { @@ -970,6 +1021,19 @@ public void loadWithTypeString_FormatterError(Path testFile) throws IOException } } + @Test + @UseTestFile + public void storeStorableOfNull(Path testFile) throws IOException { + Storable storable = null; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + assertThrows(NullStorageObjectException.class, () -> storage.store(storable)); + } + @Test @UseTestFile public void storeStorableOfString(Path testFile) throws IOException { @@ -1056,6 +1120,18 @@ public void storeStorableOfString_FormatterError(Path testFile) throws IOExcepti assertInstanceOf(ExampleException.class, exception.getCause()); } + @Test + @UseTestFile + public void storeStorableOfNullAtFilepath(Path testFile) throws IOException { + Storable storable = null; + Storage storage = new Storage() + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + assertThrows(NullStorageObjectException.class, () -> storage.store(storable, testFile.toString())); + } + @Test @UseTestFile public void storeStorableOfStringAtFilepath(Path testFile) throws IOException { @@ -1137,6 +1213,19 @@ public void storeStorableOfStringAtFilepath_FormatterError(Path testFile) throws assertInstanceOf(ExampleException.class, exception.getCause()); } + @Test + @UseTestFile + public void storeStorageValueOfNull(Path testFile) throws IOException { + StorageValue storageValue = null; + Storage storage = new Storage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + assertThrows(NullStorageObjectException.class, () -> storage.store(storageValue)); + } + @Test @UseTestFile public void storeStorageValueOfString(Path testFile) throws IOException { @@ -1225,7 +1314,7 @@ public void storeStorageValueOfString_FormatterError(Path testFile) throws IOExc @Test @UseTestFile - void LoadStringInto(Path testFile) throws IOException { + void LoadStringInto(Path testFile) throws IOException { String expectedString = "testString"; TestLoadable loadable = new TestLoadable(); Storage storage = new Storage() @@ -1244,7 +1333,7 @@ void LoadStringInto(Path testFile) throws IOException { @Test @UseTestFile - void LoadIntegerInto(Path testFile) throws IOException { + void LoadIntegerInto(Path testFile) throws IOException { int expectedInteger = 10; TestLoadable loadable = new TestLoadable(); Storage storage = new Storage() From 65ab22e075441cab996bbd018719b747d4b709bc Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 3 Sep 2026 00:45:39 +0100 Subject: [PATCH 132/162] StorableCustomCompilerFactoryTests import cleanup --- .../storage/factories/StorableCustomCompilerFactoryTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index 22e11fd..2940bb4 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test; import code_generation.CodeGenerator; -import component_construction.storage.StorableCustomCompiler; import component_construction.storage.exceptions.*; import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; From 9db33d7d52313f5d825c45e29368734730a4f923 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 3 Sep 2026 22:52:58 +0100 Subject: [PATCH 133/162] CompilerStorage methods --- .../storage/CompilerStorage.java | 236 +++++++++++++++++- .../storage/CompilerStorageTests.java | 16 +- 2 files changed, 246 insertions(+), 6 deletions(-) diff --git a/src/main/java/component_construction/storage/CompilerStorage.java b/src/main/java/component_construction/storage/CompilerStorage.java index 5c23424..4db8dd5 100644 --- a/src/main/java/component_construction/storage/CompilerStorage.java +++ b/src/main/java/component_construction/storage/CompilerStorage.java @@ -1,21 +1,249 @@ package component_construction.storage; +import java.io.*; +import java.io.UncheckedIOException; +import java.nio.file.Path; + import component_construction.storage.factories.StorableCustomCompilerFactory; import storage.Storage; +import storage.exceptions.*; +import storage.external_interfaces.Loadable; +import storage.file_editors.*; +import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.StorageValue; +import storage.value_formatters.ValueFormatter; public class CompilerStorage { protected Storage storage = new Storage(); protected StorableCustomCompilerFactory storableCustomCompilerFactory = new StorableCustomCompilerFactory(); - public void store(StorableCustomCompiler compiler) { + //#region Getters + + /** + * Gets the currently tagetted filepath being used for storage + * @return The targeted filepath + */ + public Path getTargetFilepath() { + return storage.getTargetFilepath(); + } + + //#endregion + + //#region Configuration + + /** + * Sets the target filepath the be use for storage + * @param filepath The filepath to target + * @return This object for method chaining + */ + public CompilerStorage setTargetPath(Path filepath) { + storage.setTargetPath(filepath); + return this; + } + + /** + * Sets the target filepath the be use for storage + * @param filepath The absolute filepath to be targeted + * @return This object for method chaining + */ + public CompilerStorage setAbsoluteTargetPath(String filepath) { + storage.setAbsoluteTargetPath(filepath); + return this; + } + + /** + * Sets the target filepath the be use for storage + * @param filepath The relative filepath to be targeted + * @return This object for method chaining + */ + public CompilerStorage setRelativeTargetPath(String filepath) { + storage.setRelativeTargetPath(filepath); + return this; + } + + /** + * Sets the formatter to be used for converting StorageValues into storage representations + * @param The target format to convert values to/from + * @param formatter The formatter to be used + * @return This object for method chaining + */ + public CompilerStorage setFormatter(ValueFormatter formatter) { + storage.setFormatter(formatter); + return this; + } + + /** + * Sets the stream writer to be used for storing storage values + * @param The data format expected to be writen + * @param streamWriter The stream writer to be selected + * @return This object for method chaining + */ + public CompilerStorage setStreamWriter(StreamWriter streamWriter) { + storage.setStreamWriter(streamWriter); + return this; + } + + /** + * Sets the stream reader to be used for reading values from storage + * @param The data format expected to be output when read + * @param streamReader The stream reader to be selected + * @return This object for method chaining + */ + public CompilerStorage setStreamReader(StreamReader streamReader) { + storage.setStreamReader(streamReader); + return this; + } + + /** + * Sets the stream reader to be used for reading and storing values in storage + * @param The data format expected to be read or stored + * @param streamEditor The stream editor to be selected + * @return This object for method chaining + */ + public CompilerStorage setStreamEditor(StreamEditor streamEditor) { + storage.setStreamEditor(streamEditor); + return this; + } + + //#endregion + + //#region ConvenienceMethods + + /** + * Sets the file reader to be used for reading and storing values in storage. + * An equvalent method to setStreamWriter(StreamWriter streamWriter) + * @param The data format expected to be writen + * @param fileWriter The file writer to be selected + * @return This object for method chaining + */ + public CompilerStorage setFileWriter(StreamWriter fileWriter) { + storage.setStreamWriter(fileWriter); + return this; + } + + /** + * Sets the file reader to be used for reading values from storage. + * An equvalent method to setStreamReader(StreamReader streamReader) + * @param The data format expected to be writen + * @param fileReader The file reader to be selected + * @return This object for method chaining + */ + public CompilerStorage setFileReader(StreamReader fileReader) { + storage.setStreamReader(fileReader); + return this; + } + + /** + * Sets the stream reader to be used for reading and storing values in storage. + * An equvalent method to setStreamEditor(StreamEditor streamEditor) + * @param The data format expected to be read or stored + * @param fileEditor The stream editor to be selected + * @return This object for method chaining + */ + public CompilerStorage setFileEditor(StreamEditor fileEditor) { + storage.setStreamEditor(fileEditor); + return this; + } + + //#endregion + + //#region StreamStorage + + /** + * Stores a specified compiler in the given output stream + * @param compiler The object to be stored + * @param outputStream The stream to be used + * @throws StoreFailureException + * @throws FormattingException + * @throws StorageFormatMismatchException + * @throws NullStorageObjectException + */ + public void store(StorableCustomCompiler compiler, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException, NullStorageObjectException { + storage.store(compiler, outputStream); + } + + /** + * Reads a value from the given input stream, converts the value using the chosen formatter and loads it into the given compiler + * @param compiler An existing to load the value into + * @param inputStream The input stream to be read + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + */ + public void convertAndLoadInto(Loadable compiler, InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + storage.convertAndLoadInto(compiler, inputStream); + } + + /** + * Loads a compiler from the given input stream + * @param inputStream The input stream to read from + * @return The compiler built for the stream, once formatted by the chosen formatter + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + */ + public StorableCustomCompiler load(InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + StorageValue storageValue = storage.load(inputStream); + return storableCustomCompilerFactory.produce(storageValue); + } + + //#endregion + + //#region FileStorage + + /** + * Stores the compiler in the targetted file + * @param compiler The compiler to be stored + * @throws UnsupportedValueException + * @throws UncheckedIOException + * @throws RuntimeException + * @throws UncheckedIOException + * @throws NullStorageObjectException + */ + public void store(StorableCustomCompiler compiler) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException, NullStorageObjectException { storage.store(compiler); } - public StorableCustomCompiler load() { + /** + * Stores the compiler in the given file + * @param compiler The compiler to be stored + * @param filePath The target file to use for storage + * @throws UnsupportedValueException + * @throws UncheckedIOException + * @throws RuntimeException + * @throws UncheckedIOException + * @throws NullStorageObjectException + */ + public void store(StorableCustomCompiler compiler, String filePath) throws UnsupportedValueException, UncheckedIOException, RuntimeException, UncheckedIOException, NullStorageObjectException { + storage.store(compiler, filePath); + } + + + /** + * Loads a compiler from the chosen file + * @return The loaded compiler + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + * @throws UncheckedIOException + */ + public StorableCustomCompiler load() throws LoadFailureException, FormatParseException, StorageFormatMismatchException, UncheckedIOException { StorageValue storageValue = storage.load(); return storableCustomCompilerFactory.produce(storageValue); } - // TODO: Include other load variations -} \ No newline at end of file + /** + * Loads a value from the chosen file into the given compiler + * @param compiler An existing compiler to load stored values into + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + * @throws UncheckedIOException + */ + public void loadInto(Loadable compiler) throws LoadFailureException, FormatParseException, StorageFormatMismatchException, UncheckedIOException { + storage.loadInto(compiler); + } + + //#endregion + +} diff --git a/src/test/java/component_construction/storage/CompilerStorageTests.java b/src/test/java/component_construction/storage/CompilerStorageTests.java index 09ae0ed..0f9b03d 100644 --- a/src/test/java/component_construction/storage/CompilerStorageTests.java +++ b/src/test/java/component_construction/storage/CompilerStorageTests.java @@ -1,9 +1,21 @@ package component_construction.storage; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + +import storage.exceptions.NullStorageObjectException; + public class CompilerStorageTests { - // TODO: Test - //store(null) + @Test + public void store_null() { + CompilerStorage storage = new CompilerStorage(); + StorableCustomCompiler compiler = null; + + + assertThrows(NullStorageObjectException.class, () -> storage.store(compiler)); + } + //store(StorableCustomCompiler) //load() valid format From 90fd759a4c70a4e295fecf30eff18167b862014c Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 5 Sep 2026 02:15:20 +0100 Subject: [PATCH 134/162] UseTestFile annotation and extension moved to specialised files --- src/test/java/storage/StorageTests.java | 40 +---------- .../test_files/UseTestFile.java | 7 ++ .../test_files/UseTestFileExtension.java | 67 +++++++++++++++++++ 3 files changed, 76 insertions(+), 38 deletions(-) create mode 100644 src/test/java/test_aids/test_extensions/test_files/UseTestFile.java create mode 100644 src/test/java/test_aids/test_extensions/test_files/UseTestFileExtension.java diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 339c0b2..6a60d4e 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1,58 +1,22 @@ package storage; import static org.junit.jupiter.api.Assertions.*; - import java.io.*; -import java.lang.annotation.*; import java.nio.file.*; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.*; -import org.junit.jupiter.api.io.TempDir; import storage.exceptions.*; import storage.external_interfaces.Storable; import storage.storage_values.*; import storage.value_formatters.*; import test_aids.exceptions.ExampleException; +import test_aids.test_extensions.test_files.*; import test_aids.test_storage.*; -@ExtendWith(StorageTests.UseTestFileExtension.class) +@ExtendWith(UseTestFileExtension.class) public class StorageTests { - @TempDir - Path storageTestPath; - - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.RUNTIME) - protected @interface UseTestFile {} - - public static class UseTestFileExtension implements ParameterResolver { - @Override - public boolean supportsParameter(ParameterContext pc, ExtensionContext ec) { - return ec - .getTestMethod() - .get() - .isAnnotationPresent(UseTestFile.class); - } - - @Override - public Path resolveParameter(ParameterContext pc, ExtensionContext ec) { - try { - StorageTests testInstance = (StorageTests) ec.getRequiredTestInstance(); - Path tempDir = testInstance.storageTestPath; - return createTestFile(tempDir); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - protected Path createTestFile(Path tempDir) throws IOException { - String fileName = "testFile.txt"; - return Files.createFile(tempDir.resolve(fileName)); - } - } - @Test public void setTargetPath() { Path expectedPath = Path.of("./testPath"); diff --git a/src/test/java/test_aids/test_extensions/test_files/UseTestFile.java b/src/test/java/test_aids/test_extensions/test_files/UseTestFile.java new file mode 100644 index 0000000..79b7d89 --- /dev/null +++ b/src/test/java/test_aids/test_extensions/test_files/UseTestFile.java @@ -0,0 +1,7 @@ +package test_aids.test_extensions.test_files; + +import java.lang.annotation.*; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface UseTestFile {} \ No newline at end of file diff --git a/src/test/java/test_aids/test_extensions/test_files/UseTestFileExtension.java b/src/test/java/test_aids/test_extensions/test_files/UseTestFileExtension.java new file mode 100644 index 0000000..c55007f --- /dev/null +++ b/src/test/java/test_aids/test_extensions/test_files/UseTestFileExtension.java @@ -0,0 +1,67 @@ +package test_aids.test_extensions.test_files; + +import java.io.*; +import java.nio.file.*; +import java.util.Comparator; + +import org.junit.jupiter.api.extension.*; +import org.junit.jupiter.api.extension.ExtensionContext.Namespace; +import org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource; + +public class UseTestFileExtension implements ParameterResolver { + + private static final Namespace STORAGE_NAMESPACE = Namespace.create(UseTestFileExtension.class); + + @Override + public boolean supportsParameter(ParameterContext pc, ExtensionContext ec) { + return ec + .getTestMethod() + .get() + .isAnnotationPresent(UseTestFile.class); + } + + @Override + public Object resolveParameter(ParameterContext pc, ExtensionContext ec) { + try { + ManagedDirectory managedDir = ec + .getStore(STORAGE_NAMESPACE) + .getOrComputeIfAbsent( + "managedDir", + key -> new ManagedDirectory(), + ManagedDirectory.class + ); + + return managedDir.createFile("testFile-" + System.nanoTime()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + protected static class ManagedDirectory implements CloseableResource { + + private final Path dir; + + public ManagedDirectory() { + try { + this.dir = Files.createTempDirectory("tests-"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + public Path createFile(String filename) throws IOException { + return Files.createFile(dir.resolve(filename)); + } + + @Override + public void close() throws Throwable { + if (!Files.exists(dir)) return; + + try (var stream = Files.walk(dir)) { + stream + .sorted(Comparator.reverseOrder()) + .forEach(p -> p.toFile().delete()); + } + } + } +} \ No newline at end of file From 39e28903dc809ed132b5cf5d4854c03f6142bb3a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 6 Sep 2026 22:24:08 +0100 Subject: [PATCH 135/162] More LoadableTest... Components --- .../LoadableCustomCodeGenerator.java | 22 +++++++++++++ .../LoadableCustomLexicalAnalyser.java | 2 +- .../LoadableCustomSyntaxAnalyser.java | 24 ++++++++++++++ .../LoadableTestStorableCustomCompiler.java | 33 +++++++++++++++++++ .../TestStorableCustomCompiler.java | 15 +++++++++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 src/test/java/test_aids/storage_entities/custom_components/LoadableCustomCodeGenerator.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/LoadableCustomSyntaxAnalyser.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomCodeGenerator.java new file mode 100644 index 0000000..5a6d4e5 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomCodeGenerator.java @@ -0,0 +1,22 @@ +package test_aids.storage_entities.custom_components; + +import code_generation.CodeGenerator; +import storage.external_interfaces.Loadable; +import storage.storage_values.StorageValue; +import syntax_analysis.parsing.ParseState; + +public class LoadableCustomCodeGenerator implements CodeGenerator, Loadable { + + public StorageValue loadedData; + + @Override + public String generate(ParseState parseRoot) { + throw new UnsupportedOperationException("Unimplemented method 'generate'"); + } + + @Override + public void load(StorageValue data) { + loadedData = data; + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java index 70d15cc..ceea4e2 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java @@ -14,7 +14,7 @@ public Token[] analyse(String sentence) { throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } - @Override + @Override public void load(StorageValue data) { loadedData = data; } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomSyntaxAnalyser.java new file mode 100644 index 0000000..33e937b --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomSyntaxAnalyser.java @@ -0,0 +1,24 @@ +package test_aids.storage_entities.custom_components; + +import grammar_objects.Token; +import storage.external_interfaces.Loadable; +import storage.storage_values.StorageValue; +import syntax_analysis.SyntaxAnalyser; +import syntax_analysis.parsing.ParseFailedException; +import syntax_analysis.parsing.ParseState; + +public class LoadableCustomSyntaxAnalyser implements SyntaxAnalyser, Loadable { + + public StorageValue loadedData; + + @Override + public ParseState analyse(Token[] inputTokens) throws ParseFailedException { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + + @Override + public void load(StorageValue data) { + loadedData = data; + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java new file mode 100644 index 0000000..e987948 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java @@ -0,0 +1,33 @@ +package test_aids.storage_entities.custom_components; + +import java.util.Map; + +import component_construction.storage.StorableCustomCompiler; +import storage.external_interfaces.Loadable; +import storage.storage_values.MapStorageValue; +import storage.storage_values.StorageValue; + +public class LoadableTestStorableCustomCompiler extends StorableCustomCompiler implements Loadable { + + public LoadableTestStorableCustomCompiler() { + super( + new LoadableCustomLexicalAnalyser(), + new LoadableCustomSyntaxAnalyser(), + new LoadableCustomCodeGenerator() + ); + } + + @Override + public void load(StorageValue data) { + Map> description = ((MapStorageValue)data).getValue(); + + lexicalAnalyser = new LoadableCustomLexicalAnalyser(); + syntaxAnalyser = new LoadableCustomSyntaxAnalyser(); + codeGenerator = new LoadableCustomCodeGenerator(); + + ((LoadableCustomLexicalAnalyser)lexicalAnalyser).load(description.get("lexicalAnalyser")); + ((LoadableCustomSyntaxAnalyser)syntaxAnalyser).load(description.get("syntaxAnalyser")); + ((LoadableCustomCodeGenerator)codeGenerator).load(description.get("codeGenerator")); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java new file mode 100644 index 0000000..6c00d5b --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java @@ -0,0 +1,15 @@ +package test_aids.storage_entities.custom_components; + +import component_construction.storage.StorableCustomCompiler; + +public class TestStorableCustomCompiler extends StorableCustomCompiler { + + public TestStorableCustomCompiler() { + super( + new TestCustomLexicalAnalyser(), + new TestCustomSyntaxAnalyser(), + new TestCustomCodeGenerator() + ); + } + +} From b2af90ab3d60d0b07f37153c489ad33e2feae4b7 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 6 Sep 2026 22:27:23 +0100 Subject: [PATCH 136/162] .equals() for CustomCompiler and StorableCustomCompiler --- .../custom_components/CustomCompiler.java | 21 +++++++++++++++++++ .../storage/StorableCustomCompiler.java | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/component_construction/custom_components/CustomCompiler.java b/src/main/java/component_construction/custom_components/CustomCompiler.java index 9fb9a2f..47e386a 100644 --- a/src/main/java/component_construction/custom_components/CustomCompiler.java +++ b/src/main/java/component_construction/custom_components/CustomCompiler.java @@ -2,6 +2,7 @@ import code_generation.CodeGenerator; import component_construction.Compiler; +import component_construction.storage.StorableCustomCompiler; import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; import syntax_analysis.SyntaxAnalyser; @@ -27,4 +28,24 @@ public String compile(String input) throws ParseFailedException { ParseState parseRoot = syntaxAnalyser.analyse(tokens); return codeGenerator.generate(parseRoot); } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof CustomCompiler)) return false; + + CustomCompiler other = (CustomCompiler)obj; + if (!this.lexicalAnalyser.equals(other.lexicalAnalyser)) return false; + if (!this.syntaxAnalyser.equals(other.syntaxAnalyser)) return false; + if (!this.codeGenerator.equals(other.codeGenerator)) return false; + + return true; + } + + @Override + public int hashCode() { + return 31 + * lexicalAnalyser.hashCode() + * syntaxAnalyser.hashCode() + * codeGenerator.hashCode(); + } } \ No newline at end of file diff --git a/src/main/java/component_construction/storage/StorableCustomCompiler.java b/src/main/java/component_construction/storage/StorableCustomCompiler.java index 188bda6..41a820d 100644 --- a/src/main/java/component_construction/storage/StorableCustomCompiler.java +++ b/src/main/java/component_construction/storage/StorableCustomCompiler.java @@ -44,4 +44,10 @@ public MapStorageValue getStorageRepresentation() { )); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof StorableCustomCompiler)) return false; + return super.equals(obj); + } + } From 2ea54dd72faa1697dc8166eb43a4c47026d56702 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 6 Sep 2026 22:30:55 +0100 Subject: [PATCH 137/162] CompilerStorage additional storage methods and LoadableBy comment update --- .../storage/CompilerStorage.java | 35 +++++++++++++++++-- src/test/java/storage/StorageTests.java | 2 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/java/component_construction/storage/CompilerStorage.java b/src/main/java/component_construction/storage/CompilerStorage.java index 4db8dd5..c251cfe 100644 --- a/src/main/java/component_construction/storage/CompilerStorage.java +++ b/src/main/java/component_construction/storage/CompilerStorage.java @@ -1,13 +1,13 @@ package component_construction.storage; import java.io.*; -import java.io.UncheckedIOException; import java.nio.file.Path; import component_construction.storage.factories.StorableCustomCompilerFactory; import storage.Storage; import storage.exceptions.*; import storage.external_interfaces.Loadable; +import storage.external_interfaces.Storable; import storage.file_editors.*; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.StorageValue; @@ -149,9 +149,24 @@ public CompilerStorage setFileEditor(StreamEditor fileEditor) { //#region StreamStorage + /** + * Stores the given compiler to the given output stream, converting the compiler using the specified formatter to produce a storable data format + * @param The data format to be used for storage + * @param compiler The compiler to be stored + * @param formatter The formatter to be used to convert values for storage. Only set for execution of this function. Use setFormatter to use this for multiple executions. + * @param outputStream The stream to be used + * @throws StoreFailureException + * @throws FormattingException + * @throws StorageFormatMismatchException + * @throws NullStorageObjectException + */ + public void convertAndStore(StorableCustomCompiler compiler, ValueFormatter formatter, OutputStream outputStream) throws StoreFailureException, FormattingException, StorageFormatMismatchException, NullStorageObjectException { + storage.convertAndStore(compiler, formatter, outputStream); + } + /** * Stores a specified compiler in the given output stream - * @param compiler The object to be stored + * @param compiler The compiler to be stored * @param outputStream The stream to be used * @throws StoreFailureException * @throws FormattingException @@ -174,6 +189,20 @@ public void convertAndLoadInto(Loadable compiler, InputStream inputStream) throw storage.convertAndLoadInto(compiler, inputStream); } + /** + * Reads a value from the given input stream, converts the value using the provided formatter and loads it into the given compiler + * @param The expected value format to be read and provided to the formatter + * @param compiler The compiler to load the value into + * @param formatter The formatter to be used to convert data from the stream + * @param inputStream The input stream to be read + * @throws LoadFailureException + * @throws FormatParseException + * @throws StorageFormatMismatchException + */ + public void convertAndLoadInto(Loadable compiler, ValueFormatter formatter, InputStream inputStream) throws LoadFailureException, FormatParseException, StorageFormatMismatchException { + storage.convertAndLoadInto(compiler, formatter, inputStream); + } + /** * Loads a compiler from the given input stream * @param inputStream The input stream to read from @@ -245,5 +274,7 @@ public void loadInto(Loadable compiler) throws LoadFailureException, FormatParse } //#endregion + + // TODO: Implement and test LoadableBy } diff --git a/src/test/java/storage/StorageTests.java b/src/test/java/storage/StorageTests.java index 6a60d4e..00c9b1c 100644 --- a/src/test/java/storage/StorageTests.java +++ b/src/test/java/storage/StorageTests.java @@ -1461,5 +1461,5 @@ public void loadStringFromTargetPath_FormatterError(Path testFile) throws IOExce assertInstanceOf(ExampleException.class, exception.getCause()); } - // TODO: Test LoadableBy + // TODO: Implement and test LoadableBy } From 6f73618ba6b9796e85ea9c3c198a9b30ee3cb700 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 7 Sep 2026 01:45:05 +0100 Subject: [PATCH 138/162] Introduction of NonStorableComponentException --- .../StorableCustomCompilerFactory.java | 4 +++- .../storage/StorableCustomCompiler.java | 23 ++++++++++++------- .../StorableCustomCompilerBuilder.java | 3 ++- .../NonStorableComponentException.java | 11 +++++++++ 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 src/main/java/component_construction/storage/exceptions/NonStorableComponentException.java diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 8439d45..3371400 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -58,13 +58,15 @@ public StorableCustomCompilerFactory addCodeGeneratorFactory(String name, Factor * @throws ComponentCastException A specified component class could not be cast to its intended type * @throws ReflectiveLoadFailure A specified component class does not contain a constructor taing a single {@code StorageValue} parameter * @throws IncorrectLoadValueFormat A provided component's description was not the expected type {@code ListStorageValue} + * @throws NonStorableComponentException A pecified component class does not implement Storable */ public StorableCustomCompiler produce(StorageValue loadValue) throws IncorrectLoadValueFormat, MissingKeyException, NonExistentComponentException, ComponentCastException, - ReflectiveLoadFailure + ReflectiveLoadFailure, + NonStorableComponentException { Map> mapValue = tryGetMapValue(loadValue); Set keys = mapValue.keySet(); diff --git a/src/main/java/component_construction/storage/StorableCustomCompiler.java b/src/main/java/component_construction/storage/StorableCustomCompiler.java index 41a820d..ce721c3 100644 --- a/src/main/java/component_construction/storage/StorableCustomCompiler.java +++ b/src/main/java/component_construction/storage/StorableCustomCompiler.java @@ -5,6 +5,7 @@ import code_generation.CodeGenerator; import component_construction.custom_components.*; import component_construction.storage.dynamic_loading.LoadableBy; +import component_construction.storage.exceptions.NonStorableComponentException; import component_construction.storage.factories.StorableCustomCompilerFactory; import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; @@ -13,17 +14,23 @@ public class StorableCustomCompiler extends CustomCompiler implements Storable, LoadableBy { - public < - L extends LexicalAnalyser & Storable, - S extends SyntaxAnalyser & Storable, - C extends CodeGenerator & Storable - > - StorableCustomCompiler( + /** + * Creates a new StorableCustomCompiler. All components must implement Storable. + * @param lexicalAnalyser A Storable LexicalAnalyser for this compiler + * @param syntaxAnalyser A Storable SyntaxAnalyser for this compiler + * @param codeGenerator A Storable CodeGenerator for this compiler + * @throws NonStorableComponentException A component was introduced without implementing Storable + */ + public StorableCustomCompiler( LexicalAnalyser lexicalAnalyser, SyntaxAnalyser syntaxAnalyser, CodeGenerator codeGenerator - ) { + ) throws NonStorableComponentException { super(lexicalAnalyser, syntaxAnalyser, codeGenerator); + + if (!(lexicalAnalyser instanceof Storable)) throw new NonStorableComponentException(lexicalAnalyser); + if (!(syntaxAnalyser instanceof Storable)) throw new NonStorableComponentException(syntaxAnalyser); + if (!(codeGenerator instanceof Storable)) throw new NonStorableComponentException(codeGenerator); } @Override @@ -49,5 +56,5 @@ public boolean equals(Object obj) { if (!(obj instanceof StorableCustomCompiler)) return false; return super.equals(obj); } - + } diff --git a/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java b/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java index 0d16a52..1615a2a 100644 --- a/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java +++ b/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java @@ -2,6 +2,7 @@ import component_construction.builders.CompilerBuilderTemplate; import component_construction.storage.StorableCustomCompiler; +import component_construction.storage.exceptions.NonStorableComponentException; import grammar_objects.GrammarParts; public class StorableCustomCompilerBuilder extends CompilerBuilderTemplate { @@ -12,7 +13,7 @@ protected StorableCustomCompilerBuilder getThis() { } @Override - public StorableCustomCompiler createCompiler() { + public StorableCustomCompiler createCompiler() throws NonStorableComponentException { checkForCompleteBuild(); GrammarParts parts = grammar.getParts(); diff --git a/src/main/java/component_construction/storage/exceptions/NonStorableComponentException.java b/src/main/java/component_construction/storage/exceptions/NonStorableComponentException.java new file mode 100644 index 0000000..b589042 --- /dev/null +++ b/src/main/java/component_construction/storage/exceptions/NonStorableComponentException.java @@ -0,0 +1,11 @@ +package component_construction.storage.exceptions; + +import storage.external_interfaces.Storable; + +public class NonStorableComponentException extends RuntimeException { + + public NonStorableComponentException(Object component) { + super("The selected component \"" + component.getClass().getName() + "\" must implement " + Storable.class.getSimpleName()); + } + +} From 792c6d6cf45ea1b02b653f7c1b8217602edd57a9 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 7 Sep 2026 01:45:53 +0100 Subject: [PATCH 139/162] Small unused import cleanup --- .../component_construction/custom_components/CustomCompiler.java | 1 - .../java/component_construction/storage/CompilerStorage.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/component_construction/custom_components/CustomCompiler.java b/src/main/java/component_construction/custom_components/CustomCompiler.java index 47e386a..6b16337 100644 --- a/src/main/java/component_construction/custom_components/CustomCompiler.java +++ b/src/main/java/component_construction/custom_components/CustomCompiler.java @@ -2,7 +2,6 @@ import code_generation.CodeGenerator; import component_construction.Compiler; -import component_construction.storage.StorableCustomCompiler; import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; import syntax_analysis.SyntaxAnalyser; diff --git a/src/main/java/component_construction/storage/CompilerStorage.java b/src/main/java/component_construction/storage/CompilerStorage.java index c251cfe..a0fe85e 100644 --- a/src/main/java/component_construction/storage/CompilerStorage.java +++ b/src/main/java/component_construction/storage/CompilerStorage.java @@ -7,7 +7,6 @@ import storage.Storage; import storage.exceptions.*; import storage.external_interfaces.Loadable; -import storage.external_interfaces.Storable; import storage.file_editors.*; import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.StorageValue; From da7dc2385be76cd3e32e381b399aabeee280fafa Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 7 Sep 2026 01:49:00 +0100 Subject: [PATCH 140/162] Made test compiler components storable --- .../StorableCustomCompilerFactoryTests.java | 14 ++++++------- ...ConstructableStorableLexicalAnalyser.java} | 10 +++++++-- ... LoadableStorableCustomCodeGenerator.java} | 9 ++++++-- ...oadableStorableCustomLexicalAnalyser.java} | 8 ++++++- ...LoadableStorableCustomSyntaxAnalyser.java} | 12 +++++++---- .../LoadableTestStorableCustomCompiler.java | 21 +++++++++---------- .../TestCustomCodeGenerator.java | 13 ------------ .../TestCustomLexicalAnalyser.java | 13 ------------ .../TestStorableCustomCodeGenerator.java | 20 ++++++++++++++++++ .../TestStorableCustomCompiler.java | 6 +++--- .../TestStorableCustomLexicalAnalyser.java | 20 ++++++++++++++++++ ... => TestStorableCustomSyntaxAnalyser.java} | 9 +++++++- ...LoadableByCustomLexicalAnalyserLoader.java | 6 +++--- ...dableByStorableCustomLexicalAnalyser.java} | 8 ++++++- 14 files changed, 108 insertions(+), 61 deletions(-) rename src/test/java/test_aids/storage_entities/custom_components/{ConstructableLexicalAnalyser.java => ConstructableStorableLexicalAnalyser.java} (56%) rename src/test/java/test_aids/storage_entities/custom_components/{LoadableCustomCodeGenerator.java => LoadableStorableCustomCodeGenerator.java} (67%) rename src/test/java/test_aids/storage_entities/custom_components/{LoadableCustomLexicalAnalyser.java => LoadableStorableCustomLexicalAnalyser.java} (67%) rename src/test/java/test_aids/storage_entities/custom_components/{LoadableCustomSyntaxAnalyser.java => LoadableStorableCustomSyntaxAnalyser.java} (64%) delete mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java delete mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCodeGenerator.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomLexicalAnalyser.java rename src/test/java/test_aids/storage_entities/custom_components/{TestCustomSyntaxAnalyser.java => TestStorableCustomSyntaxAnalyser.java} (52%) rename src/test/java/test_aids/storage_entities/custom_components/loadableBy/{LoadableByCustomLexicalAnalyser.java => LoadableByStorableCustomLexicalAnalyser.java} (64%) diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index 2940bb4..c49138c 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -10,7 +10,7 @@ import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; import test_aids.storage_entities.custom_components.*; -import test_aids.storage_entities.custom_components.loadableBy.LoadableByCustomLexicalAnalyser; +import test_aids.storage_entities.custom_components.loadableBy.LoadableByStorableCustomLexicalAnalyser; public class StorableCustomCompilerFactoryTests { @@ -29,7 +29,7 @@ protected record TypedComponent(String name, ListStorageValue description, Fa description ); - return new TestCustomLexicalAnalyser(); + return new TestStorableCustomLexicalAnalyser(); } ); @@ -46,7 +46,7 @@ protected record TypedComponent(String name, ListStorageValue description, Fa description ); - return new TestCustomSyntaxAnalyser(); + return new TestStorableCustomSyntaxAnalyser(); } ); @@ -63,7 +63,7 @@ protected record TypedComponent(String name, ListStorageValue description, Fa description ); - return new TestCustomCodeGenerator(); + return new TestStorableCustomCodeGenerator(); } ); @@ -150,7 +150,7 @@ public void produce_LoadableByLexicalAnalyser() { factory.produce( new MapStorageValue(Map.of( "lexicalAnalyser", new ListStorageValue( - new StringStorageValue(LoadableByCustomLexicalAnalyser.class.getName()), + new StringStorageValue(LoadableByStorableCustomLexicalAnalyser.class.getName()), lexicalComponent.description() ), "syntaxAnalyser", new ListStorageValue( @@ -180,7 +180,7 @@ public void produce_LoadableLexicalAnalyser() { factory.produce( new MapStorageValue(Map.of( "lexicalAnalyser", new ListStorageValue( - new StringStorageValue(LoadableCustomLexicalAnalyser.class.getName()), + new StringStorageValue(LoadableStorableCustomLexicalAnalyser.class.getName()), lexicalComponent.description() ), "syntaxAnalyser", new ListStorageValue( @@ -210,7 +210,7 @@ public void produce_ConstructableLexicalAnalyser() { factory.produce( new MapStorageValue(Map.of( "lexicalAnalyser", new ListStorageValue( - new StringStorageValue(ConstructableLexicalAnalyser.class.getName()), + new StringStorageValue(ConstructableStorableLexicalAnalyser.class.getName()), new ListStorageValue(List.of()) ), "syntaxAnalyser", new ListStorageValue( diff --git a/src/test/java/test_aids/storage_entities/custom_components/ConstructableLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/ConstructableStorableLexicalAnalyser.java similarity index 56% rename from src/test/java/test_aids/storage_entities/custom_components/ConstructableLexicalAnalyser.java rename to src/test/java/test_aids/storage_entities/custom_components/ConstructableStorableLexicalAnalyser.java index 91810f3..dabc3ad 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/ConstructableLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/ConstructableStorableLexicalAnalyser.java @@ -2,13 +2,14 @@ import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; +import storage.external_interfaces.Storable; import storage.storage_values.StorageValue; -public class ConstructableLexicalAnalyser implements LexicalAnalyser { +public class ConstructableStorableLexicalAnalyser implements LexicalAnalyser, Storable { public StorageValue loadedData; - public ConstructableLexicalAnalyser(StorageValue data) { + public ConstructableStorableLexicalAnalyser(StorageValue data) { loadedData = data; } @@ -17,4 +18,9 @@ public Token[] analyse(String sentence) { throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } + @Override + public StorageValue getStorageRepresentation() { + return loadedData; + } + } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomCodeGenerator.java similarity index 67% rename from src/test/java/test_aids/storage_entities/custom_components/LoadableCustomCodeGenerator.java rename to src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomCodeGenerator.java index 5a6d4e5..679ce5c 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomCodeGenerator.java +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomCodeGenerator.java @@ -1,11 +1,11 @@ package test_aids.storage_entities.custom_components; import code_generation.CodeGenerator; -import storage.external_interfaces.Loadable; +import storage.external_interfaces.*; import storage.storage_values.StorageValue; import syntax_analysis.parsing.ParseState; -public class LoadableCustomCodeGenerator implements CodeGenerator, Loadable { +public class LoadableStorableCustomCodeGenerator implements CodeGenerator, Loadable, Storable { public StorageValue loadedData; @@ -19,4 +19,9 @@ public void load(StorageValue data) { loadedData = data; } + @Override + public StorageValue getStorageRepresentation() { + return loadedData; + } + } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomLexicalAnalyser.java similarity index 67% rename from src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java rename to src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomLexicalAnalyser.java index ceea4e2..bc19629 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomLexicalAnalyser.java @@ -3,9 +3,10 @@ import component_construction.storage.dynamic_loading.ReflectivelyLoadable; import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; +import storage.external_interfaces.Storable; import storage.storage_values.StorageValue; -public class LoadableCustomLexicalAnalyser implements LexicalAnalyser, ReflectivelyLoadable { +public class LoadableStorableCustomLexicalAnalyser implements LexicalAnalyser, ReflectivelyLoadable, Storable { public StorageValue loadedData; @@ -18,5 +19,10 @@ public Token[] analyse(String sentence) { public void load(StorageValue data) { loadedData = data; } + + @Override + public StorageValue getStorageRepresentation() { + return loadedData; + } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomSyntaxAnalyser.java similarity index 64% rename from src/test/java/test_aids/storage_entities/custom_components/LoadableCustomSyntaxAnalyser.java rename to src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomSyntaxAnalyser.java index 33e937b..18b6f9e 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableCustomSyntaxAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomSyntaxAnalyser.java @@ -1,13 +1,12 @@ package test_aids.storage_entities.custom_components; import grammar_objects.Token; -import storage.external_interfaces.Loadable; +import storage.external_interfaces.*; import storage.storage_values.StorageValue; import syntax_analysis.SyntaxAnalyser; -import syntax_analysis.parsing.ParseFailedException; -import syntax_analysis.parsing.ParseState; +import syntax_analysis.parsing.*; -public class LoadableCustomSyntaxAnalyser implements SyntaxAnalyser, Loadable { +public class LoadableStorableCustomSyntaxAnalyser implements SyntaxAnalyser, Loadable, Storable { public StorageValue loadedData; @@ -20,5 +19,10 @@ public ParseState analyse(Token[] inputTokens) throws ParseFailedException { public void load(StorageValue data) { loadedData = data; } + + @Override + public StorageValue getStorageRepresentation() { + return loadedData; + } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java index e987948..ef0f65c 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java +++ b/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java @@ -4,16 +4,15 @@ import component_construction.storage.StorableCustomCompiler; import storage.external_interfaces.Loadable; -import storage.storage_values.MapStorageValue; -import storage.storage_values.StorageValue; +import storage.storage_values.*; public class LoadableTestStorableCustomCompiler extends StorableCustomCompiler implements Loadable { public LoadableTestStorableCustomCompiler() { super( - new LoadableCustomLexicalAnalyser(), - new LoadableCustomSyntaxAnalyser(), - new LoadableCustomCodeGenerator() + new LoadableStorableCustomLexicalAnalyser(), + new LoadableStorableCustomSyntaxAnalyser(), + new LoadableStorableCustomCodeGenerator() ); } @@ -21,13 +20,13 @@ public LoadableTestStorableCustomCompiler() { public void load(StorageValue data) { Map> description = ((MapStorageValue)data).getValue(); - lexicalAnalyser = new LoadableCustomLexicalAnalyser(); - syntaxAnalyser = new LoadableCustomSyntaxAnalyser(); - codeGenerator = new LoadableCustomCodeGenerator(); + lexicalAnalyser = new LoadableStorableCustomLexicalAnalyser(); + syntaxAnalyser = new LoadableStorableCustomSyntaxAnalyser(); + codeGenerator = new LoadableStorableCustomCodeGenerator(); - ((LoadableCustomLexicalAnalyser)lexicalAnalyser).load(description.get("lexicalAnalyser")); - ((LoadableCustomSyntaxAnalyser)syntaxAnalyser).load(description.get("syntaxAnalyser")); - ((LoadableCustomCodeGenerator)codeGenerator).load(description.get("codeGenerator")); + ((LoadableStorableCustomLexicalAnalyser)lexicalAnalyser).load(description.get("lexicalAnalyser")); + ((LoadableStorableCustomSyntaxAnalyser)syntaxAnalyser).load(description.get("syntaxAnalyser")); + ((LoadableStorableCustomCodeGenerator)codeGenerator).load(description.get("codeGenerator")); } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java deleted file mode 100644 index aafd55e..0000000 --- a/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java +++ /dev/null @@ -1,13 +0,0 @@ -package test_aids.storage_entities.custom_components; - -import code_generation.CodeGenerator; -import syntax_analysis.parsing.ParseState; - -public class TestCustomCodeGenerator implements CodeGenerator { - - @Override - public String generate(ParseState parseRoot) { - throw new UnsupportedOperationException("Unimplemented method 'generate'"); - } - -} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java deleted file mode 100644 index fb85d9d..0000000 --- a/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java +++ /dev/null @@ -1,13 +0,0 @@ -package test_aids.storage_entities.custom_components; - -import grammar_objects.Token; -import lexical_analysis.LexicalAnalyser; - -public class TestCustomLexicalAnalyser implements LexicalAnalyser { - - @Override - public Token[] analyse(String sentence) { - throw new UnsupportedOperationException("Unimplemented method 'analyse'"); - } - -} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCodeGenerator.java new file mode 100644 index 0000000..ca2cbde --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCodeGenerator.java @@ -0,0 +1,20 @@ +package test_aids.storage_entities.custom_components; + +import code_generation.CodeGenerator; +import storage.external_interfaces.Storable; +import storage.storage_values.*; +import syntax_analysis.parsing.ParseState; + +public class TestStorableCustomCodeGenerator implements CodeGenerator, Storable { + + @Override + public String generate(ParseState parseRoot) { + throw new UnsupportedOperationException("Unimplemented method 'generate'"); + } + + @Override + public StorageValue getStorageRepresentation() { + return new StringStorageValue("TestStorableCustomCodeGenerator"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java index 6c00d5b..e3659dd 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java @@ -6,9 +6,9 @@ public class TestStorableCustomCompiler extends StorableCustomCompiler { public TestStorableCustomCompiler() { super( - new TestCustomLexicalAnalyser(), - new TestCustomSyntaxAnalyser(), - new TestCustomCodeGenerator() + new TestStorableCustomLexicalAnalyser(), + new TestStorableCustomSyntaxAnalyser(), + new TestStorableCustomCodeGenerator() ); } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomLexicalAnalyser.java new file mode 100644 index 0000000..318b037 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomLexicalAnalyser.java @@ -0,0 +1,20 @@ +package test_aids.storage_entities.custom_components; + +import grammar_objects.Token; +import lexical_analysis.LexicalAnalyser; +import storage.external_interfaces.Storable; +import storage.storage_values.*; + +public class TestStorableCustomLexicalAnalyser implements LexicalAnalyser, Storable { + + @Override + public Token[] analyse(String sentence) { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + + @Override + public StorageValue getStorageRepresentation() { + return new StringStorageValue("TestStorableCustomLexicalAnalyser"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomSyntaxAnalyser.java similarity index 52% rename from src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java rename to src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomSyntaxAnalyser.java index 0699d3d..8f01190 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomSyntaxAnalyser.java @@ -1,14 +1,21 @@ package test_aids.storage_entities.custom_components; import grammar_objects.Token; +import storage.external_interfaces.Storable; +import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; import syntax_analysis.parsing.*; -public class TestCustomSyntaxAnalyser implements SyntaxAnalyser { +public class TestStorableCustomSyntaxAnalyser implements SyntaxAnalyser, Storable { @Override public ParseState analyse(Token[] inputTokens) throws ParseFailedException { throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } + + @Override + public StorageValue getStorageRepresentation() { + return new StringStorageValue("TestStorableCustomSyntaxAnalyser"); + } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java index ccb358a..2b0cf9b 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java @@ -3,11 +3,11 @@ import component_construction.storage.dynamic_loading.Loader; import storage.storage_values.StorageValue; -public class LoadableByCustomLexicalAnalyserLoader implements Loader { +public class LoadableByCustomLexicalAnalyserLoader implements Loader { @Override - public LoadableByCustomLexicalAnalyser produce(StorageValue loadValue) { - LoadableByCustomLexicalAnalyser lex = new LoadableByCustomLexicalAnalyser(); + public LoadableByStorableCustomLexicalAnalyser produce(StorageValue loadValue) { + LoadableByStorableCustomLexicalAnalyser lex = new LoadableByStorableCustomLexicalAnalyser(); lex.loadInternals(loadValue); return lex; diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java similarity index 64% rename from src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java rename to src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java index d57a62f..e4a37e3 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java @@ -3,9 +3,10 @@ import component_construction.storage.dynamic_loading.LoadableBy; import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; +import storage.external_interfaces.Storable; import storage.storage_values.StorageValue; -public class LoadableByCustomLexicalAnalyser implements LexicalAnalyser, LoadableBy { +public class LoadableByStorableCustomLexicalAnalyser implements LexicalAnalyser, LoadableBy, Storable { public StorageValue loadedData; @@ -17,5 +18,10 @@ public Token[] analyse(String sentence) { public void loadInternals(StorageValue data) { loadedData = data; } + + @Override + public StorageValue getStorageRepresentation() { + return loadedData; + } } From fdc5fdd8680d8c10cc03997afcd61389460b5933 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 8 Sep 2026 11:07:18 +0100 Subject: [PATCH 141/162] NullStorageValue handling --- .../storage/storage_values/NullStorageValue.java | 14 ++++++++++++++ .../value_formatters/ValueToStringFormatter.java | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 src/main/java/storage/storage_values/NullStorageValue.java diff --git a/src/main/java/storage/storage_values/NullStorageValue.java b/src/main/java/storage/storage_values/NullStorageValue.java new file mode 100644 index 0000000..923b415 --- /dev/null +++ b/src/main/java/storage/storage_values/NullStorageValue.java @@ -0,0 +1,14 @@ +package storage.storage_values; + +public class NullStorageValue extends StorageValue { + + public NullStorageValue() { + super(null); + } + + @Override + public String toString() { + return "NullStorageValue()"; + } + +} diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index d9a543d..35a132a 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -17,6 +17,7 @@ public class ValueToStringFormatter implements ValueFormatter { @Override public String format(StorageValue value) throws UnsupportedValueException { + if (value instanceof NullStorageValue) return "null"; if (value instanceof ListStorageValue) return formatValue((ListStorageValue)value); if (value instanceof MapStorageValue) return formatValue((MapStorageValue)value); if (value instanceof StringStorageValue) return formatValue((StringStorageValue)value); @@ -34,6 +35,7 @@ public String format(StorageValue value) throws UnsupportedValueException { */ @Override public StorageValue parse(String formattedData) throws UnsupportedValueException { + if (formattedData.startsWith("null")) return new NullStorageValue(); if (formattedData.startsWith("[")) return parseListFormat(formattedData); if (formattedData.startsWith("{")) return parseMapFormat(formattedData); if (formattedData.startsWith("\"")) return parseStringFormat(formattedData); From 8c2a1d63c72f93d86056e17d6f2e77cfa6d29661 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 8 Sep 2026 11:09:12 +0100 Subject: [PATCH 142/162] .equals, NullStorageValue, folder shift and minor value edits for test components --- .../StorableCustomCompilerFactoryTests.java | 1 + .../ConstructableStorableLexicalAnalyser.java | 12 +++++- .../LoadableStorableCustomCodeGenerator.java | 27 -------------- .../NonConstructableLexicalAnalyser.java | 12 +++++- .../TestStorableCustomCodeGenerator.java | 8 +++- .../TestStorableCustomCompiler.java | 7 ++-- .../TestStorableCustomLexicalAnalyser.java | 8 +++- .../TestStorableCustomSyntaxAnalyser.java | 8 +++- .../LoadableStorableCustomCodeGenerator.java | 37 +++++++++++++++++++ ...LoadableStorableCustomLexicalAnalyser.java | 14 +++++-- .../LoadableStorableCustomSyntaxAnalyser.java | 17 +++++++-- .../LoadableTestStorableCustomCompiler.java | 2 +- ...adableByStorableCustomLexicalAnalyser.java | 13 ++++++- 13 files changed, 119 insertions(+), 47 deletions(-) delete mode 100644 src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomCodeGenerator.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomCodeGenerator.java rename src/test/java/test_aids/storage_entities/custom_components/{ => loadable}/LoadableStorableCustomLexicalAnalyser.java (59%) rename src/test/java/test_aids/storage_entities/custom_components/{ => loadable}/LoadableStorableCustomSyntaxAnalyser.java (50%) rename src/test/java/test_aids/storage_entities/custom_components/{ => loadable}/LoadableTestStorableCustomCompiler.java (95%) diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java index c49138c..9005fa4 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java @@ -10,6 +10,7 @@ import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; import test_aids.storage_entities.custom_components.*; +import test_aids.storage_entities.custom_components.loadable.LoadableStorableCustomLexicalAnalyser; import test_aids.storage_entities.custom_components.loadableBy.LoadableByStorableCustomLexicalAnalyser; public class StorableCustomCompilerFactoryTests { diff --git a/src/test/java/test_aids/storage_entities/custom_components/ConstructableStorableLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/ConstructableStorableLexicalAnalyser.java index dabc3ad..2ac6237 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/ConstructableStorableLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/ConstructableStorableLexicalAnalyser.java @@ -3,11 +3,11 @@ import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; -import storage.storage_values.StorageValue; +import storage.storage_values.*; public class ConstructableStorableLexicalAnalyser implements LexicalAnalyser, Storable { - public StorageValue loadedData; + public StorageValue loadedData = new NullStorageValue(); public ConstructableStorableLexicalAnalyser(StorageValue data) { loadedData = data; @@ -23,4 +23,12 @@ public StorageValue getStorageRepresentation() { return loadedData; } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ConstructableStorableLexicalAnalyser)) return false; + + ConstructableStorableLexicalAnalyser other = (ConstructableStorableLexicalAnalyser)obj; + return this.loadedData.equals(other.loadedData); + } + } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomCodeGenerator.java deleted file mode 100644 index 679ce5c..0000000 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomCodeGenerator.java +++ /dev/null @@ -1,27 +0,0 @@ -package test_aids.storage_entities.custom_components; - -import code_generation.CodeGenerator; -import storage.external_interfaces.*; -import storage.storage_values.StorageValue; -import syntax_analysis.parsing.ParseState; - -public class LoadableStorableCustomCodeGenerator implements CodeGenerator, Loadable, Storable { - - public StorageValue loadedData; - - @Override - public String generate(ParseState parseRoot) { - throw new UnsupportedOperationException("Unimplemented method 'generate'"); - } - - @Override - public void load(StorageValue data) { - loadedData = data; - } - - @Override - public StorageValue getStorageRepresentation() { - return loadedData; - } - -} diff --git a/src/test/java/test_aids/storage_entities/custom_components/NonConstructableLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/NonConstructableLexicalAnalyser.java index 6da59b5..1af1991 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/NonConstructableLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/NonConstructableLexicalAnalyser.java @@ -2,11 +2,11 @@ import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; -import storage.storage_values.StorageValue; +import storage.storage_values.*; public class NonConstructableLexicalAnalyser implements LexicalAnalyser { - public StorageValue loadedData; + public StorageValue loadedData = new NullStorageValue(); public NonConstructableLexicalAnalyser() {} @@ -17,4 +17,12 @@ public Token[] analyse(String sentence) { throw new UnsupportedOperationException("Unimplemented method 'analyse'"); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof NonConstructableLexicalAnalyser)) return false; + + NonConstructableLexicalAnalyser other = (NonConstructableLexicalAnalyser)obj; + return this.loadedData.equals(other.loadedData); + } + } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCodeGenerator.java index ca2cbde..78e1963 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCodeGenerator.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCodeGenerator.java @@ -14,7 +14,13 @@ public String generate(ParseState parseRoot) { @Override public StorageValue getStorageRepresentation() { - return new StringStorageValue("TestStorableCustomCodeGenerator"); + return new StringStorageValue("TestStorableCustomCodeGenerator description"); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof TestStorableCustomCodeGenerator)) return false; + return true; + } + } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java index e3659dd..7e55b35 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java @@ -1,14 +1,15 @@ package test_aids.storage_entities.custom_components; import component_construction.storage.StorableCustomCompiler; +import test_aids.storage_entities.custom_components.loadable.*; public class TestStorableCustomCompiler extends StorableCustomCompiler { public TestStorableCustomCompiler() { super( - new TestStorableCustomLexicalAnalyser(), - new TestStorableCustomSyntaxAnalyser(), - new TestStorableCustomCodeGenerator() + new LoadableStorableCustomLexicalAnalyser(), + new LoadableStorableCustomSyntaxAnalyser(), + new LoadableStorableCustomCodeGenerator() ); } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomLexicalAnalyser.java index 318b037..b8a1055 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomLexicalAnalyser.java @@ -14,7 +14,13 @@ public Token[] analyse(String sentence) { @Override public StorageValue getStorageRepresentation() { - return new StringStorageValue("TestStorableCustomLexicalAnalyser"); + return new StringStorageValue("TestStorableCustomLexicalAnalyser description"); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof TestStorableCustomCodeGenerator)) return false; + return true; } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomSyntaxAnalyser.java index 8f01190..2fef464 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomSyntaxAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomSyntaxAnalyser.java @@ -15,7 +15,13 @@ public ParseState analyse(Token[] inputTokens) throws ParseFailedException { @Override public StorageValue getStorageRepresentation() { - return new StringStorageValue("TestStorableCustomSyntaxAnalyser"); + return new StringStorageValue("TestStorableCustomSyntaxAnalyser description"); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof TestStorableCustomCodeGenerator)) return false; + return true; } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomCodeGenerator.java new file mode 100644 index 0000000..08e9ef0 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomCodeGenerator.java @@ -0,0 +1,37 @@ +package test_aids.storage_entities.custom_components.loadable; + +import code_generation.CodeGenerator; +import component_construction.storage.StorableCustomCompiler; +import component_construction.storage.dynamic_loading.ReflectivelyLoadable; +import storage.external_interfaces.*; +import storage.storage_values.*; +import syntax_analysis.parsing.ParseState; + +public class LoadableStorableCustomCodeGenerator implements CodeGenerator, ReflectivelyLoadable, Storable { + + public StorageValue loadedData = new NullStorageValue(); + + @Override + public String generate(ParseState parseRoot) { + throw new UnsupportedOperationException("Unimplemented method 'generate'"); + } + + @Override + public void load(StorageValue data) { + loadedData = data; + } + + @Override + public StorageValue getStorageRepresentation() { + return loadedData; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof LoadableStorableCustomCodeGenerator)) return false; + + LoadableStorableCustomCodeGenerator other = (LoadableStorableCustomCodeGenerator)obj; + return this.loadedData.equals(other.loadedData); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomLexicalAnalyser.java similarity index 59% rename from src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomLexicalAnalyser.java rename to src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomLexicalAnalyser.java index bc19629..f9fb735 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomLexicalAnalyser.java @@ -1,14 +1,14 @@ -package test_aids.storage_entities.custom_components; +package test_aids.storage_entities.custom_components.loadable; import component_construction.storage.dynamic_loading.ReflectivelyLoadable; import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; -import storage.storage_values.StorageValue; +import storage.storage_values.*; public class LoadableStorableCustomLexicalAnalyser implements LexicalAnalyser, ReflectivelyLoadable, Storable { - public StorageValue loadedData; + public StorageValue loadedData = new NullStorageValue(); @Override public Token[] analyse(String sentence) { @@ -25,4 +25,12 @@ public StorageValue getStorageRepresentation() { return loadedData; } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof LoadableStorableCustomLexicalAnalyser)) return false; + + LoadableStorableCustomLexicalAnalyser other = (LoadableStorableCustomLexicalAnalyser)obj; + return this.loadedData.equals(other.loadedData); + } + } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomSyntaxAnalyser.java similarity index 50% rename from src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomSyntaxAnalyser.java rename to src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomSyntaxAnalyser.java index 18b6f9e..e4c8bde 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableStorableCustomSyntaxAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomSyntaxAnalyser.java @@ -1,14 +1,15 @@ -package test_aids.storage_entities.custom_components; +package test_aids.storage_entities.custom_components.loadable; +import component_construction.storage.dynamic_loading.ReflectivelyLoadable; import grammar_objects.Token; import storage.external_interfaces.*; -import storage.storage_values.StorageValue; +import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; import syntax_analysis.parsing.*; -public class LoadableStorableCustomSyntaxAnalyser implements SyntaxAnalyser, Loadable, Storable { +public class LoadableStorableCustomSyntaxAnalyser implements SyntaxAnalyser, ReflectivelyLoadable, Storable { - public StorageValue loadedData; + public StorageValue loadedData = new NullStorageValue(); @Override public ParseState analyse(Token[] inputTokens) throws ParseFailedException { @@ -25,4 +26,12 @@ public StorageValue getStorageRepresentation() { return loadedData; } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof LoadableStorableCustomSyntaxAnalyser)) return false; + + LoadableStorableCustomSyntaxAnalyser other = (LoadableStorableCustomSyntaxAnalyser)obj; + return this.loadedData.equals(other.loadedData); + } + } diff --git a/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java similarity index 95% rename from src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java rename to src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java index ef0f65c..38e4e82 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/LoadableTestStorableCustomCompiler.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java @@ -1,4 +1,4 @@ -package test_aids.storage_entities.custom_components; +package test_aids.storage_entities.custom_components.loadable; import java.util.Map; diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java index e4a37e3..7e6ff96 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java @@ -4,11 +4,12 @@ import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; -import storage.storage_values.StorageValue; +import storage.storage_values.*; +import test_aids.storage_entities.custom_components.loadable.LoadableStorableCustomSyntaxAnalyser; public class LoadableByStorableCustomLexicalAnalyser implements LexicalAnalyser, LoadableBy, Storable { - public StorageValue loadedData; + public StorageValue loadedData = new NullStorageValue(); @Override public Token[] analyse(String sentence) { @@ -24,4 +25,12 @@ public StorageValue getStorageRepresentation() { return loadedData; } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof LoadableByStorableCustomLexicalAnalyser)) return false; + + LoadableByStorableCustomLexicalAnalyser other = (LoadableByStorableCustomLexicalAnalyser)obj; + return this.loadedData.equals(other.loadedData); + } + } From e2fec8b5c0db7709e65c7f91fb566b794db8f4d3 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 8 Sep 2026 11:12:38 +0100 Subject: [PATCH 143/162] StorableCustomCompilerFactory exception arrow removal and ComponentInformation using StorageValue --- .../Factories/StorableCustomCompilerFactory.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java index 3371400..4714d03 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java @@ -105,7 +105,7 @@ private Map> tryGetMapValue(StorageValue loadValue) t } catch (ClassCastException e) { throw new IncorrectLoadValueFormat( - "MapStorageValue which maps String -> ListStorageValue", + "MapStorageValue which maps String to ListStorageValue", loadValue.getClass().getSimpleName(), e ); @@ -129,19 +129,19 @@ protected ComponentInformation getComponentDescription(StorageValue descripti } catch (ClassCastException e) { throw new IncorrectLoadValueFormat( - "MapStorageValue which maps String -> ListStorageValue", - "MapStorageValue which maps String -> " + description.getClass().getSimpleName(), + "MapStorageValue which maps String to ListStorageValue", + "MapStorageValue which maps String to " + description.getClass().getSimpleName(), e ); } return new ComponentInformation( ((StringStorageValue)entry.get(0)).getValue(), - (ListStorageValue)entry.get(1) + entry.get(1) ); } - protected record ComponentInformation(String name, ListStorageValue description) {} + protected record ComponentInformation(String name, StorageValue description) {} @SuppressWarnings("unchecked") /** From bf33cde560057b75fa3d3ed7d73aff699bf2a143 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Tue, 8 Sep 2026 11:14:11 +0100 Subject: [PATCH 144/162] CompilerStorageTests start Tests reworked from StorageTests, multiple failing. All tests should be double checked to ensure specific relevance to CompilerStorageTests --- .../storage/CompilerStorageTests.java | 1071 ++++++++++++++++- 1 file changed, 1064 insertions(+), 7 deletions(-) diff --git a/src/test/java/component_construction/storage/CompilerStorageTests.java b/src/test/java/component_construction/storage/CompilerStorageTests.java index 0f9b03d..44fb698 100644 --- a/src/test/java/component_construction/storage/CompilerStorageTests.java +++ b/src/test/java/component_construction/storage/CompilerStorageTests.java @@ -1,24 +1,1081 @@ package component_construction.storage; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; +import java.io.*; +import java.nio.file.*; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; -import storage.exceptions.NullStorageObjectException; +import storage.exceptions.*; +import storage.value_formatters.ValueFormatter; +import storage.value_formatters.ValueToStringFormatter; +import test_aids.exceptions.ExampleException; +import test_aids.storage_entities.custom_components.*; +import test_aids.storage_entities.custom_components.loadable.LoadableTestStorableCustomCompiler; +import test_aids.test_extensions.test_files.*; +import test_aids.test_storage.*; +@ExtendWith(UseTestFileExtension.class) public class CompilerStorageTests { @Test - public void store_null() { + public void setTargetPath() { + Path expectedPath = Path.of("./testPath"); CompilerStorage storage = new CompilerStorage(); + + + storage.setTargetPath(expectedPath); + Path actualPath = storage.getTargetFilepath(); + + + assertEquals(expectedPath, actualPath); + } + + @Test + public void setAbsoluteTargetPath() { + Path expectedPath = Path.of("testPath"); + CompilerStorage storage = new CompilerStorage(); + + + storage.setAbsoluteTargetPath(expectedPath.toString()); + Path actualPath = storage.getTargetFilepath(); + + + assertEquals(expectedPath, actualPath); + } + + @Test + public void setRelativeTargetPath() { + String fileName = "testPath.txt"; + CompilerStorage storage = new CompilerStorage(); + + + storage.setRelativeTargetPath(fileName); + Path actualPath = storage.getTargetFilepath(); + + + Path expectedPath = Path.of("./" + fileName); + assertEquals(expectedPath, actualPath); + } + + @Test + @UseTestFile + public void storeNull(Path testFile) throws IOException { + StorableCustomCompiler compiler = null; + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + assertThrows(NullStorageObjectException.class, () -> storage.store(compiler)); + } + + @Test + @UseTestFile + public void store(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + ValueFormatter formatter = new TestStringValueFormatter(); + String expectedString = formatter.format(compiler.getStorageRepresentation()); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(formatter); + + + storage.store(compiler); + String actualString = Files.readString(testFile); + + + assertEquals(expectedString, actualString); + } + + @Test + @UseTestFile + public void storeString_IncorrectFormatter(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.store(compiler)); + } + + @Test + @UseTestFile + public void storeString_FileWriteError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(compiler) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storeString_FormatterError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(compiler) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void load(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + ValueFormatter formatter = new ValueToStringFormatter(); + String testString = formatter.format(expectedCompiler.getStorageRepresentation()); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(formatter); + + Files.writeString(testFile, testString); + + + StorableCustomCompiler actualCompiler = storage.load(); + + + assertEquals(expectedCompiler, actualCompiler); + } + + @Test + @UseTestFile + public void loadString_IncorrectFormatter(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, testString); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.load()); + } + + @Test + @UseTestFile + public void loadString_FileWriteError(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.load() + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void loadString_FormatterError(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + Files.writeString(testFile, testString); + + + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.load() + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + void convertAndStoreNull(Path testFile) throws IOException { + StorableCustomCompiler compiler = null; + ValueFormatter formatter = new TestStringValueFormatter(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + assertThrows(NullStorageObjectException.class, () -> { + try (outputStream) { + storage.convertAndStore(compiler, formatter, outputStream); + } + }); + } + + @Test + @UseTestFile + void convertAndStoreString(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + String expectedString = compiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new TestStringValueFormatter(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + storage.convertAndStore(compiler, formatter, outputStream); + } + + + String actualString = Files.readString(testFile); + assertEquals(expectedString, actualString); + } + + @Test + @UseTestFile + public void convertAndStoreString_IncorrectFormatter(Path testFile) throws IOException { + + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + ValueFormatter formatter = new TestIntegerValueFormatter(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + try (outputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.convertAndStore(compiler, formatter, outputStream)); + } + } + + @Test + @UseTestFile + public void convertAndStoreString_FileWriteError(Path testFile) throws IOException { + + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + ValueFormatter formatter = new TestStringValueFormatter(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + try (outputStream) { + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.convertAndStore(compiler, formatter, outputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void convertAndStoreString_FormatterError(Path testFile) throws IOException { + + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + ValueFormatter formatter = new TestStringErrorValueFormatter(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + try (outputStream) { + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.convertAndStore(compiler, formatter, outputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + void convertAndLoadStringInto(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + storage.convertAndLoadInto(actualCompiler, inputStream); + } + + + assertEquals(expectedCompiler, actualCompiler); + } + + @Test + @UseTestFile + public void convertAndLoadStringInto_IncorrectFormatter(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFormatter(new TestIntegerValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.convertAndLoadInto(actualCompiler, inputStream)); + } + } + + @Test + @UseTestFile + public void convertAndLoadStringInto_FileWriteError(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualComipler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestStringErrorStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.convertAndLoadInto(actualComipler, inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void convertAndLoadStringInto_FormatterError(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFormatter(new TestStringErrorValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.convertAndLoadInto(actualCompiler, inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + void convertThenFormatAndLoadStringInto(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new TestStringValueFormatter(); + + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + storage.convertAndLoadInto(actualCompiler, formatter, inputStream); + } + + assertEquals(expectedCompiler, actualCompiler); + } + + @Test + @UseTestFile + public void convertThenFormatAndLoadStringInto_IncorrectFormatter(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new TestIntegerValueFormatter(); + + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.convertAndLoadInto(actualCompiler, formatter, inputStream)); + } + } + + @Test + @UseTestFile + public void convertThenFormatAndLoadStringInto_FileWriteError(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new TestStringValueFormatter(); + + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.convertAndLoadInto(actualCompiler, formatter, inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void convertThenFormatAndLoadStringInto_FormatterError(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new TestStringErrorValueFormatter(); + + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.convertAndLoadInto(actualCompiler, formatter, inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void storeNullToStream(Path testFile) throws IOException { + StorableCustomCompiler compiler = null; + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + assertThrows(NullStorageObjectException.class, () -> { + try (outputStream) { + storage.store(compiler, outputStream); + } + }); + } + + @Test + @UseTestFile + public void storeStringToStream(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + String expectedString = compiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + storage.store(compiler, outputStream); + } + + + String actualString = Files.readString(testFile); + assertEquals(expectedString, actualString); + } + + @Test + @UseTestFile + public void storeStringToStream_IncorrectFormatter(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.store(compiler, outputStream)); + } + } + + @Test + @UseTestFile + public void storeStringToStream_FileWriteError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(compiler, outputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void storeStringToStream_FormatterError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + OutputStream outputStream = new FileOutputStream(testFile.toFile()); + + + try (outputStream) { + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(compiler, outputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void loadStringFromInputStream(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + StorableCustomCompiler actualcompiler = storage.load(inputStream); + + + assertEquals(expectedCompiler, actualcompiler); + } + + @Test + @UseTestFile + public void loadStringFromInputStream_IncorrectFormatter(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + assertThrows(StorageFormatMismatchException.class, () -> storage.load(inputStream)); + } + } + + @Test + @UseTestFile + public void loadStringFromInputStream_FileWriteError(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.load(inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void loadStringFromInputStream_FormatterError(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + Files.writeString(testFile, testString); + + InputStream inputStream = new FileInputStream(testFile.toFile()); + + + try (inputStream) { + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.load(inputStream) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + } + + @Test + @UseTestFile + public void storeStorableOfNull(Path testFile) throws IOException { + StorableCustomCompiler compiler = null; + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + assertThrows(NullStorageObjectException.class, () -> storage.store(compiler)); + } + + @Test + @UseTestFile + public void storeStorableOfString(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + String expectedString = compiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + storage.store(compiler); + String actualString = Files.readString(testFile); + + + assertEquals(expectedString, actualString); + } + + @Test + @UseTestFile + public void storeStorableOfString_IncorrectFormatter(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.store(compiler)); + } + + @Test + @UseTestFile + public void storeStorableOfString_FileWriteError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(compiler) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storeStorableOfString_FormatterError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(compiler) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storeStorableOfNullAtFilepath(Path testFile) throws IOException { + StorableCustomCompiler compiler = null; + CompilerStorage storage = new CompilerStorage() + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + assertThrows(NullStorageObjectException.class, () -> storage.store(compiler, testFile.toString())); + } + + @Test + @UseTestFile + public void storeStorableOfStringAtFilepath(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + String expectedString = compiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + storage.store(compiler, testFile.toString()); + String actualString = Files.readString(testFile); + + + assertEquals(expectedString, actualString); + } + + @Test + @UseTestFile + public void storeStorableOfStringAtFilepath_IncorrectFormatter(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.store(compiler, testFile.toString())); + } + + @Test + @UseTestFile + public void storeStorableOfStringAtFilepath_FileWriteError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(compiler, testFile.toString()) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storeStorableOfStringAtFilepath_FormatterError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(compiler, testFile.toString()) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storecompilerOfNull(Path testFile) throws IOException { StorableCustomCompiler compiler = null; + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); assertThrows(NullStorageObjectException.class, () -> storage.store(compiler)); } - //store(StorableCustomCompiler) + @Test + @UseTestFile + public void storecompilerOfString(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + String expectedString = compiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + storage.store(compiler); + String actualString = Files.readString(testFile); + + + assertEquals(expectedString, actualString); + } + + @Test + @UseTestFile + public void storecompilerOfString_IncorrectFormatter(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.store(compiler)); + } + + @Test + @UseTestFile + public void storecompilerOfString_FileWriteError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + + StoreFailureException exception = assertThrows( + StoreFailureException.class, + () -> storage.store(compiler) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void storecompilerOfString_FormatterError(Path testFile) throws IOException { + StorableCustomCompiler compiler = new TestStorableCustomCompiler(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + + FormattingException exception = assertThrows( + FormattingException.class, + () -> storage.store(compiler) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + void LoadStringInto(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + + storage.loadInto(actualCompiler); + + + assertEquals(expectedCompiler, actualCompiler); + } + + @Test + @UseTestFile + public void LoadStringInto_IncorrectFormatter(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestIntegerStreamEditor()); + + Files.writeString(testFile, expectedString); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.loadInto(actualCompiler)); + } + + @Test + @UseTestFile + public void LoadStringInto_FileWriteError(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFormatter(new TestStringValueFormatter()) + .setFileEditor(new TestStringErrorStreamEditor()); + + Files.writeString(testFile, expectedString); + + + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.loadInto(actualCompiler) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void LoadStringInto_FormatterError(Path testFile) throws IOException { + LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); + LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); + String expectedString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFormatter(new TestStringErrorValueFormatter()) + .setFileEditor(new TestStringStreamEditor()); + + Files.writeString(testFile, expectedString); + + + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.loadInto(actualCompiler) + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void loadStringFromTargetPath(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + + StorableCustomCompiler actualcompiler = storage.load(); + + + assertEquals(expectedCompiler, actualcompiler); + } + + @Test + @UseTestFile + public void loadStringFromTargetPath_IncorrectFormatter(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestIntegerValueFormatter()); + + Files.writeString(testFile, testString); + + + assertThrows(StorageFormatMismatchException.class, () -> storage.load()); + } + + @Test + @UseTestFile + public void loadStringFromTargetPath_FileWriteError(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringErrorStreamEditor()) + .setFormatter(new TestStringValueFormatter()); + + Files.writeString(testFile, testString); + + + LoadFailureException exception = assertThrows( + LoadFailureException.class, + () -> storage.load() + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } + + @Test + @UseTestFile + public void loadStringFromTargetPath_FormatterError(Path testFile) throws IOException { + StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); + String testString = expectedCompiler.getStorageRepresentation().toString(); + CompilerStorage storage = new CompilerStorage() + .setTargetPath(testFile) + .setFileEditor(new TestStringStreamEditor()) + .setFormatter(new TestStringErrorValueFormatter()); + + Files.writeString(testFile, testString); + + + FormatParseException exception = assertThrows( + FormatParseException.class, + () -> storage.load() + ); + assertInstanceOf(ExampleException.class, exception.getCause()); + } - //load() valid format - //load() incomplete format - //load() incrrect format } From 863386b2d5697f10f6e7412e6cbe8957e424a7ca Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 10 Sep 2026 20:39:09 +0100 Subject: [PATCH 145/162] CompilerStorageTests passing --- .../storage/CompilerStorageTests.java | 50 +++++++++++-------- .../LoadableTestStorableCustomCompiler.java | 12 +++-- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/test/java/component_construction/storage/CompilerStorageTests.java b/src/test/java/component_construction/storage/CompilerStorageTests.java index 44fb698..61a07a3 100644 --- a/src/test/java/component_construction/storage/CompilerStorageTests.java +++ b/src/test/java/component_construction/storage/CompilerStorageTests.java @@ -236,8 +236,8 @@ void convertAndStoreNull(Path testFile) throws IOException { @UseTestFile void convertAndStoreString(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); - String expectedString = compiler.getStorageRepresentation().toString(); ValueFormatter formatter = new TestStringValueFormatter(); + String expectedString = formatter.format(compiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()); @@ -318,10 +318,11 @@ public void convertAndStoreString_FormatterError(Path testFile) throws IOExcepti void convertAndLoadStringInto(Path testFile) throws IOException { LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); - String expectedString = expectedCompiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(expectedCompiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) - .setFormatter(new TestStringValueFormatter()) + .setFormatter(formatter) .setFileEditor(new TestStringStreamEditor()); Files.writeString(testFile, expectedString); @@ -413,8 +414,8 @@ public void convertAndLoadStringInto_FormatterError(Path testFile) throws IOExce void convertThenFormatAndLoadStringInto(Path testFile) throws IOException { LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); - String expectedString = expectedCompiler.getStorageRepresentation().toString(); - ValueFormatter formatter = new TestStringValueFormatter(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(expectedCompiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) @@ -529,11 +530,12 @@ public void storeNullToStream(Path testFile) throws IOException { @UseTestFile public void storeStringToStream(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); - String expectedString = compiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(compiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) - .setFormatter(new TestStringValueFormatter()); + .setFormatter(formatter); OutputStream outputStream = new FileOutputStream(testFile.toFile()); @@ -610,13 +612,14 @@ public void storeStringToStream_FormatterError(Path testFile) throws IOException @UseTestFile public void loadStringFromInputStream(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); - String testString = expectedCompiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(expectedCompiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) - .setFormatter(new TestStringValueFormatter()); + .setFormatter(formatter); - Files.writeString(testFile, testString); + Files.writeString(testFile, expectedString); InputStream inputStream = new FileInputStream(testFile.toFile()); @@ -712,11 +715,12 @@ public void storeStorableOfNull(Path testFile) throws IOException { @UseTestFile public void storeStorableOfString(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); - String expectedString = compiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(compiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) - .setFormatter(new TestStringValueFormatter()); + .setFormatter(formatter); storage.store(compiler); @@ -789,10 +793,11 @@ public void storeStorableOfNullAtFilepath(Path testFile) throws IOException { @UseTestFile public void storeStorableOfStringAtFilepath(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); - String expectedString = compiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(compiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setFileEditor(new TestStringStreamEditor()) - .setFormatter(new TestStringValueFormatter()); + .setFormatter(formatter); storage.store(compiler, testFile.toString()); @@ -863,11 +868,12 @@ public void storecompilerOfNull(Path testFile) throws IOException { @UseTestFile public void storecompilerOfString(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); - String expectedString = compiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(compiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) - .setFormatter(new TestStringValueFormatter()); + .setFormatter(formatter); storage.store(compiler); @@ -929,10 +935,11 @@ public void storecompilerOfString_FormatterError(Path testFile) throws IOExcepti void LoadStringInto(Path testFile) throws IOException { LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); - String expectedString = expectedCompiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(expectedCompiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) - .setFormatter(new TestStringValueFormatter()) + .setFormatter(formatter) .setFileEditor(new TestStringStreamEditor()); Files.writeString(testFile, expectedString); @@ -1007,13 +1014,14 @@ public void LoadStringInto_FormatterError(Path testFile) throws IOException { @UseTestFile public void loadStringFromTargetPath(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); - String testString = expectedCompiler.getStorageRepresentation().toString(); + ValueFormatter formatter = new ValueToStringFormatter(); + String expectedString = formatter.format(expectedCompiler.getStorageRepresentation()); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) - .setFormatter(new TestStringValueFormatter()); + .setFormatter(formatter); - Files.writeString(testFile, testString); + Files.writeString(testFile, expectedString); StorableCustomCompiler actualcompiler = storage.load(); diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java index 38e4e82..4415954 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java @@ -19,14 +19,18 @@ public LoadableTestStorableCustomCompiler() { @Override public void load(StorageValue data) { Map> description = ((MapStorageValue)data).getValue(); - + + StorageValue lexicalAnalyserDescription = ((ListStorageValue)description.get("lexicalAnalyser")).getValue().get(1); + StorageValue syntaxAnalyserDescription = ((ListStorageValue)description.get("lexicalAnalyser")).getValue().get(1); + StorageValue codeGeneratorDescription = ((ListStorageValue)description.get("lexicalAnalyser")).getValue().get(1); + lexicalAnalyser = new LoadableStorableCustomLexicalAnalyser(); syntaxAnalyser = new LoadableStorableCustomSyntaxAnalyser(); codeGenerator = new LoadableStorableCustomCodeGenerator(); - ((LoadableStorableCustomLexicalAnalyser)lexicalAnalyser).load(description.get("lexicalAnalyser")); - ((LoadableStorableCustomSyntaxAnalyser)syntaxAnalyser).load(description.get("syntaxAnalyser")); - ((LoadableStorableCustomCodeGenerator)codeGenerator).load(description.get("codeGenerator")); + ((LoadableStorableCustomLexicalAnalyser)lexicalAnalyser).load(lexicalAnalyserDescription); + ((LoadableStorableCustomSyntaxAnalyser)syntaxAnalyser).load(syntaxAnalyserDescription); + ((LoadableStorableCustomCodeGenerator)codeGenerator).load(codeGeneratorDescription); } } From 37e23981f5fe283143d1c91c3df0f5e69843a8a9 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 10 Sep 2026 23:08:47 +0100 Subject: [PATCH 146/162] CompilerStorageTests cleanup --- .../storage/CompilerStorageTests.java | 66 ++++++------------- 1 file changed, 19 insertions(+), 47 deletions(-) diff --git a/src/test/java/component_construction/storage/CompilerStorageTests.java b/src/test/java/component_construction/storage/CompilerStorageTests.java index 61a07a3..d1c9dba 100644 --- a/src/test/java/component_construction/storage/CompilerStorageTests.java +++ b/src/test/java/component_construction/storage/CompilerStorageTests.java @@ -7,8 +7,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import storage.exceptions.*; -import storage.value_formatters.ValueFormatter; -import storage.value_formatters.ValueToStringFormatter; +import storage.value_formatters.*; import test_aids.exceptions.ExampleException; import test_aids.storage_entities.custom_components.*; import test_aids.storage_entities.custom_components.loadable.LoadableTestStorableCustomCompiler; @@ -92,7 +91,7 @@ public void store(Path testFile) throws IOException { @Test @UseTestFile - public void storeString_IncorrectFormatter(Path testFile) throws IOException { + public void store_IncorrectFormatter(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) @@ -105,7 +104,7 @@ public void storeString_IncorrectFormatter(Path testFile) throws IOException { @Test @UseTestFile - public void storeString_FileWriteError(Path testFile) throws IOException { + public void store_FileWriteError(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) @@ -122,7 +121,7 @@ public void storeString_FileWriteError(Path testFile) throws IOException { @Test @UseTestFile - public void storeString_FormatterError(Path testFile) throws IOException { + public void store_FormatterError(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) @@ -159,23 +158,19 @@ public void load(Path testFile) throws IOException { @Test @UseTestFile - public void loadString_IncorrectFormatter(Path testFile) throws IOException { - StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); - String testString = expectedCompiler.getStorageRepresentation().toString(); + public void load_IncorrectFormatter(Path testFile) throws IOException { CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) .setFormatter(new TestIntegerValueFormatter()); - Files.writeString(testFile, testString); - assertThrows(StorageFormatMismatchException.class, () -> storage.load()); } @Test @UseTestFile - public void loadString_FileWriteError(Path testFile) throws IOException { + public void load_FileWriteError(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); String testString = expectedCompiler.getStorageRepresentation().toString(); CompilerStorage storage = new CompilerStorage() @@ -195,7 +190,7 @@ public void loadString_FileWriteError(Path testFile) throws IOException { @Test @UseTestFile - public void loadString_FormatterError(Path testFile) throws IOException { + public void load_FormatterError(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); String testString = expectedCompiler.getStorageRepresentation().toString(); CompilerStorage storage = new CompilerStorage() @@ -257,7 +252,6 @@ void convertAndStoreString(Path testFile) throws IOException { @Test @UseTestFile public void convertAndStoreString_IncorrectFormatter(Path testFile) throws IOException { - StorableCustomCompiler compiler = new TestStorableCustomCompiler(); ValueFormatter formatter = new TestIntegerValueFormatter(); CompilerStorage storage = new CompilerStorage() @@ -274,7 +268,6 @@ public void convertAndStoreString_IncorrectFormatter(Path testFile) throws IOExc @Test @UseTestFile public void convertAndStoreString_FileWriteError(Path testFile) throws IOException { - StorableCustomCompiler compiler = new TestStorableCustomCompiler(); ValueFormatter formatter = new TestStringValueFormatter(); CompilerStorage storage = new CompilerStorage() @@ -295,7 +288,6 @@ public void convertAndStoreString_FileWriteError(Path testFile) throws IOExcepti @Test @UseTestFile public void convertAndStoreString_FormatterError(Path testFile) throws IOException { - StorableCustomCompiler compiler = new TestStorableCustomCompiler(); ValueFormatter formatter = new TestStringErrorValueFormatter(); CompilerStorage storage = new CompilerStorage() @@ -341,16 +333,12 @@ void convertAndLoadStringInto(Path testFile) throws IOException { @Test @UseTestFile public void convertAndLoadStringInto_IncorrectFormatter(Path testFile) throws IOException { - LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); - String expectedString = expectedCompiler.getStorageRepresentation().toString(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFormatter(new TestIntegerValueFormatter()) .setFileEditor(new TestStringStreamEditor()); - Files.writeString(testFile, expectedString); - InputStream inputStream = new FileInputStream(testFile.toFile()); @@ -436,17 +424,13 @@ void convertThenFormatAndLoadStringInto(Path testFile) throws IOException { @Test @UseTestFile public void convertThenFormatAndLoadStringInto_IncorrectFormatter(Path testFile) throws IOException { - LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); - String expectedString = expectedCompiler.getStorageRepresentation().toString(); ValueFormatter formatter = new TestIntegerValueFormatter(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()); - Files.writeString(testFile, expectedString); - InputStream inputStream = new FileInputStream(testFile.toFile()); @@ -528,7 +512,7 @@ public void storeNullToStream(Path testFile) throws IOException { @Test @UseTestFile - public void storeStringToStream(Path testFile) throws IOException { + public void storeToStream(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); ValueFormatter formatter = new ValueToStringFormatter(); String expectedString = formatter.format(compiler.getStorageRepresentation()); @@ -551,7 +535,7 @@ public void storeStringToStream(Path testFile) throws IOException { @Test @UseTestFile - public void storeStringToStream_IncorrectFormatter(Path testFile) throws IOException { + public void storeToStream_IncorrectFormatter(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) @@ -568,7 +552,7 @@ public void storeStringToStream_IncorrectFormatter(Path testFile) throws IOExcep @Test @UseTestFile - public void storeStringToStream_FileWriteError(Path testFile) throws IOException { + public void storeToStream_FileWriteError(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) @@ -589,7 +573,7 @@ public void storeStringToStream_FileWriteError(Path testFile) throws IOException @Test @UseTestFile - public void storeStringToStream_FormatterError(Path testFile) throws IOException { + public void storeToStream_FormatterError(Path testFile) throws IOException { StorableCustomCompiler compiler = new TestStorableCustomCompiler(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) @@ -610,7 +594,7 @@ public void storeStringToStream_FormatterError(Path testFile) throws IOException @Test @UseTestFile - public void loadStringFromInputStream(Path testFile) throws IOException { + public void loadFromInputStream(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); ValueFormatter formatter = new ValueToStringFormatter(); String expectedString = formatter.format(expectedCompiler.getStorageRepresentation()); @@ -632,16 +616,12 @@ public void loadStringFromInputStream(Path testFile) throws IOException { @Test @UseTestFile - public void loadStringFromInputStream_IncorrectFormatter(Path testFile) throws IOException { - StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); - String testString = expectedCompiler.getStorageRepresentation().toString(); + public void loadFromInputStream_IncorrectFormatter(Path testFile) throws IOException { CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) .setFormatter(new TestIntegerValueFormatter()); - Files.writeString(testFile, testString); - InputStream inputStream = new FileInputStream(testFile.toFile()); @@ -652,7 +632,7 @@ public void loadStringFromInputStream_IncorrectFormatter(Path testFile) throws I @Test @UseTestFile - public void loadStringFromInputStream_FileWriteError(Path testFile) throws IOException { + public void loadFromInputStream_FileWriteError(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); String testString = expectedCompiler.getStorageRepresentation().toString(); CompilerStorage storage = new CompilerStorage() @@ -676,7 +656,7 @@ public void loadStringFromInputStream_FileWriteError(Path testFile) throws IOExc @Test @UseTestFile - public void loadStringFromInputStream_FormatterError(Path testFile) throws IOException { + public void loadFromInputStream_FormatterError(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); String testString = expectedCompiler.getStorageRepresentation().toString(); CompilerStorage storage = new CompilerStorage() @@ -954,16 +934,12 @@ void LoadStringInto(Path testFile) throws IOException { @Test @UseTestFile public void LoadStringInto_IncorrectFormatter(Path testFile) throws IOException { - LoadableTestStorableCustomCompiler expectedCompiler = new LoadableTestStorableCustomCompiler(); LoadableTestStorableCustomCompiler actualCompiler = new LoadableTestStorableCustomCompiler(); - String expectedString = expectedCompiler.getStorageRepresentation().toString(); CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFormatter(new TestStringValueFormatter()) .setFileEditor(new TestIntegerStreamEditor()); - Files.writeString(testFile, expectedString); - assertThrows(StorageFormatMismatchException.class, () -> storage.loadInto(actualCompiler)); } @@ -1012,7 +988,7 @@ public void LoadStringInto_FormatterError(Path testFile) throws IOException { @Test @UseTestFile - public void loadStringFromTargetPath(Path testFile) throws IOException { + public void loadFromTargetPath(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); ValueFormatter formatter = new ValueToStringFormatter(); String expectedString = formatter.format(expectedCompiler.getStorageRepresentation()); @@ -1032,23 +1008,19 @@ public void loadStringFromTargetPath(Path testFile) throws IOException { @Test @UseTestFile - public void loadStringFromTargetPath_IncorrectFormatter(Path testFile) throws IOException { - StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); - String testString = expectedCompiler.getStorageRepresentation().toString(); + public void loadFromTargetPath_IncorrectFormatter(Path testFile) throws IOException { CompilerStorage storage = new CompilerStorage() .setTargetPath(testFile) .setFileEditor(new TestStringStreamEditor()) .setFormatter(new TestIntegerValueFormatter()); - Files.writeString(testFile, testString); - assertThrows(StorageFormatMismatchException.class, () -> storage.load()); } @Test @UseTestFile - public void loadStringFromTargetPath_FileWriteError(Path testFile) throws IOException { + public void loadFromTargetPath_FileWriteError(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); String testString = expectedCompiler.getStorageRepresentation().toString(); CompilerStorage storage = new CompilerStorage() @@ -1068,7 +1040,7 @@ public void loadStringFromTargetPath_FileWriteError(Path testFile) throws IOExce @Test @UseTestFile - public void loadStringFromTargetPath_FormatterError(Path testFile) throws IOException { + public void loadFromTargetPath_FormatterError(Path testFile) throws IOException { StorableCustomCompiler expectedCompiler = new TestStorableCustomCompiler(); String testString = expectedCompiler.getStorageRepresentation().toString(); CompilerStorage storage = new CompilerStorage() From 700789d481c9d2dce9f812b2f381df01234acb99 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 13 Sep 2026 22:12:04 +0100 Subject: [PATCH 147/162] Make CompilerBuilderTests use assertDoesNotThrow --- .../component_construction/builders/CompilerBuilderTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/component_construction/builders/CompilerBuilderTests.java b/src/test/java/component_construction/builders/CompilerBuilderTests.java index 09c3e51..bae9028 100644 --- a/src/test/java/component_construction/builders/CompilerBuilderTests.java +++ b/src/test/java/component_construction/builders/CompilerBuilderTests.java @@ -32,7 +32,7 @@ public void basicCompilerBuilder() { ); - builder.createCompiler(); + assertDoesNotThrow(() -> builder.createCompiler()); } @Test @@ -138,6 +138,6 @@ public void nullLexicalInputs() { ); - builder.createCompiler(); + assertDoesNotThrow(() -> builder.createCompiler()); } } From 89e8b72fa16938c4db1ffd5962b6f8ddc46c4d21 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 13 Sep 2026 23:38:10 +0100 Subject: [PATCH 148/162] First StorableCustomCompilerBuilderTests --- .../StorableCustomCompilerBuilderTests.java | 149 +++++++++++++++++- ...estStorableCustomCodeGeneratorFactory.java | 15 ++ ...tStorableCustomLexicalAnalyserFactory.java | 20 +++ ...stStorableCustomSyntaxAnalyserFactory.java | 15 ++ 4 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomCodeGeneratorFactory.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomLexicalAnalyserFactory.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomSyntaxAnalyserFactory.java diff --git a/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java b/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java index a53ebc3..4f1a707 100644 --- a/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java +++ b/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java @@ -1,5 +1,152 @@ package component_construction.storage.builders; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +import component_construction.ParameterError; +import grammars.basic_identifier.BasicIdentifierGrammar; +import grammars.basic_identifier.convertors.XToYToXSemantic; +import lexical_analysis.DynamicTokenRegex; +import test_aids.storage_entities.custom_components.factories.*; + public class StorableCustomCompilerBuilderTests { - // TODO + + @Test + public void getSelf() { + StorableCustomCompilerBuilder builder = new StorableCustomCompilerBuilder(); + + + assertEquals(builder, builder.getThis()); + } + + @Test + public void basicCompilerBuilder() { + StorableCustomCompilerBuilder builder = new StorableCustomCompilerBuilder(); + builder.setComponents( + new TestStorableCustomLexicalAnalyserFactory(), + new TestStorableCustomSyntaxAnalyserFactory(), + new TestStorableCustomCodeGeneratorFactory(), + BasicIdentifierGrammar.produce(), + XToYToXSemantic.produce(), + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") //TODO: Using [0-9]+(\\.[0-9]+)? for all tests would be better + } + ); + + + assertDoesNotThrow(() -> builder.createCompiler()); + } + + @Test + public void nullComponentInputs() { + StorableCustomCompilerBuilder builder1 = new StorableCustomCompilerBuilder(); + StorableCustomCompilerBuilder builder2 = new StorableCustomCompilerBuilder(); + StorableCustomCompilerBuilder builder3 = new StorableCustomCompilerBuilder(); + StorableCustomCompilerBuilder builder4 = new StorableCustomCompilerBuilder(); + StorableCustomCompilerBuilder builder5 = new StorableCustomCompilerBuilder(); + + builder1.setComponents( + null, + new TestStorableCustomSyntaxAnalyserFactory(), + new TestStorableCustomCodeGeneratorFactory(), + BasicIdentifierGrammar.produce(), + XToYToXSemantic.produce(), + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + } + ); + builder2.setComponents( + new TestStorableCustomLexicalAnalyserFactory(), + null, + new TestStorableCustomCodeGeneratorFactory(), + BasicIdentifierGrammar.produce(), + XToYToXSemantic.produce(), + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + } + ); + builder3.setComponents( + new TestStorableCustomLexicalAnalyserFactory(), + new TestStorableCustomSyntaxAnalyserFactory(), + null, + BasicIdentifierGrammar.produce(), + XToYToXSemantic.produce(), + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + } + ); + builder4.setComponents( + new TestStorableCustomLexicalAnalyserFactory(), + new TestStorableCustomSyntaxAnalyserFactory(), + new TestStorableCustomCodeGeneratorFactory(), + null, + XToYToXSemantic.produce(), + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + } + ); + builder5.setComponents( + new TestStorableCustomLexicalAnalyserFactory(), + new TestStorableCustomSyntaxAnalyserFactory(), + new TestStorableCustomCodeGeneratorFactory(), + BasicIdentifierGrammar.produce(), + null, + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + } + ); + + + assertThrows(ParameterError.class, () -> builder1.createCompiler()); + assertThrows(ParameterError.class, () -> builder2.createCompiler()); + assertThrows(ParameterError.class, () -> builder3.createCompiler()); + assertThrows(ParameterError.class, () -> builder4.createCompiler()); + assertThrows(ParameterError.class, () -> builder5.createCompiler()); + } + + @Test + public void nullLexicalInputs() { + StorableCustomCompilerBuilder builder = new StorableCustomCompilerBuilder(); + builder.setComponents( + new TestStorableCustomLexicalAnalyserFactory(), + new TestStorableCustomSyntaxAnalyserFactory(), + new TestStorableCustomCodeGeneratorFactory(), + BasicIdentifierGrammar.produce(), + XToYToXSemantic.produce(), + null, + null, + null, + null + ); + + + assertDoesNotThrow(() -> builder.createCompiler()); + } + + // TODO: Catch NonStorableComponentException for non-storable analysers and code generator + } diff --git a/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomCodeGeneratorFactory.java b/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomCodeGeneratorFactory.java new file mode 100644 index 0000000..abbe686 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomCodeGeneratorFactory.java @@ -0,0 +1,15 @@ +package test_aids.storage_entities.custom_components.factories; + +import code_generation.CodeGenerator; +import component_construction.factories.code_generation.CodeGeneratorFactory; +import grammar_objects.RuleConvertor; +import test_aids.storage_entities.custom_components.TestStorableCustomCodeGenerator; + +public class TestStorableCustomCodeGeneratorFactory implements CodeGeneratorFactory { + + @Override + public CodeGenerator produceGenerator(RuleConvertor ruleConvertor) { + return new TestStorableCustomCodeGenerator(); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomLexicalAnalyserFactory.java b/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomLexicalAnalyserFactory.java new file mode 100644 index 0000000..e81ffb7 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomLexicalAnalyserFactory.java @@ -0,0 +1,20 @@ +package test_aids.storage_entities.custom_components.factories; + +import component_construction.factories.lexical_analysis.LexicalAnalyserFactory; +import lexical_analysis.DynamicTokenRegex; +import lexical_analysis.LexicalAnalyser; +import test_aids.storage_entities.custom_components.TestStorableCustomLexicalAnalyser; + +public class TestStorableCustomLexicalAnalyserFactory implements LexicalAnalyserFactory { + + @Override + public LexicalAnalyser produceAnalyser( + String[] whitespaceDelimiters, + String[] stronglyReservedWords, + String[] weaklyReservedWords, + DynamicTokenRegex[] dynamicTokenRegex + ) { + return new TestStorableCustomLexicalAnalyser(); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomSyntaxAnalyserFactory.java b/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomSyntaxAnalyserFactory.java new file mode 100644 index 0000000..a942411 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/factories/TestStorableCustomSyntaxAnalyserFactory.java @@ -0,0 +1,15 @@ +package test_aids.storage_entities.custom_components.factories; + +import component_construction.factories.syntax_analysis.SyntaxAnalyserFactory; +import grammar_objects.GrammarParts; +import syntax_analysis.SyntaxAnalyser; +import test_aids.storage_entities.custom_components.TestStorableCustomSyntaxAnalyser; + +public class TestStorableCustomSyntaxAnalyserFactory implements SyntaxAnalyserFactory { + + @Override + public SyntaxAnalyser produceAnalyser(GrammarParts parts) { + return new TestStorableCustomSyntaxAnalyser(); + } + +} From 868baf4e6b44f2f318930706333c9438a93f517a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 17 Sep 2026 21:02:50 +0100 Subject: [PATCH 149/162] Non storable components for StorableCustomCompilerBuilderTests --- .../StorableCustomCompilerBuilderTests.java | 79 +++++++++++++++++-- .../TestCustomCodeGenerator.java | 13 +++ .../TestCustomLexicalAnalyser.java | 13 +++ .../TestCustomSyntaxAnalyser.java | 14 ++++ .../TestCustomCodeGeneratorFactory.java | 15 ++++ .../TestCustomLexicalAnalyserFactory.java | 20 +++++ .../TestCustomSyntaxAnalyserFactory.java | 15 ++++ 7 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomCodeGeneratorFactory.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomLexicalAnalyserFactory.java create mode 100644 src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomSyntaxAnalyserFactory.java diff --git a/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java b/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java index 4f1a707..d2ce48b 100644 --- a/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java +++ b/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import component_construction.ParameterError; +import component_construction.storage.exceptions.NonStorableComponentException; import grammars.basic_identifier.BasicIdentifierGrammar; import grammars.basic_identifier.convertors.XToYToXSemantic; import lexical_analysis.DynamicTokenRegex; @@ -33,7 +34,7 @@ public void basicCompilerBuilder() { new String[] {}, new DynamicTokenRegex[] { new DynamicTokenRegex("[A-Za-z]+", "identifier"), - new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") //TODO: Using [0-9]+(\\.[0-9]+)? for all tests would be better + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") //TODO: Using [0-9]+(\\.[0-9]+)? for all tests would be better } ); @@ -60,7 +61,7 @@ public void nullComponentInputs() { new String[] {}, new DynamicTokenRegex[] { new DynamicTokenRegex("[A-Za-z]+", "identifier"), - new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") } ); builder2.setComponents( @@ -74,7 +75,7 @@ public void nullComponentInputs() { new String[] {}, new DynamicTokenRegex[] { new DynamicTokenRegex("[A-Za-z]+", "identifier"), - new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") } ); builder3.setComponents( @@ -88,7 +89,7 @@ public void nullComponentInputs() { new String[] {}, new DynamicTokenRegex[] { new DynamicTokenRegex("[A-Za-z]+", "identifier"), - new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") } ); builder4.setComponents( @@ -102,7 +103,7 @@ public void nullComponentInputs() { new String[] {}, new DynamicTokenRegex[] { new DynamicTokenRegex("[A-Za-z]+", "identifier"), - new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") } ); builder5.setComponents( @@ -116,7 +117,7 @@ public void nullComponentInputs() { new String[] {}, new DynamicTokenRegex[] { new DynamicTokenRegex("[A-Za-z]+", "identifier"), - new DynamicTokenRegex("[0-9]+|[0-9]+.[0-9]+", "number") + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") } ); @@ -147,6 +148,70 @@ public void nullLexicalInputs() { assertDoesNotThrow(() -> builder.createCompiler()); } - // TODO: Catch NonStorableComponentException for non-storable analysers and code generator + @Test + public void setcomponents_nonStorableLexicalAnalyser() { + StorableCustomCompilerBuilder builder = new StorableCustomCompilerBuilder(); + builder.setComponents( + new TestCustomLexicalAnalyserFactory(), + new TestStorableCustomSyntaxAnalyserFactory(), + new TestStorableCustomCodeGeneratorFactory(), + BasicIdentifierGrammar.produce(), + XToYToXSemantic.produce(), + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") + } + ); + + + assertThrows(NonStorableComponentException.class, () -> builder.createCompiler()); + } + + @Test + public void setcomponents_nonStorableSyntaxAnalyser() { + StorableCustomCompilerBuilder builder = new StorableCustomCompilerBuilder(); + builder.setComponents( + new TestStorableCustomLexicalAnalyserFactory(), + new TestCustomSyntaxAnalyserFactory(), + new TestStorableCustomCodeGeneratorFactory(), + BasicIdentifierGrammar.produce(), + XToYToXSemantic.produce(), + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") + } + ); + + + assertThrows(NonStorableComponentException.class, () -> builder.createCompiler()); + } + + @Test + public void setcomponents_nonStorableCodeGenerator() { + StorableCustomCompilerBuilder builder = new StorableCustomCompilerBuilder(); + builder.setComponents( + new TestStorableCustomLexicalAnalyserFactory(), + new TestStorableCustomSyntaxAnalyserFactory(), + new TestCustomCodeGeneratorFactory(), + BasicIdentifierGrammar.produce(), + XToYToXSemantic.produce(), + new String[] {" "}, + new String[] {"+", "=", ";"}, + new String[] {}, + new DynamicTokenRegex[] { + new DynamicTokenRegex("[A-Za-z]+", "identifier"), + new DynamicTokenRegex("[0-9]+(\\.[0-9]+)?", "number") + } + ); + + + assertThrows(NonStorableComponentException.class, () -> builder.createCompiler()); + } } diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java new file mode 100644 index 0000000..71c7d8b --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomCodeGenerator.java @@ -0,0 +1,13 @@ +package test_aids.storage_entities.custom_components; + +import code_generation.CodeGenerator; +import syntax_analysis.parsing.ParseState; + +public class TestCustomCodeGenerator implements CodeGenerator { + + @Override + public String generate(ParseState parseRoot) { + throw new UnsupportedOperationException("Unimplemented method 'generate'"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java new file mode 100644 index 0000000..43c1319 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomLexicalAnalyser.java @@ -0,0 +1,13 @@ +package test_aids.storage_entities.custom_components; + +import grammar_objects.Token; +import lexical_analysis.LexicalAnalyser; + +public class TestCustomLexicalAnalyser implements LexicalAnalyser { + + @Override + public Token[] analyse(String sentence) { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java new file mode 100644 index 0000000..14a14a3 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/TestCustomSyntaxAnalyser.java @@ -0,0 +1,14 @@ +package test_aids.storage_entities.custom_components; + +import grammar_objects.Token; +import syntax_analysis.SyntaxAnalyser; +import syntax_analysis.parsing.*; + +public class TestCustomSyntaxAnalyser implements SyntaxAnalyser { + + @Override + public ParseState analyse(Token[] inputTokens) throws ParseFailedException { + throw new UnsupportedOperationException("Unimplemented method 'analyse'"); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomCodeGeneratorFactory.java b/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomCodeGeneratorFactory.java new file mode 100644 index 0000000..d20edeb --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomCodeGeneratorFactory.java @@ -0,0 +1,15 @@ +package test_aids.storage_entities.custom_components.factories; + +import code_generation.CodeGenerator; +import component_construction.factories.code_generation.CodeGeneratorFactory; +import grammar_objects.RuleConvertor; +import test_aids.storage_entities.custom_components.*; + +public class TestCustomCodeGeneratorFactory implements CodeGeneratorFactory { + + @Override + public CodeGenerator produceGenerator(RuleConvertor ruleConvertor) { + return new TestCustomCodeGenerator(); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomLexicalAnalyserFactory.java b/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomLexicalAnalyserFactory.java new file mode 100644 index 0000000..637f0f1 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomLexicalAnalyserFactory.java @@ -0,0 +1,20 @@ +package test_aids.storage_entities.custom_components.factories; + +import component_construction.factories.lexical_analysis.LexicalAnalyserFactory; +import lexical_analysis.DynamicTokenRegex; +import lexical_analysis.LexicalAnalyser; +import test_aids.storage_entities.custom_components.*; + +public class TestCustomLexicalAnalyserFactory implements LexicalAnalyserFactory { + + @Override + public LexicalAnalyser produceAnalyser( + String[] whitespaceDelimiters, + String[] stronglyReservedWords, + String[] weaklyReservedWords, + DynamicTokenRegex[] dynamicTokenRegex + ) { + return new TestCustomLexicalAnalyser(); + } + +} diff --git a/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomSyntaxAnalyserFactory.java b/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomSyntaxAnalyserFactory.java new file mode 100644 index 0000000..a58e6f6 --- /dev/null +++ b/src/test/java/test_aids/storage_entities/custom_components/factories/TestCustomSyntaxAnalyserFactory.java @@ -0,0 +1,15 @@ +package test_aids.storage_entities.custom_components.factories; + +import component_construction.factories.syntax_analysis.SyntaxAnalyserFactory; +import grammar_objects.GrammarParts; +import syntax_analysis.SyntaxAnalyser; +import test_aids.storage_entities.custom_components.*; + +public class TestCustomSyntaxAnalyserFactory implements SyntaxAnalyserFactory { + + @Override + public SyntaxAnalyser produceAnalyser(GrammarParts parts) { + return new TestCustomSyntaxAnalyser(); + } + +} From 860f296b87bfd8497d3d6ff79995d0e4c0adc19a Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Thu, 17 Sep 2026 22:59:01 +0100 Subject: [PATCH 150/162] Removal of unused FactoryRepository and test file --- .../storage/factories/FactoryRepository.java | 43 ------------------- .../factories/FactoryRepositoryTest.java | 42 ------------------ 2 files changed, 85 deletions(-) delete mode 100644 src/main/java/component_construction/storage/factories/FactoryRepository.java delete mode 100644 src/test/java/component_construction/storage/factories/FactoryRepositoryTest.java diff --git a/src/main/java/component_construction/storage/factories/FactoryRepository.java b/src/main/java/component_construction/storage/factories/FactoryRepository.java deleted file mode 100644 index 3c2dcd5..0000000 --- a/src/main/java/component_construction/storage/factories/FactoryRepository.java +++ /dev/null @@ -1,43 +0,0 @@ -package component_construction.storage.factories; - -import java.util.*; - -import storage.storage_values.StorageValue; - -//TODO: Remove? -public class FactoryRepository { - protected Map> factories = new HashMap<>(); - - /** - * Adds a factory to this repository - * @param name The name of the factory - * @param factory The factory - * @return This object for method chaining - */ - public FactoryRepository addFactory(String name, Factory factory) { - factories.put(name, factory); - return this; - } - - /** - * Checks if this repository contains a factory for a given key - * @param name The name/key of the factory - * @return Whether or not this repository contains the specified key - */ - public boolean containsKey(String name) { - return factories.containsKey(name); - } - - /** - * Instantiates the named entity using the given value. - * @param name The entity name - * @param loadValue The StorageValue to be loaded into the specified entity - * @return The constructed entity - * @throws ClassNotFoundException - */ - public T instantiate(String name, StorageValue loadValue) throws ClassNotFoundException { - return factories - .get(name) - .produce(loadValue); - } -} diff --git a/src/test/java/component_construction/storage/factories/FactoryRepositoryTest.java b/src/test/java/component_construction/storage/factories/FactoryRepositoryTest.java deleted file mode 100644 index 7b92cd9..0000000 --- a/src/test/java/component_construction/storage/factories/FactoryRepositoryTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package component_construction.storage.factories; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class FactoryRepositoryTest { - protected Factory testFactory1 = (loadValue) -> loadValue.getValue().toString(); - protected Factory testFactory2 = (loadValue) -> loadValue.getValue().toString() + "2"; - - @Test - public void addFactory() { - FactoryRepository repository = new FactoryRepository(); - - FactoryRepository actualRepository = assertDoesNotThrow( - () -> repository.addFactory("testFactory1", testFactory1) - ); - - assertEquals(repository, actualRepository); - } - - @Test - public void containsKey_key1() { - FactoryRepository repository = new FactoryRepository(); - repository.addFactory("testFactory1", testFactory1); - repository.addFactory("testFactory2", testFactory2); - - assertTrue(repository.containsKey("testFactory1")); - } - - @Test - public void containsKey_key2() { - FactoryRepository repository = new FactoryRepository(); - repository.addFactory("testFactory1", testFactory1); - repository.addFactory("testFactory2", testFactory2); - - assertTrue(repository.containsKey("testFactory2")); - } - - //TODO: Consider, why not use a factory? - // instantiate -} From 80d14500bc6a85aafc6a1efaa0d7e4cdd0e7c19e Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 20 Sep 2026 16:10:42 +0100 Subject: [PATCH 151/162] CompilerBuilderTemplate documentation update --- .../builders/CompilerBuilderTemplate.java | 83 +++++++++++++++---- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/src/main/java/component_construction/builders/CompilerBuilderTemplate.java b/src/main/java/component_construction/builders/CompilerBuilderTemplate.java index 49c5208..8872179 100644 --- a/src/main/java/component_construction/builders/CompilerBuilderTemplate.java +++ b/src/main/java/component_construction/builders/CompilerBuilderTemplate.java @@ -31,10 +31,11 @@ public abstract class CompilerBuilderTemplate Date: Sun, 20 Sep 2026 17:23:58 +0100 Subject: [PATCH 152/162] Documentation additions --- .../java/component_construction/Compiler.java | 8 +++++++ .../builders/CustomCompilerBuilder.java | 4 ++-- .../custom_components/CustomCompiler.java | 3 +++ .../CustomCompilerFactory.java | 21 +++++++++++++++++-- .../storage/dynamic_loading/LoadableBy.java | 9 ++++++++ 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/main/java/component_construction/Compiler.java b/src/main/java/component_construction/Compiler.java index 4d7d7ea..92486ef 100644 --- a/src/main/java/component_construction/Compiler.java +++ b/src/main/java/component_construction/Compiler.java @@ -2,5 +2,13 @@ import syntax_analysis.parsing.ParseFailedException; public interface Compiler { + + /** + * Compiles an input sentence + * @param input The sentence to be compiled + * @return The output of compilation + * @throws ParseFailedException An error occurred when parsing the sentence + */ public String compile(String input) throws ParseFailedException; + } diff --git a/src/main/java/component_construction/builders/CustomCompilerBuilder.java b/src/main/java/component_construction/builders/CustomCompilerBuilder.java index f843b54..9ced170 100644 --- a/src/main/java/component_construction/builders/CustomCompilerBuilder.java +++ b/src/main/java/component_construction/builders/CustomCompilerBuilder.java @@ -18,11 +18,11 @@ public CustomCompiler createCompiler() { syntaxAnalyserFactory, codeGeneratorFactory, grammar, + ruleConvertor, whitespaceDelimiters, stronglyReservedWords, weaklyReservedWords, - dynamicTokenRegex, - ruleConvertor + dynamicTokenRegex ); } diff --git a/src/main/java/component_construction/custom_components/CustomCompiler.java b/src/main/java/component_construction/custom_components/CustomCompiler.java index 6b16337..5a8626f 100644 --- a/src/main/java/component_construction/custom_components/CustomCompiler.java +++ b/src/main/java/component_construction/custom_components/CustomCompiler.java @@ -7,6 +7,9 @@ import syntax_analysis.SyntaxAnalyser; import syntax_analysis.parsing.*; +/** + * A compiler that can be built with user-definable inner components + */ public class CustomCompiler implements Compiler { protected LexicalAnalyser lexicalAnalyser; protected SyntaxAnalyser syntaxAnalyser; diff --git a/src/main/java/component_construction/custom_components/CustomCompilerFactory.java b/src/main/java/component_construction/custom_components/CustomCompilerFactory.java index 50f1ae0..04d139c 100644 --- a/src/main/java/component_construction/custom_components/CustomCompilerFactory.java +++ b/src/main/java/component_construction/custom_components/CustomCompilerFactory.java @@ -9,18 +9,34 @@ import lexical_analysis.*; import syntax_analysis.SyntaxAnalyser; +/** + * A factory for {@code CustomCompilers} + */ public class CustomCompilerFactory { + /** + * Builds and produces a {@code CustomCompiler} with user-specified components + * @param lexicalAnalyserFactory A factory for producing {@code LexicalAnalysers} for use within produced {@code CustomCompilers} + * @param syntaxAnalyserFactory A factory for producing {@code SyntaxAnalysers} for use within produced {@code CustomCompilers} + * @param codeGeneratorFactory A factory for producing {@code CodeGenerators} for use within produced {@code CustomCompilers} + * @param grammar The grammar to be used by produced {@code CustomCompilers} + * @param ruleConvertor The convertor to sanction grammar rules within produced {@code CustomCompilers} + * @param whitespaceDelimiters An array of designated whitespace delimiter strings for compilation + * @param stronglyReservedWords An array of designated reserved words for compilation. These words may not be used within other tokens + * @param weaklyReservedWords An array of reserved words that may be used as part of other tokens + * @param dynamicTokenRegex An array of {@code DynamicTokenRegex} for tokens whix may take many forms according to the provided regex + * @return A produced {@code CustomCompiler} + */ public CustomCompiler produce( LexicalAnalyserFactory lexicalAnalyserFactory, SyntaxAnalyserFactory syntaxAnalyserFactory, CodeGeneratorFactory codeGeneratorFactory, Grammar grammar, + RuleConvertor ruleConvertor, String[] whitespaceDelimiters, String[] stronglyReservedWords, String[] weaklyReservedWords, - DynamicTokenRegex[] dynamicTokenRegex, - RuleConvertor ruleConvertor + DynamicTokenRegex[] dynamicTokenRegex ) { if(whitespaceDelimiters == null) whitespaceDelimiters = new String[]{}; if(stronglyReservedWords == null) stronglyReservedWords = new String[]{}; @@ -42,4 +58,5 @@ public CustomCompiler produce( codeGenerator ); } + } diff --git a/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java b/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java index 1eaacc6..fd655bc 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java +++ b/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java @@ -11,6 +11,15 @@ */ public interface LoadableBy> { + /** + * Gets the {@code Loader} referenced by a given {@code LoadableBy} object + * @param The object type that may be loaded through the referenced {@code Loader} type + * @param The type of {@code Loader} referenced by this {@code LoadableBy} object + * @param loadableByClass The class implementing {@code LoadableBy} + * @return The class of the referenced {@code Loader} type + * @throws IllegalArgumentException The provided class does not directly implement {@code LoadableBy} + * @throws IncorrectlyFormattedException The provided {@code Loader} type is not a constructable/concrete {@code Class} object + */ @SuppressWarnings("unchecked") public static > Class getTargetLoader(Class> loadableByClass) throws IllegalArgumentException, IncorrectlyFormattedException { ParameterizedType loadableByInterface = null; From dc4bad19d004038089dc28bc835f0c6ae1cad008 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 20 Sep 2026 19:03:52 +0100 Subject: [PATCH 153/162] More documentation tweaks --- .../storage/Factories/Factory.java | 4 ++++ .../storage/dynamic_loading/Loader.java | 12 ++++++++++++ .../dynamic_loading/ReflectivelyLoadable.java | 1 - 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/component_construction/storage/Factories/Factory.java b/src/main/java/component_construction/storage/Factories/Factory.java index 799c8d6..db69129 100644 --- a/src/main/java/component_construction/storage/Factories/Factory.java +++ b/src/main/java/component_construction/storage/Factories/Factory.java @@ -2,6 +2,10 @@ import storage.storage_values.StorageValue; +/** + * A class for objects which may produce other objects from a specified {@code StorageValue} + * @param The type of object to be produced + */ public interface Factory { public T produce(StorageValue loadValue); } \ No newline at end of file diff --git a/src/main/java/component_construction/storage/dynamic_loading/Loader.java b/src/main/java/component_construction/storage/dynamic_loading/Loader.java index bb7ee29..ea50fb1 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/Loader.java +++ b/src/main/java/component_construction/storage/dynamic_loading/Loader.java @@ -5,8 +5,20 @@ import component_construction.storage.exceptions.MissingEmptyConstructorException; import component_construction.storage.factories.Factory; +/** + * An interface defining the ability construct objects of the specified type + * @param The type of object to be constructed + */ public interface Loader extends Factory { + /** + * Constructs a new object of the specified {@code Loader} + * @param The type of object constructable by the {@code Loader} + * @param loaderClass The class of the {@code Loader} to be reflectively constructed + * @return An object of the specified {@code Loader} + * @throws MissingEmptyConstructorException The {@code Loader} did not contain the required empty constructor + * @throws IllegalArgumentException The specified {@code Loader} could not be constructed as it is either abstract or the constructor is inaccessible + */ public static Loader construct(Class> loaderClass) throws MissingEmptyConstructorException, IllegalArgumentException { try { return loaderClass diff --git a/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java b/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java index ac69fec..4d2d9bb 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java +++ b/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java @@ -4,6 +4,5 @@ /** * Classes of this type must have a constructor that may be used to reflectively construct objects. - * ReflectivelyLoadable */ public interface ReflectivelyLoadable extends Loadable {} \ No newline at end of file From fc8954ec3556150673edfdf5c8cab6f4453457a6 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 20 Sep 2026 23:53:24 +0100 Subject: [PATCH 154/162] Storable documentation --- src/main/java/storage/external_interfaces/Storable.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/storage/external_interfaces/Storable.java b/src/main/java/storage/external_interfaces/Storable.java index a46f089..e315315 100644 --- a/src/main/java/storage/external_interfaces/Storable.java +++ b/src/main/java/storage/external_interfaces/Storable.java @@ -4,6 +4,10 @@ public interface Storable { + /** + * Gets the storage representation of this object + * @return A {@code StoraageValue} representing the storable state of this object + */ public StorageValue getStorageRepresentation(); } From 14bda14e5d2f3663f6ff866e44acbc64c5477809 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:40:20 +0100 Subject: [PATCH 155/162] Deletion of unused StorableAndLoadable interface --- .../java/storage/external_interfaces/StorableAndLoadable.java | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/main/java/storage/external_interfaces/StorableAndLoadable.java diff --git a/src/main/java/storage/external_interfaces/StorableAndLoadable.java b/src/main/java/storage/external_interfaces/StorableAndLoadable.java deleted file mode 100644 index 6747fc1..0000000 --- a/src/main/java/storage/external_interfaces/StorableAndLoadable.java +++ /dev/null @@ -1,3 +0,0 @@ -package storage.external_interfaces; - -public interface StorableAndLoadable extends Storable, Loadable {} \ No newline at end of file From eac30662b73eff4562b266e5ed616826ce170666 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:49:00 +0100 Subject: [PATCH 156/162] More documentation cleanups --- .../storage/external_interfaces/Loadable.java | 7 +++++++ .../storage/external_interfaces/Storable.java | 3 +++ .../value_formatters/ValueFormatter.java | 18 ++++++++++++++++++ .../ValueToStringFormatter.java | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/storage/external_interfaces/Loadable.java b/src/main/java/storage/external_interfaces/Loadable.java index bdbb850..a69ebb9 100644 --- a/src/main/java/storage/external_interfaces/Loadable.java +++ b/src/main/java/storage/external_interfaces/Loadable.java @@ -2,8 +2,15 @@ import storage.storage_values.StorageValue; +/** + * An interface denoting the state of this object may be loaded from a specified {@code StorageValue} + */ public interface Loadable { + /** + * Loads the given state into this object + * @param data The {@code StorageValue} state to be loaded + */ public void load(StorageValue data); } diff --git a/src/main/java/storage/external_interfaces/Storable.java b/src/main/java/storage/external_interfaces/Storable.java index e315315..189ad0c 100644 --- a/src/main/java/storage/external_interfaces/Storable.java +++ b/src/main/java/storage/external_interfaces/Storable.java @@ -2,6 +2,9 @@ import storage.storage_values.StorageValue; +/** + * An interface denoting that this object's state can be fetched + */ public interface Storable { /** diff --git a/src/main/java/storage/value_formatters/ValueFormatter.java b/src/main/java/storage/value_formatters/ValueFormatter.java index 3668303..575b5cb 100644 --- a/src/main/java/storage/value_formatters/ValueFormatter.java +++ b/src/main/java/storage/value_formatters/ValueFormatter.java @@ -3,7 +3,25 @@ import storage.storage_value_adapters.UnsupportedValueException; import storage.storage_values.StorageValue; +/** + * An interface denoting the ability of this object to format and parse {@code StorageValues} into objects for storage + * @param The target object format + */ public interface ValueFormatter { + + /** + * Formats the provided {@code StorageValue} + * @param value The provided {@code StorageValue} + * @return The formatted {@code StorageValue} + * @throws UnsupportedValueException The {@code StorageValue} provided was not supported by this formatter + */ public F format(StorageValue value) throws UnsupportedValueException; + + /** + * Parses a given value into a {@code StorageValue} representation + * @param formattedData An object containing data to be parsed + * @return The object parsed into a {@code StorageValue} + * @throws UnsupportedValueException The object provided was not supported by this formatter + */ public StorageValue parse(F formattedData) throws UnsupportedValueException; } diff --git a/src/main/java/storage/value_formatters/ValueToStringFormatter.java b/src/main/java/storage/value_formatters/ValueToStringFormatter.java index 35a132a..0102e75 100644 --- a/src/main/java/storage/value_formatters/ValueToStringFormatter.java +++ b/src/main/java/storage/value_formatters/ValueToStringFormatter.java @@ -7,7 +7,7 @@ import storage.storage_values.*; /** - * A simple and limited ValueFormatter, not intended for storage of complex data + * A simple ValueFormatter * Parses and produces strings in the form { "entry1":value1, ..., "entryN":value } */ public class ValueToStringFormatter implements ValueFormatter { From 784d7251d5129cb7cc088177da38086e50b8ff49 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:52:57 +0100 Subject: [PATCH 157/162] Removal of compiler specific language within Storage --- src/main/java/storage/Storage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/storage/Storage.java b/src/main/java/storage/Storage.java index 30b267f..42b8ad8 100644 --- a/src/main/java/storage/Storage.java +++ b/src/main/java/storage/Storage.java @@ -13,11 +13,11 @@ import storage.value_formatters.*; /** - * A utility class for storage of compiler components. + * A utility class for storage */ public class Storage { - private Path targetFilepath = Path.of("." + File.separator + "compilerFile.txt"); + private Path targetFilepath = Path.of("." + File.separator + "storageFile.txt"); private ChosenFormatter formatter = new ChosenFormatter<>(new ValueToStringFormatter()); private ChosenStreamWriter streamWriter = new ChosenStreamWriter<>(new DefaultUTF8StreamEditor()); private ChosenStreamReader streamReader = new ChosenStreamReader<>(new DefaultUTF8StreamEditor()); From 8ef8f669f95b84c8c29ca0a20843045ff1bbb94b Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 26 Sep 2026 00:37:35 +0100 Subject: [PATCH 158/162] Diagram update --- docs/diagrams/CustomCompilers.drawio.svg | 1158 ++++------------------ 1 file changed, 220 insertions(+), 938 deletions(-) diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg index 96ccbdd..57e84a1 100644 --- a/docs/diagrams/CustomCompilers.drawio.svg +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -1,938 +1,220 @@ - - - - - - - - - - -
-
-
-
- Compiler <<I>> -
-
-
-
-
- - Compiler <<I>> - -
-
-
- - - - - - - - - - - - - - - - -
-
-
- Contains -
-
-
-
- - Contains - -
-
-
- - - - - - - -
-
-
-
- CustomCompiler -
-
-
-
-
- - CustomCompiler - -
-
-
- - - - - - - -
-
-
-
- StoreAndLoadable <<I>> -
-
-
-
-
- - StoreAndLoadable <<I>> - -
-
-
- - - - - - - -
-
-
-
- Storable <<I>> -
-
-
-
-
- - Storable <<I>> - -
-
-
- - - - - - - -
-
-
-
- Loadable <<I>> -
-
-
-
-
- - Loadable <<I>> - -
-
-
- - - - - - - - - - - - - - - - -
-
-
- Creates -
-
-
-
- - Creates - -
-
-
- - - - - - - - - - - - - - - - -
-
-
- Uses -
-
-
-
- - Uses - -
-
-
- - - - - - - -
-
-
-
- CustomCompilerBuilder -
-
-
-
-
- - CustomCompilerBuilder - -
-
-
- - - - - - - -
-
-
-
- CustomLexicalAnalyser <<I>> -
-
-
-
-
- - CustomLexicalAnalyser <<I>> - -
-
-
- - - - - - - -
-
-
-
- CustomSyntaxAnalyser <<I>> -
-
-
-
-
- - CustomSyntaxAnalyser <<I>> - -
-
-
- - - - - - - -
-
-
-
- CustomCodeGenerator <<I>> -
-
-
-
-
- - CustomCodeGenerator <<I>> - -
-
-
- - - - - - - - -
-
-
- Creates -
-
-
-
- - Creates - -
-
-
- - - - - - - -
-
-
-
- CustomLexicalAnalyserFactory <<I>> -
-
-
-
-
- - CustomLexicalAnalyserFactory <<I>> - -
-
-
- - - - - - - - -
-
-
- Creates -
-
-
-
- - Creates - -
-
-
- - - - - - - -
-
-
-
- CustomSyntaxAnalyserFactory <<I>> -
-
-
-
-
- - CustomSyntaxAnalyserFactory <<I>> - -
-
-
- - - - - - - - -
-
-
- Creates -
-
-
-
- - Creates - -
-
-
- - - - - - - -
-
-
-
- CustomCodeGeneratorFactory <<I>> -
-
-
-
-
- - CustomCodeGeneratorFactory <<I>> - -
-
-
- - - - - - - - -
-
-
- Builder -
-
-
-
- - Builder - -
-
-
- - - - - - - - -
-
-
- CustomCompiler -
-
-
-
- - CustomCompiler - -
-
-
- - - - - - - -
-
-
-
- LexicalAnalyser <<I>> -
-
-
-
-
- - LexicalAnalyser <<I>> - -
-
-
- - - - - - - -
-
-
-
- SyntaxAnalyser <<I>> -
-
-
-
-
- - SyntaxAnalyser <<I>> - -
-
-
- - - - - - - -
-
-
-
- CodeGenerator <<I>> -
-
-
-
-
- - CodeGenerator <<I>> - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- Extends -
-
-
-
- - Extends - -
-
-
- - - - - - - - -
-
-
- Extends -
-
-
-
- - Extends - -
-
-
- - - - - - - - -
-
-
- Store -
-
-
-
- - Store - -
-
-
- - - - -
-
-
- Load -
-
-
-
- - Load - -
-
-
- - - - - - - -
-
-
-
- Storage -
-
-
-
-
- - Storage - -
-
-
- - - - - - - - -
-
-
- load() -
-
-
-
- - load() - -
-
-
- - - - -
-
-
- store() -
-
-
-
- - store() - -
-
-
- - - - - - - - -
-
-
- Query -
-
-
-
- - Query - -
-
-
- - - - - - - - -
-
-
- uses -
-
-
-
- - uses - -
-
-
- - - - - - - -
-
-
-
- CustomCompilerStorage -
-
-
-
-
- - CustomCompilerStorage - -
-
-
- - - - - - - -
-
-
- File -
-
-
-
- - File - -
-
-
- - - - - - - -
-
-
-
- StorableCustomCompiler -
-
-
-
-
- - StorableCustomCompiler - -
-
-
- - - - - - - - -
-
-
- Creates -
-
-
-
- - Creates - -
-
-
- - - - - - - -
-
-
-
- StorableCustomCompilerBuilder -
-
-
-
-
- - StorableCustomCompilerBuilder - -
-
-
- - - - - - - - -
-
-
- Instantiate -
-
-
-
- - Instantiate - -
-
-
- - - - - - - -
-
-
-
- ReflectiveFactoryRepository -
-
-
-
-
- - ReflectiveFactoryRepository - -
-
-
-
- - - - - Text is not SVG - cannot display - - - -
\ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 3304f64d45d93a38b2d7087a7ab45ecf6154a690 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sat, 26 Sep 2026 22:18:45 +0100 Subject: [PATCH 159/162] More diagram updates --- docs/diagrams/CustomCompilers.drawio.svg | 1245 ++++++++++++++++++---- 1 file changed, 1025 insertions(+), 220 deletions(-) diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg index 57e84a1..3159c34 100644 --- a/docs/diagrams/CustomCompilers.drawio.svg +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -1,220 +1,1025 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + +
+
+
+
+
+ + StorableCustomCompilerBuilder + +
+
+
+
+
+
+ + StorableCustomCompilerBuilder + +
+
+
+
+ + + + + + + + + + +
+
+
+ Loads +
+
+
+
+ + Loads + +
+
+
+
+ + + + + +
+
+
+ Load +
+
+
+
+ + Load + +
+
+
+
+
+ + + + + + + + + + + + + + + + +
+
+
+ Uses +
+
+
+
+ + Uses + +
+
+
+
+
+ + + + + + + + +
+
+
+
+
+ + CompilerStorage + +
+
+
+
+
+
+ + CompilerStorage + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Uses +
+
+
+
+ + Uses + +
+
+
+
+
+ + + + + + + + +
+
+
+
+ <A> + + CompilerBuilderTemplate + +
+
+
+
+
+ + <A> CompilerBuilderTemplate + +
+
+
+
+ + + + + + + + + + +
+
+
+ Store +
+
+
+
+ + Store + +
+
+
+
+
+ + + + + + + + + + +
+
+
+ User creates +
+
+
+
+ + User creates + +
+
+
+
+
+ + + + + + + + +
+
+
+
+
+ + StorableCustomCompiler + +
+
+
+
+
+
+ + StorableCustomCompiler + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + <I> LexicalAnalyserFactory + +
+
+
+
+
+
+ + <I> LexicalAnalyserFactory + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + <I> SyntaxAnalyserFactory + +
+
+
+
+
+
+ + <I> SyntaxAnalyserFactory + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + <I> CodeGeneratorFactory + +
+
+
+
+
+
+ + <I> CodeGeneratorFactory + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + CustomCompiler + +
+
+
+
+
+
+ + CustomCompiler + +
+
+
+
+ + + + + + + + +
+
+
+
+ <I> Compiler +
+
+
+
+
+ + <I> Compiler + +
+
+
+
+ + + + + + + + + + + + + + +
+
+
+
+ <I> Storable +
+
+
+
+
+ + <I> Storable + +
+
+
+
+ + + + + + + + + + +
+
+
+ References +
+
+
+
+ + References + +
+
+
+
+
+ + + + + + + + +
+
+
+
+ <I> LoadableBy<T> +
+ T = StorableCustomCompilerFactory> +
+
+
+
+
+ + + <I> LoadableBy<T> + + + T = StorableCustomCompilerFactory> + + +
+
+
+
+ + + + + + + + + + +
+
+
+ Uses +
+
+
+
+ + Uses + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + StorableCustomCompilerFactory + +
+
+
+
+
+
+ + StorableCustomCompilerFactory + +
+
+
+
+ + + + + + + + + + + + + + +
+
+
+
+ <I> Loader<T> +
+ T = StorableCustomCompiler +
+
+
+
+
+ + + <I> Loader<T> + + + T = StorableCustomCompiler + + +
+
+
+
+ + + + + + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + ReflectiveClassConstructor + +
+
+
+
+
+
+ + ReflectiveClassConstructor + +
+
+
+
+ + + + + + + + +
+
+
+
+ <I> Factory<T> +
+
+
+
+
+ + <I> Factory<T> + +
+
+
+
+ + + + + + + + +
+
+
+
+ Storage +
+
+
+
+
+ + Storage + +
+
+
+
+ + + + + + + + + +
+
+
+ Component Construcion +
+
+
+
+ + Component Construcion + +
+
+
+
+ + + + + + + + + +
+
+
+ Factories +
+
+
+
+ + Factories + +
+
+
+
+ + + + + + + + + +
+
+
+ Builders +
+
+
+
+ + Builders + +
+
+
+
+ + + + + + + + + + + + + + +
+
+
+
+
+ + CustomCompilerFactory + +
+
+
+
+
+
+ + CustomCompilerFactory + +
+
+
+
+ + + + + + + + + +
+
+
+ Custom Compiler +
+
+
+
+ + Custom Compiler + +
+
+
+
+ + + + + + + + +
+
+
+
+ <I> Loader<T> +
+
+
+
+
+ + <I> Loader<T> + +
+
+
+
+ + + + + + + + + +
+
+
+ Dynamic Loading +
+
+
+
+ + Dynamic Loading + +
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+ Storage +
+
+
+
+ + Storage + +
+
+
+
+ + + + + + + + + + +
+
+
+ Builds +
+
+
+
+ + Builds + +
+
+
+
+
+ + + + + + + + + +
+
+
+ Builders +
+
+
+
+ + Builders + +
+
+
+
+ + + + + + + + + +
+
+
+ Extends +
+
+
+
+ + Extends + +
+
+
+
+
+
+
+ + + + + Text is not SVG - cannot display + + + +
\ No newline at end of file From 32b7abb124d32d4b4652d049b57154a9be460a22 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 27 Sep 2026 15:43:45 +0100 Subject: [PATCH 160/162] Diagram colour fix --- docs/diagrams/CustomCompilers.drawio.svg | 684 ++++++++++++++++------- 1 file changed, 471 insertions(+), 213 deletions(-) diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg index 3159c34..00c8205 100644 --- a/docs/diagrams/CustomCompilers.drawio.svg +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -17,9 +17,9 @@

-
-
- +
+
+ StorableCustomCompilerBuilder
@@ -37,15 +37,15 @@ - - + + -
+
Loads @@ -53,7 +53,7 @@
- + Loads @@ -65,7 +65,7 @@ -
+
Load @@ -73,7 +73,7 @@
- + Load @@ -81,41 +81,9 @@ - - - - - - - - - - - - - - - - -
-
-
- Uses -
-
-
-
- - Uses - -
-
-
-
-
- + @@ -124,9 +92,9 @@
-
-
- +
+
+ CompilerStorage
@@ -142,58 +110,22 @@ - - - - - - - - - - - - - - - - - - - - - - -
-
-
- Uses -
-
-
-
- - Uses - -
-
-
-
-
- + -
+
-
- <A> - +
+ + <A> + + CompilerBuilderTemplate
@@ -201,7 +133,7 @@
- + <A> CompilerBuilderTemplate @@ -210,15 +142,15 @@ - - + + -
+
Store @@ -226,7 +158,7 @@
- + Store @@ -236,15 +168,15 @@ - - + + -
+
User creates @@ -252,7 +184,7 @@
- + User creates @@ -262,7 +194,7 @@ - + @@ -271,9 +203,9 @@
-
-
- +
+
+ StorableCustomCompiler
@@ -291,18 +223,18 @@ - + -
+
-
-
- +
+
+ <I> LexicalAnalyserFactory
@@ -311,7 +243,7 @@
- + <I> LexicalAnalyserFactory @@ -320,18 +252,18 @@ - + -
+
-
-
- +
+
+ <I> SyntaxAnalyserFactory
@@ -340,7 +272,7 @@
- + <I> SyntaxAnalyserFactory @@ -349,18 +281,18 @@ - + -
+
-
-
- +
+
+ <I> CodeGeneratorFactory
@@ -369,7 +301,7 @@
- + <I> CodeGeneratorFactory @@ -378,7 +310,7 @@ - + @@ -387,9 +319,9 @@
-
-
- +
+
+ CustomCompiler
@@ -407,7 +339,7 @@ - + @@ -432,13 +364,13 @@ - - + + - + @@ -463,15 +395,15 @@ - - + + -
+
References @@ -479,7 +411,7 @@
- + References @@ -489,7 +421,7 @@ - + @@ -521,15 +453,15 @@ - - + + -
+
Uses @@ -537,7 +469,7 @@
- + Uses @@ -547,19 +479,19 @@ - - + + - - + + - + @@ -568,9 +500,9 @@
-
-
- +
+
+ StorableCustomCompilerFactory
@@ -588,13 +520,13 @@ - - + + - + @@ -626,8 +558,8 @@ - - + + @@ -650,7 +582,7 @@ - + @@ -679,7 +611,7 @@ - + @@ -704,7 +636,7 @@ - + @@ -729,8 +661,8 @@ - - + + @@ -744,7 +676,7 @@
- + Component Construcion @@ -753,14 +685,14 @@ - - + + -
+
Factories @@ -768,7 +700,7 @@
- + Factories @@ -777,14 +709,14 @@ - - + + -
+
Builders @@ -792,7 +724,7 @@
- + Builders @@ -801,13 +733,13 @@ - - + + - + @@ -816,9 +748,9 @@
-
-
- +
+
+ CustomCompilerFactory
@@ -836,14 +768,14 @@ - - + + -
+
Custom Compiler @@ -860,7 +792,7 @@ - + @@ -885,14 +817,14 @@ - - + + -
+
Dynamic Loading @@ -909,70 +841,140 @@ - - + + - + - - + + - + - - -
-
-
- Storage + + + +
+
+
+ Builds +
-
- - - Storage - - + + + Builds + + + - + - - + + - + + + + + + + -
+
- Builds + Uses
- - Builds + + Uses + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Uses +
+
+
+
+ + Uses + +
+
+
+
+
+ + + + + + + + + +
+
+
+ Storage +
+
+
+
+ + Storage + +
+
+
+
- - + + -
+
Builders @@ -980,23 +982,279 @@
- + Builders + + + + + + + + +
+
+
+
+
+ + ComponentCastException + +
+
+
+
+
+
+ + ComponentCastException + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + IncorrectLoadValueFormat + +
+
+
+
+
+
+ + IncorrectLoadValueFormat + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + IncorrectlyFormattedException + +
+
+
+
+
+
+ + IncorrectlyFormattedException + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + MissingEmptyConstructorException + +
+
+
+
+
+
+ + MissingEmptyConstructorException + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + MissingKeyException + +
+
+
+
+
+
+ + MissingKeyException + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + NonExistentComponentException + +
+
+
+
+
+
+ + NonExistentComponentException + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + NonStorableComponentException + +
+
+
+
+
+
+ + NonStorableComponentException + +
+
+
+
+ + + + + + + + +
+
+
+
+
+ + ReflectiveLoadFailure + +
+
+
+
+
+
+ + ReflectiveLoadFailure + +
+
+
+
+ + + + + + + + + +
+
+
+ Exceptions +
+
+
+
+ + Exceptions + +
+
+
+
- - + + -
+
Extends @@ -1004,7 +1262,7 @@
- + Extends From fe7ade257904bfe42512365707ccb904ae083395 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 27 Sep 2026 16:57:34 +0100 Subject: [PATCH 161/162] Import fixes --- src/test/java/component_construction/CompilerTests.java | 1 - .../loadableBy/LoadableByStorableCustomLexicalAnalyser.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/test/java/component_construction/CompilerTests.java b/src/test/java/component_construction/CompilerTests.java index 1574cac..14f3f1f 100644 --- a/src/test/java/component_construction/CompilerTests.java +++ b/src/test/java/component_construction/CompilerTests.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import component_construction.builders.CompilerBuilderTemplate; import component_construction.builders.CustomCompilerBuilder; import component_construction.factories.code_generation.BasicCodeGenFactory; import component_construction.factories.lexical_analysis.GeneralLexicalAnalyserFactory; diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java index 7e6ff96..12133a0 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java @@ -5,7 +5,6 @@ import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; import storage.storage_values.*; -import test_aids.storage_entities.custom_components.loadable.LoadableStorableCustomSyntaxAnalyser; public class LoadableByStorableCustomLexicalAnalyser implements LexicalAnalyser, LoadableBy, Storable { From 79e4dd0d137b0140fc755605337d61e0852d6875 Mon Sep 17 00:00:00 2001 From: warburec <77669019+warburec@users.noreply.github.com> Date: Sun, 27 Sep 2026 17:15:18 +0100 Subject: [PATCH 162/162] Rename component_construction "storage" to "storable" --- docs/diagrams/CustomCompilers.drawio.svg | 234 +++++++++--------- .../CompilerStorage.java | 4 +- .../StorableCustomCompiler.java | 9 +- .../StorableCustomCompilerBuilder.java | 6 +- .../dynamic_loading/LoadableBy.java | 4 +- .../dynamic_loading/Loader.java | 6 +- .../ReflectiveClassConstructor.java | 2 +- .../dynamic_loading/ReflectivelyLoadable.java | 2 +- .../exceptions/ComponentCastException.java | 2 +- .../exceptions/IncorrectLoadValueFormat.java | 2 +- .../IncorrectlyFormattedException.java | 2 +- .../MissingEmptyConstructorException.java | 4 +- .../exceptions/MissingKeyException.java | 2 +- .../NonExistentComponentException.java | 2 +- .../NonStorableComponentException.java | 2 +- .../exceptions/ReflectiveLoadFailure.java | 2 +- .../factories}/Factory.java | 2 +- .../StorableCustomCompilerFactory.java | 9 +- .../CompilerStorageTests.java | 2 +- .../StorableCustomCompilerTests.java | 2 +- .../StorableCustomCompilerBuilderTests.java | 4 +- .../dynamic_loading/LoadableByTests.java | 4 +- .../dynamic_loading/LoaderTests.java | 4 +- .../ReflectiveClassConstructorTests.java | 2 +- .../StorableCustomCompilerFactoryTests.java | 4 +- .../IncorrectlyFormedLoader.java | 2 +- .../storage_entities/TestObjectLoader.java | 2 +- .../TestStorableCustomCompiler.java | 2 +- .../LoadableStorableCustomCodeGenerator.java | 3 +- ...LoadableStorableCustomLexicalAnalyser.java | 2 +- .../LoadableStorableCustomSyntaxAnalyser.java | 2 +- .../LoadableTestStorableCustomCompiler.java | 2 +- ...LoadableByCustomLexicalAnalyserLoader.java | 2 +- ...adableByStorableCustomLexicalAnalyser.java | 2 +- .../ConcretisedGenericTestLoadableObject.java | 2 +- .../loadableby_entities/GenericLoader.java | 2 +- .../GenericTestLoadableObject.java | 2 +- .../GenericallyLoadableObject.java | 2 +- .../loadableby_entities/LoadableObject.java | 2 +- .../loadableby_entities/StandardLoader.java | 2 +- .../TestLoadableObject.java | 2 +- .../WildcardLoadableObject.java | 2 +- 42 files changed, 177 insertions(+), 176 deletions(-) rename src/main/java/component_construction/{storage => storable}/CompilerStorage.java (98%) rename src/main/java/component_construction/{storage => storable}/StorableCustomCompiler.java (87%) rename src/main/java/component_construction/{storage => storable}/builders/StorableCustomCompilerBuilder.java (82%) rename src/main/java/component_construction/{storage => storable}/dynamic_loading/LoadableBy.java (94%) rename src/main/java/component_construction/{storage => storable}/dynamic_loading/Loader.java (87%) rename src/main/java/component_construction/{storage => storable}/dynamic_loading/ReflectiveClassConstructor.java (98%) rename src/main/java/component_construction/{storage => storable}/dynamic_loading/ReflectivelyLoadable.java (78%) rename src/main/java/component_construction/{storage => storable}/exceptions/ComponentCastException.java (89%) rename src/main/java/component_construction/{storage => storable}/exceptions/IncorrectLoadValueFormat.java (86%) rename src/main/java/component_construction/{storage => storable}/exceptions/IncorrectlyFormattedException.java (75%) rename src/main/java/component_construction/{storage => storable}/exceptions/MissingEmptyConstructorException.java (71%) rename src/main/java/component_construction/{storage => storable}/exceptions/MissingKeyException.java (93%) rename src/main/java/component_construction/{storage => storable}/exceptions/NonExistentComponentException.java (88%) rename src/main/java/component_construction/{storage => storable}/exceptions/NonStorableComponentException.java (86%) rename src/main/java/component_construction/{storage => storable}/exceptions/ReflectiveLoadFailure.java (76%) rename src/main/java/component_construction/{storage/Factories => storable/factories}/Factory.java (84%) rename src/main/java/component_construction/{storage/Factories => storable/factories}/StorableCustomCompilerFactory.java (97%) rename src/test/java/component_construction/{storage => storable}/CompilerStorageTests.java (99%) rename src/test/java/component_construction/{storage => storable}/StorableCustomCompilerTests.java (58%) rename src/test/java/component_construction/{storage => storable}/builders/StorableCustomCompilerBuilderTests.java (98%) rename src/test/java/component_construction/{storage => storable}/dynamic_loading/LoadableByTests.java (95%) rename src/test/java/component_construction/{storage => storable}/dynamic_loading/LoaderTests.java (83%) rename src/test/java/component_construction/{storage => storable}/dynamic_loading/ReflectiveClassConstructorTests.java (99%) rename src/test/java/component_construction/{storage => storable}/factories/StorableCustomCompilerFactoryTests.java (99%) diff --git a/docs/diagrams/CustomCompilers.drawio.svg b/docs/diagrams/CustomCompilers.drawio.svg index 00c8205..0cbb1f4 100644 --- a/docs/diagrams/CustomCompilers.drawio.svg +++ b/docs/diagrams/CustomCompilers.drawio.svg @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -37,15 +37,15 @@ - - + + -
+
Loads @@ -53,7 +53,7 @@
- + Loads @@ -65,7 +65,7 @@ -
+
Load @@ -73,7 +73,7 @@
- + Load @@ -83,7 +83,7 @@ - + @@ -112,7 +112,7 @@ - + @@ -142,15 +142,15 @@ - - + + -
+
Store @@ -158,7 +158,7 @@
- + Store @@ -168,15 +168,15 @@ - - + + -
+
User creates @@ -184,7 +184,7 @@
- + User creates @@ -194,7 +194,7 @@ - + @@ -223,7 +223,7 @@ - + @@ -252,7 +252,7 @@ - + @@ -281,7 +281,7 @@ - + @@ -310,7 +310,7 @@ - + @@ -339,7 +339,7 @@ - + @@ -364,13 +364,13 @@ - - + + - + @@ -395,15 +395,15 @@ - - + + -
+
References @@ -411,7 +411,7 @@
- + References @@ -421,7 +421,7 @@ - + @@ -453,15 +453,15 @@ - - + + -
+
Uses @@ -469,7 +469,7 @@
- + Uses @@ -479,19 +479,19 @@ - - + + - - + + - + @@ -520,13 +520,13 @@ - - + + - + @@ -558,14 +558,14 @@ - - + + -
+
Extends @@ -582,7 +582,7 @@ - + @@ -611,7 +611,7 @@ - + @@ -636,7 +636,7 @@ - + @@ -661,8 +661,8 @@ - - + + @@ -676,7 +676,7 @@
- + Component Construcion @@ -685,14 +685,14 @@ - - + + -
+
Factories @@ -700,7 +700,7 @@
- + Factories @@ -709,14 +709,14 @@ - - + + -
+
Builders @@ -724,7 +724,7 @@
- + Builders @@ -733,13 +733,13 @@ - - + + - + @@ -768,14 +768,14 @@ - - + + -
+
Custom Compiler @@ -792,7 +792,7 @@ - + @@ -817,14 +817,14 @@ - - + + -
+
Dynamic Loading @@ -841,21 +841,21 @@ - - + + - - + + -
+
Builds @@ -863,7 +863,7 @@
- + Builds @@ -873,21 +873,21 @@ - - + + - - + + -
+
Uses @@ -895,7 +895,7 @@
- + Uses @@ -905,27 +905,27 @@ - - + + - - + + - - + + -
+
Uses @@ -933,7 +933,7 @@
- + Uses @@ -943,23 +943,23 @@ - - + + -
+
- Storage + Storable
- - Storage + + Storable @@ -967,14 +967,14 @@ - - + + -
+
Builders @@ -982,7 +982,7 @@
- + Builders @@ -991,7 +991,7 @@ - + @@ -1020,7 +1020,7 @@ - + @@ -1049,7 +1049,7 @@ - + @@ -1078,7 +1078,7 @@ - + @@ -1107,7 +1107,7 @@ - + @@ -1136,7 +1136,7 @@ - + @@ -1165,7 +1165,7 @@ - + @@ -1194,7 +1194,7 @@ - + @@ -1223,14 +1223,14 @@ - - + + -
+
Exceptions @@ -1238,7 +1238,7 @@
- + Exceptions @@ -1247,14 +1247,14 @@ - - + + -
+
Extends diff --git a/src/main/java/component_construction/storage/CompilerStorage.java b/src/main/java/component_construction/storable/CompilerStorage.java similarity index 98% rename from src/main/java/component_construction/storage/CompilerStorage.java rename to src/main/java/component_construction/storable/CompilerStorage.java index a0fe85e..91f5465 100644 --- a/src/main/java/component_construction/storage/CompilerStorage.java +++ b/src/main/java/component_construction/storable/CompilerStorage.java @@ -1,9 +1,9 @@ -package component_construction.storage; +package component_construction.storable; import java.io.*; import java.nio.file.Path; -import component_construction.storage.factories.StorableCustomCompilerFactory; +import component_construction.storable.factories.StorableCustomCompilerFactory; import storage.Storage; import storage.exceptions.*; import storage.external_interfaces.Loadable; diff --git a/src/main/java/component_construction/storage/StorableCustomCompiler.java b/src/main/java/component_construction/storable/StorableCustomCompiler.java similarity index 87% rename from src/main/java/component_construction/storage/StorableCustomCompiler.java rename to src/main/java/component_construction/storable/StorableCustomCompiler.java index ce721c3..bfcdf7b 100644 --- a/src/main/java/component_construction/storage/StorableCustomCompiler.java +++ b/src/main/java/component_construction/storable/StorableCustomCompiler.java @@ -1,12 +1,13 @@ -package component_construction.storage; +package component_construction.storable; import java.util.Map; import code_generation.CodeGenerator; import component_construction.custom_components.*; -import component_construction.storage.dynamic_loading.LoadableBy; -import component_construction.storage.exceptions.NonStorableComponentException; -import component_construction.storage.factories.StorableCustomCompilerFactory; +import component_construction.storable.dynamic_loading.LoadableBy; +import component_construction.storable.exceptions.NonStorableComponentException; +import component_construction.storable.factories.StorableCustomCompilerFactory; +import component_construction.storable.StorableCustomCompiler; import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; import storage.storage_values.*; diff --git a/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java b/src/main/java/component_construction/storable/builders/StorableCustomCompilerBuilder.java similarity index 82% rename from src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java rename to src/main/java/component_construction/storable/builders/StorableCustomCompilerBuilder.java index 1615a2a..c5420c8 100644 --- a/src/main/java/component_construction/storage/builders/StorableCustomCompilerBuilder.java +++ b/src/main/java/component_construction/storable/builders/StorableCustomCompilerBuilder.java @@ -1,8 +1,8 @@ -package component_construction.storage.builders; +package component_construction.storable.builders; import component_construction.builders.CompilerBuilderTemplate; -import component_construction.storage.StorableCustomCompiler; -import component_construction.storage.exceptions.NonStorableComponentException; +import component_construction.storable.StorableCustomCompiler; +import component_construction.storable.exceptions.NonStorableComponentException; import grammar_objects.GrammarParts; public class StorableCustomCompilerBuilder extends CompilerBuilderTemplate { diff --git a/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java b/src/main/java/component_construction/storable/dynamic_loading/LoadableBy.java similarity index 94% rename from src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java rename to src/main/java/component_construction/storable/dynamic_loading/LoadableBy.java index fd655bc..f9e3839 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/LoadableBy.java +++ b/src/main/java/component_construction/storable/dynamic_loading/LoadableBy.java @@ -1,8 +1,8 @@ -package component_construction.storage.dynamic_loading; +package component_construction.storable.dynamic_loading; import java.lang.reflect.*; -import component_construction.storage.exceptions.IncorrectlyFormattedException; +import component_construction.storable.exceptions.IncorrectlyFormattedException; /** * A class specifying a designated loader for the current class. diff --git a/src/main/java/component_construction/storage/dynamic_loading/Loader.java b/src/main/java/component_construction/storable/dynamic_loading/Loader.java similarity index 87% rename from src/main/java/component_construction/storage/dynamic_loading/Loader.java rename to src/main/java/component_construction/storable/dynamic_loading/Loader.java index ea50fb1..dd13bce 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/Loader.java +++ b/src/main/java/component_construction/storable/dynamic_loading/Loader.java @@ -1,9 +1,9 @@ -package component_construction.storage.dynamic_loading; +package component_construction.storable.dynamic_loading; import java.lang.reflect.InvocationTargetException; -import component_construction.storage.exceptions.MissingEmptyConstructorException; -import component_construction.storage.factories.Factory; +import component_construction.storable.exceptions.MissingEmptyConstructorException; +import component_construction.storable.factories.Factory; /** * An interface defining the ability construct objects of the specified type diff --git a/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java b/src/main/java/component_construction/storable/dynamic_loading/ReflectiveClassConstructor.java similarity index 98% rename from src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java rename to src/main/java/component_construction/storable/dynamic_loading/ReflectiveClassConstructor.java index 58d68e0..e9ccfdf 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructor.java +++ b/src/main/java/component_construction/storable/dynamic_loading/ReflectiveClassConstructor.java @@ -1,4 +1,4 @@ -package component_construction.storage.dynamic_loading; +package component_construction.storable.dynamic_loading; import java.lang.reflect.InvocationTargetException; import java.util.*; diff --git a/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java b/src/main/java/component_construction/storable/dynamic_loading/ReflectivelyLoadable.java similarity index 78% rename from src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java rename to src/main/java/component_construction/storable/dynamic_loading/ReflectivelyLoadable.java index 4d2d9bb..0e61c86 100644 --- a/src/main/java/component_construction/storage/dynamic_loading/ReflectivelyLoadable.java +++ b/src/main/java/component_construction/storable/dynamic_loading/ReflectivelyLoadable.java @@ -1,4 +1,4 @@ -package component_construction.storage.dynamic_loading; +package component_construction.storable.dynamic_loading; import storage.external_interfaces.Loadable; diff --git a/src/main/java/component_construction/storage/exceptions/ComponentCastException.java b/src/main/java/component_construction/storable/exceptions/ComponentCastException.java similarity index 89% rename from src/main/java/component_construction/storage/exceptions/ComponentCastException.java rename to src/main/java/component_construction/storable/exceptions/ComponentCastException.java index 0b260f3..4cb2bc8 100644 --- a/src/main/java/component_construction/storage/exceptions/ComponentCastException.java +++ b/src/main/java/component_construction/storable/exceptions/ComponentCastException.java @@ -1,4 +1,4 @@ -package component_construction.storage.exceptions; +package component_construction.storable.exceptions; public class ComponentCastException extends RuntimeException { diff --git a/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java b/src/main/java/component_construction/storable/exceptions/IncorrectLoadValueFormat.java similarity index 86% rename from src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java rename to src/main/java/component_construction/storable/exceptions/IncorrectLoadValueFormat.java index 7692f36..27b7b63 100644 --- a/src/main/java/component_construction/storage/exceptions/IncorrectLoadValueFormat.java +++ b/src/main/java/component_construction/storable/exceptions/IncorrectLoadValueFormat.java @@ -1,4 +1,4 @@ -package component_construction.storage.exceptions; +package component_construction.storable.exceptions; public class IncorrectLoadValueFormat extends RuntimeException { diff --git a/src/main/java/component_construction/storage/exceptions/IncorrectlyFormattedException.java b/src/main/java/component_construction/storable/exceptions/IncorrectlyFormattedException.java similarity index 75% rename from src/main/java/component_construction/storage/exceptions/IncorrectlyFormattedException.java rename to src/main/java/component_construction/storable/exceptions/IncorrectlyFormattedException.java index 58dcd77..5890745 100644 --- a/src/main/java/component_construction/storage/exceptions/IncorrectlyFormattedException.java +++ b/src/main/java/component_construction/storable/exceptions/IncorrectlyFormattedException.java @@ -1,4 +1,4 @@ -package component_construction.storage.exceptions; +package component_construction.storable.exceptions; public class IncorrectlyFormattedException extends RuntimeException { diff --git a/src/main/java/component_construction/storage/exceptions/MissingEmptyConstructorException.java b/src/main/java/component_construction/storable/exceptions/MissingEmptyConstructorException.java similarity index 71% rename from src/main/java/component_construction/storage/exceptions/MissingEmptyConstructorException.java rename to src/main/java/component_construction/storable/exceptions/MissingEmptyConstructorException.java index 4c1a84c..c143e05 100644 --- a/src/main/java/component_construction/storage/exceptions/MissingEmptyConstructorException.java +++ b/src/main/java/component_construction/storable/exceptions/MissingEmptyConstructorException.java @@ -1,6 +1,6 @@ -package component_construction.storage.exceptions; +package component_construction.storable.exceptions; -import component_construction.storage.dynamic_loading.Loader; +import component_construction.storable.dynamic_loading.Loader; public class MissingEmptyConstructorException extends RuntimeException { diff --git a/src/main/java/component_construction/storage/exceptions/MissingKeyException.java b/src/main/java/component_construction/storable/exceptions/MissingKeyException.java similarity index 93% rename from src/main/java/component_construction/storage/exceptions/MissingKeyException.java rename to src/main/java/component_construction/storable/exceptions/MissingKeyException.java index 8249b1d..127d341 100644 --- a/src/main/java/component_construction/storage/exceptions/MissingKeyException.java +++ b/src/main/java/component_construction/storable/exceptions/MissingKeyException.java @@ -1,4 +1,4 @@ -package component_construction.storage.exceptions; +package component_construction.storable.exceptions; import java.util.Collection; import java.util.stream.Collectors; diff --git a/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java b/src/main/java/component_construction/storable/exceptions/NonExistentComponentException.java similarity index 88% rename from src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java rename to src/main/java/component_construction/storable/exceptions/NonExistentComponentException.java index cd77563..2652ce3 100644 --- a/src/main/java/component_construction/storage/exceptions/NonExistentComponentException.java +++ b/src/main/java/component_construction/storable/exceptions/NonExistentComponentException.java @@ -1,4 +1,4 @@ -package component_construction.storage.exceptions; +package component_construction.storable.exceptions; public class NonExistentComponentException extends RuntimeException { diff --git a/src/main/java/component_construction/storage/exceptions/NonStorableComponentException.java b/src/main/java/component_construction/storable/exceptions/NonStorableComponentException.java similarity index 86% rename from src/main/java/component_construction/storage/exceptions/NonStorableComponentException.java rename to src/main/java/component_construction/storable/exceptions/NonStorableComponentException.java index b589042..44929d7 100644 --- a/src/main/java/component_construction/storage/exceptions/NonStorableComponentException.java +++ b/src/main/java/component_construction/storable/exceptions/NonStorableComponentException.java @@ -1,4 +1,4 @@ -package component_construction.storage.exceptions; +package component_construction.storable.exceptions; import storage.external_interfaces.Storable; diff --git a/src/main/java/component_construction/storage/exceptions/ReflectiveLoadFailure.java b/src/main/java/component_construction/storable/exceptions/ReflectiveLoadFailure.java similarity index 76% rename from src/main/java/component_construction/storage/exceptions/ReflectiveLoadFailure.java rename to src/main/java/component_construction/storable/exceptions/ReflectiveLoadFailure.java index e35f350..6685d55 100644 --- a/src/main/java/component_construction/storage/exceptions/ReflectiveLoadFailure.java +++ b/src/main/java/component_construction/storable/exceptions/ReflectiveLoadFailure.java @@ -1,4 +1,4 @@ -package component_construction.storage.exceptions; +package component_construction.storable.exceptions; public class ReflectiveLoadFailure extends RuntimeException { diff --git a/src/main/java/component_construction/storage/Factories/Factory.java b/src/main/java/component_construction/storable/factories/Factory.java similarity index 84% rename from src/main/java/component_construction/storage/Factories/Factory.java rename to src/main/java/component_construction/storable/factories/Factory.java index db69129..892b688 100644 --- a/src/main/java/component_construction/storage/Factories/Factory.java +++ b/src/main/java/component_construction/storable/factories/Factory.java @@ -1,4 +1,4 @@ -package component_construction.storage.factories; +package component_construction.storable.factories; import storage.storage_values.StorageValue; diff --git a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java b/src/main/java/component_construction/storable/factories/StorableCustomCompilerFactory.java similarity index 97% rename from src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java rename to src/main/java/component_construction/storable/factories/StorableCustomCompilerFactory.java index 4714d03..9a01a72 100644 --- a/src/main/java/component_construction/storage/Factories/StorableCustomCompilerFactory.java +++ b/src/main/java/component_construction/storable/factories/StorableCustomCompilerFactory.java @@ -1,11 +1,12 @@ -package component_construction.storage.factories; +package component_construction.storable.factories; import java.util.*; import code_generation.CodeGenerator; -import component_construction.storage.StorableCustomCompiler; -import component_construction.storage.dynamic_loading.*; -import component_construction.storage.exceptions.*; +import component_construction.storable.StorableCustomCompiler; +import component_construction.storable.dynamic_loading.*; +import component_construction.storable.exceptions.*; +import component_construction.storable.factories.Factory; import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; diff --git a/src/test/java/component_construction/storage/CompilerStorageTests.java b/src/test/java/component_construction/storable/CompilerStorageTests.java similarity index 99% rename from src/test/java/component_construction/storage/CompilerStorageTests.java rename to src/test/java/component_construction/storable/CompilerStorageTests.java index d1c9dba..7b58a0d 100644 --- a/src/test/java/component_construction/storage/CompilerStorageTests.java +++ b/src/test/java/component_construction/storable/CompilerStorageTests.java @@ -1,4 +1,4 @@ -package component_construction.storage; +package component_construction.storable; import static org.junit.jupiter.api.Assertions.*; import java.io.*; diff --git a/src/test/java/component_construction/storage/StorableCustomCompilerTests.java b/src/test/java/component_construction/storable/StorableCustomCompilerTests.java similarity index 58% rename from src/test/java/component_construction/storage/StorableCustomCompilerTests.java rename to src/test/java/component_construction/storable/StorableCustomCompilerTests.java index b452969..12664a6 100644 --- a/src/test/java/component_construction/storage/StorableCustomCompilerTests.java +++ b/src/test/java/component_construction/storable/StorableCustomCompilerTests.java @@ -1,4 +1,4 @@ -package component_construction.storage; +package component_construction.storable; public class StorableCustomCompilerTests { // TODO diff --git a/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java b/src/test/java/component_construction/storable/builders/StorableCustomCompilerBuilderTests.java similarity index 98% rename from src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java rename to src/test/java/component_construction/storable/builders/StorableCustomCompilerBuilderTests.java index d2ce48b..90e3e70 100644 --- a/src/test/java/component_construction/storage/builders/StorableCustomCompilerBuilderTests.java +++ b/src/test/java/component_construction/storable/builders/StorableCustomCompilerBuilderTests.java @@ -1,10 +1,10 @@ -package component_construction.storage.builders; +package component_construction.storable.builders; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import component_construction.ParameterError; -import component_construction.storage.exceptions.NonStorableComponentException; +import component_construction.storable.exceptions.NonStorableComponentException; import grammars.basic_identifier.BasicIdentifierGrammar; import grammars.basic_identifier.convertors.XToYToXSemantic; import lexical_analysis.DynamicTokenRegex; diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java b/src/test/java/component_construction/storable/dynamic_loading/LoadableByTests.java similarity index 95% rename from src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java rename to src/test/java/component_construction/storable/dynamic_loading/LoadableByTests.java index 431b359..07b9de8 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/LoadableByTests.java +++ b/src/test/java/component_construction/storable/dynamic_loading/LoadableByTests.java @@ -1,9 +1,9 @@ -package component_construction.storage.dynamic_loading; +package component_construction.storable.dynamic_loading; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import component_construction.storage.exceptions.IncorrectlyFormattedException; +import component_construction.storable.exceptions.IncorrectlyFormattedException; import test_aids.storage_entities.loadableby_entities.*; public class LoadableByTests { diff --git a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java b/src/test/java/component_construction/storable/dynamic_loading/LoaderTests.java similarity index 83% rename from src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java rename to src/test/java/component_construction/storable/dynamic_loading/LoaderTests.java index 2909123..fca3c0e 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/LoaderTests.java +++ b/src/test/java/component_construction/storable/dynamic_loading/LoaderTests.java @@ -1,9 +1,9 @@ -package component_construction.storage.dynamic_loading; +package component_construction.storable.dynamic_loading; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import component_construction.storage.exceptions.MissingEmptyConstructorException; +import component_construction.storable.exceptions.MissingEmptyConstructorException; import test_aids.storage_entities.*; public class LoaderTests { diff --git a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java b/src/test/java/component_construction/storable/dynamic_loading/ReflectiveClassConstructorTests.java similarity index 99% rename from src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java rename to src/test/java/component_construction/storable/dynamic_loading/ReflectiveClassConstructorTests.java index 0268a9d..d0c7ad8 100644 --- a/src/test/java/component_construction/storage/dynamic_loading/ReflectiveClassConstructorTests.java +++ b/src/test/java/component_construction/storable/dynamic_loading/ReflectiveClassConstructorTests.java @@ -1,4 +1,4 @@ -package component_construction.storage.dynamic_loading; +package component_construction.storable.dynamic_loading; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; diff --git a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java b/src/test/java/component_construction/storable/factories/StorableCustomCompilerFactoryTests.java similarity index 99% rename from src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java rename to src/test/java/component_construction/storable/factories/StorableCustomCompilerFactoryTests.java index 9005fa4..8368ab5 100644 --- a/src/test/java/component_construction/storage/factories/StorableCustomCompilerFactoryTests.java +++ b/src/test/java/component_construction/storable/factories/StorableCustomCompilerFactoryTests.java @@ -1,11 +1,11 @@ -package component_construction.storage.factories; +package component_construction.storable.factories; import static org.junit.jupiter.api.Assertions.*; import java.util.*; import org.junit.jupiter.api.Test; import code_generation.CodeGenerator; -import component_construction.storage.exceptions.*; +import component_construction.storable.exceptions.*; import lexical_analysis.LexicalAnalyser; import storage.storage_values.*; import syntax_analysis.SyntaxAnalyser; diff --git a/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java b/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java index 3f12d4b..f5450e3 100644 --- a/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java +++ b/src/test/java/test_aids/storage_entities/IncorrectlyFormedLoader.java @@ -1,6 +1,6 @@ package test_aids.storage_entities; -import component_construction.storage.dynamic_loading.Loader; +import component_construction.storable.dynamic_loading.Loader; import storage.storage_values.StorageValue; public class IncorrectlyFormedLoader implements Loader { diff --git a/src/test/java/test_aids/storage_entities/TestObjectLoader.java b/src/test/java/test_aids/storage_entities/TestObjectLoader.java index d856a9f..f2846fd 100644 --- a/src/test/java/test_aids/storage_entities/TestObjectLoader.java +++ b/src/test/java/test_aids/storage_entities/TestObjectLoader.java @@ -1,6 +1,6 @@ package test_aids.storage_entities; -import component_construction.storage.dynamic_loading.Loader; +import component_construction.storable.dynamic_loading.Loader; import storage.storage_values.StorageValue; public class TestObjectLoader implements Loader { diff --git a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java index 7e55b35..d528957 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java +++ b/src/test/java/test_aids/storage_entities/custom_components/TestStorableCustomCompiler.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.custom_components; -import component_construction.storage.StorableCustomCompiler; +import component_construction.storable.StorableCustomCompiler; import test_aids.storage_entities.custom_components.loadable.*; public class TestStorableCustomCompiler extends StorableCustomCompiler { diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomCodeGenerator.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomCodeGenerator.java index 08e9ef0..1d15bcf 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomCodeGenerator.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomCodeGenerator.java @@ -1,8 +1,7 @@ package test_aids.storage_entities.custom_components.loadable; import code_generation.CodeGenerator; -import component_construction.storage.StorableCustomCompiler; -import component_construction.storage.dynamic_loading.ReflectivelyLoadable; +import component_construction.storable.dynamic_loading.ReflectivelyLoadable; import storage.external_interfaces.*; import storage.storage_values.*; import syntax_analysis.parsing.ParseState; diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomLexicalAnalyser.java index f9fb735..4a89fd4 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomLexicalAnalyser.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.custom_components.loadable; -import component_construction.storage.dynamic_loading.ReflectivelyLoadable; +import component_construction.storable.dynamic_loading.ReflectivelyLoadable; import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomSyntaxAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomSyntaxAnalyser.java index e4c8bde..68eb5a2 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomSyntaxAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableStorableCustomSyntaxAnalyser.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.custom_components.loadable; -import component_construction.storage.dynamic_loading.ReflectivelyLoadable; +import component_construction.storable.dynamic_loading.ReflectivelyLoadable; import grammar_objects.Token; import storage.external_interfaces.*; import storage.storage_values.*; diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java index 4415954..82a61ef 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadable/LoadableTestStorableCustomCompiler.java @@ -2,7 +2,7 @@ import java.util.Map; -import component_construction.storage.StorableCustomCompiler; +import component_construction.storable.StorableCustomCompiler; import storage.external_interfaces.Loadable; import storage.storage_values.*; diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java index 2b0cf9b..f0feff2 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByCustomLexicalAnalyserLoader.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.custom_components.loadableBy; -import component_construction.storage.dynamic_loading.Loader; +import component_construction.storable.dynamic_loading.Loader; import storage.storage_values.StorageValue; public class LoadableByCustomLexicalAnalyserLoader implements Loader { diff --git a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java index 12133a0..4029e49 100644 --- a/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java +++ b/src/test/java/test_aids/storage_entities/custom_components/loadableBy/LoadableByStorableCustomLexicalAnalyser.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.custom_components.loadableBy; -import component_construction.storage.dynamic_loading.LoadableBy; +import component_construction.storable.dynamic_loading.LoadableBy; import grammar_objects.Token; import lexical_analysis.LexicalAnalyser; import storage.external_interfaces.Storable; diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/ConcretisedGenericTestLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/ConcretisedGenericTestLoadableObject.java index 448171d..2c0256e 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/ConcretisedGenericTestLoadableObject.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/ConcretisedGenericTestLoadableObject.java @@ -1,5 +1,5 @@ package test_aids.storage_entities.loadableby_entities; -import component_construction.storage.dynamic_loading.LoadableBy; +import component_construction.storable.dynamic_loading.LoadableBy; public class ConcretisedGenericTestLoadableObject extends StandardLoader implements GenercicTestInterface, LoadableBy {} \ No newline at end of file diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java index d71c96c..ecad6e0 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericLoader.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.loadableby_entities; -import component_construction.storage.dynamic_loading.Loader; +import component_construction.storable.dynamic_loading.Loader; import storage.storage_values.StorageValue; public class GenericLoader implements Loader { diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestLoadableObject.java index 6dbd8c6..cbc0066 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestLoadableObject.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericTestLoadableObject.java @@ -1,5 +1,5 @@ package test_aids.storage_entities.loadableby_entities; -import component_construction.storage.dynamic_loading.LoadableBy; +import component_construction.storable.dynamic_loading.LoadableBy; public class GenericTestLoadableObject extends StandardLoader implements GenercicTestInterface, LoadableBy {} \ No newline at end of file diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericallyLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericallyLoadableObject.java index 3175abb..e0f5144 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/GenericallyLoadableObject.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/GenericallyLoadableObject.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.loadableby_entities; -import component_construction.storage.dynamic_loading.LoadableBy; +import component_construction.storable.dynamic_loading.LoadableBy; public record GenericallyLoadableObject(int a) implements LoadableBy> {} diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/LoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/LoadableObject.java index 17c7571..0bc390f 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/LoadableObject.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/LoadableObject.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.loadableby_entities; -import component_construction.storage.dynamic_loading.LoadableBy; +import component_construction.storable.dynamic_loading.LoadableBy; public record LoadableObject(int a) implements LoadableBy {} diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/StandardLoader.java b/src/test/java/test_aids/storage_entities/loadableby_entities/StandardLoader.java index ef8a34b..9e6d86c 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/StandardLoader.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/StandardLoader.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.loadableby_entities; -import component_construction.storage.dynamic_loading.Loader; +import component_construction.storable.dynamic_loading.Loader; import storage.storage_values.StorageValue; public class StandardLoader implements Loader { diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/TestLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/TestLoadableObject.java index 8a433a1..09e60b5 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/TestLoadableObject.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/TestLoadableObject.java @@ -1,5 +1,5 @@ package test_aids.storage_entities.loadableby_entities; -import component_construction.storage.dynamic_loading.LoadableBy; +import component_construction.storable.dynamic_loading.LoadableBy; public class TestLoadableObject extends StandardLoader implements TestInterface, LoadableBy {} \ No newline at end of file diff --git a/src/test/java/test_aids/storage_entities/loadableby_entities/WildcardLoadableObject.java b/src/test/java/test_aids/storage_entities/loadableby_entities/WildcardLoadableObject.java index 4c206f0..1f87236 100644 --- a/src/test/java/test_aids/storage_entities/loadableby_entities/WildcardLoadableObject.java +++ b/src/test/java/test_aids/storage_entities/loadableby_entities/WildcardLoadableObject.java @@ -1,6 +1,6 @@ package test_aids.storage_entities.loadableby_entities; -import component_construction.storage.dynamic_loading.*; +import component_construction.storable.dynamic_loading.*; public record WildcardLoadableObject(int a) implements LoadableBy> {}