Class RandomActionSequenceGenerator
The class provides the following functionality: Reading the maximum action sequence length from a configuration file. Generating a random action sequence string based on predefined actions.
Usage: Create an instance of RandomActionSequenceGenerator. Call the generateRandomActionSequence() method to generate a random action sequence.
Note: The maximum length of the action sequence is determined by the configuration file. The class uses a pseudo-random number generator to select actions from the available options.
Example: RandomActionSequenceGenerator generator = new RandomActionSequenceGenerator(); String actionSequence = generator.generateRandomActionSequence();
This class is part of the randomGenerators package, which provides utilities for generating random data or sequences in a controlled manner.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a RandomActionSequenceGenerator object. -
Method Summary
Modifier and TypeMethodDescriptiongenerateAllPossibleCombinations(int length, boolean atLeastOneExit, boolean startWithExitCheck) Generates a list of all possible combination of the given characters with the inputted length.Generates a random action sequence string based on predefined actions, with the length of the action sequence is determined by the configuration file.static StringGenerates a random action sequence string based on predefined actions.static StringgenerateRandomCombination(int length, boolean atLeastOneExit, boolean startWithExitCheck) The problem with the generateAllPossibleCombinations() method is that when the length is a larger number, the total of possible combinations grows exponentially and the program soon runs out of java heap space.mutateActionSequence(String actionSequence) This method mutates the given action sequence, by replacing each character of the string in turn, with each of the valid characters.
-
Constructor Details
-
RandomActionSequenceGenerator
public RandomActionSequenceGenerator()Constructs a RandomActionSequenceGenerator object. It initializes the maximum length of the action sequence from the configuration file.
-
-
Method Details
-
generateRandomActionSequenceValidCharRandomLength
Generates a random action sequence string based on predefined actions. The length of the action sequence is randomly, but the maximum is determined by the maxLength parameter.- Returns:
- The generated random action sequence string.
-
generateRandomActionSequence
Generates a random action sequence string based on predefined actions, with the length of the action sequence is determined by the configuration file.- Returns:
- The generated random action sequence string.
-
generateAllPossibleCombinations
public static List<String> generateAllPossibleCombinations(int length, boolean atLeastOneExit, boolean startWithExitCheck) Generates a list of all possible combination of the given characters with the inputted length.- Parameters:
length- The length of the action sequence.atLeastOneExit- If true, the list will contain at least one exit action.startWithExitCheck- If true, the list will contain several strings. If an S is present, one of the following characters in the string (that are after an S) will be an E.- Returns:
- A list of all possible combination of the given characters with the inputted length.
-
generateRandomCombination
public static String generateRandomCombination(int length, boolean atLeastOneExit, boolean startWithExitCheck) The problem with the generateAllPossibleCombinations() method is that when the length is a larger number, the total of possible combinations grows exponentially and the program soon runs out of java heap space. If u do not want all possible combinations, but just a few random ones, this method can help avoiding this problem. It generates a random possible combination.- Parameters:
length- The length of the action sequence.atLeastOneExit- If true, the string will contain at least one exit action.startWithExitCheck- If true, the following will always be true for the result: If an S is present, one of the following characters in the string (that are after an S) will be an E.- Returns:
- A random possible combination as String.
-
mutateActionSequence
This method mutates the given action sequence, by replacing each character of the string in turn, with each of the valid characters. It will return a list of all possible mutated action sequences.- Parameters:
actionSequence- The action sequence to mutate.- Returns:
- A list of all possible mutated action sequences.
-