Skip to content

Commit a96405b

Browse files
committed
add sanity check that prompts can only be modified once
1 parent a64ca3a commit a96405b

File tree

1 file changed

+9
-0
lines changed
  • src/main/java/edu/kit/kastel/mcse/ardoco/naer/recognizer

1 file changed

+9
-0
lines changed

src/main/java/edu/kit/kastel/mcse/ardoco/naer/recognizer/Prompt.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public abstract class Prompt {
2121
private static final Logger logger = LoggerFactory.getLogger(Prompt.class);
2222
protected final SystemMessage systemMessage = new SystemMessage("You are a software engineer and software architect.");
2323
protected String text;
24+
private boolean modified = false;
2425

2526
/**
2627
* Constructs a new {@link Prompt} instance.
@@ -52,8 +53,16 @@ public String getText() {
5253
* as values. Each type represents a category (e.g., COMPONENT, INTERFACE),
5354
* and each set contains the names of entities belonging to that type.
5455
* Must not be null or contain null keys/values.
56+
* @throws IllegalStateException if the prompt has already been modified (addPossibleEntities can only be called once)
5557
*/
5658
public void addPossibleEntities(Map<NamedEntityType, Set<String>> possibleEntities) {
59+
if (modified) {
60+
// TODO we need to refactor the modification of the prompt!
61+
throw new IllegalStateException("Cannot modify prompt after already modified.");
62+
}
63+
64+
modified = true;
65+
5766
StringBuilder sb = new StringBuilder();
5867

5968
for (Map.Entry<NamedEntityType, Set<String>> entry : possibleEntities.entrySet()) {

0 commit comments

Comments
 (0)