Class RandomExpressionGenerator


  • public class RandomExpressionGenerator
    extends Object
    Generates random Picasso expressions
    • Constructor Detail

      • RandomExpressionGenerator

        public RandomExpressionGenerator()
        Creates a RandomExpressionGenerator with a random seed
      • RandomExpressionGenerator

        public RandomExpressionGenerator​(long seed)
        Creates a RandomExpressionGenerator with a specific seed Same seed will produce the same sequence of expressions
        Parameters:
        seed - the seed value
      • RandomExpressionGenerator

        public RandomExpressionGenerator​(long seed,
                                         boolean allowRandom)
        Creates a RandomExpressionGenerator with a specific seed and random control
        Parameters:
        seed - the seed value
        allowRandom - if false, random() won't appear in generated expressions
    • Method Detail

      • setSeed

        public void setSeed​(long seed)
        Sets the seed for the random number generator.
        Parameters:
        seed - the seed value
      • setAllowRandom

        public void setAllowRandom​(boolean allowRandom)
        Sets whether random() function is allowed in generated expressions
        Parameters:
        allowRandom - true to allow random(), false to exclude it
      • isAllowRandom

        public boolean isAllowRandom()
        Returns whether random() is allowed in generated expressions
        Returns:
        true if random() is allowed
      • getNoArgFunctions

        public static List<String> getNoArgFunctions()
        Returns noArgFunctions.
        Returns:
        noArgFunctions.
      • getUnaryFunctions

        public static List<String> getUnaryFunctions()
        Returns unaryFunctions.
        Returns:
        unaryFunctions.
      • getImageFunctions

        public static List<String> getImageFunctions()
        Returns imageFunctions.
        Returns:
        imageFunctions.
      • getOperations

        public static List<String> getOperations()
        Returns operations.
        Returns:
        operations.
      • generate

        public String generate()
        Generates a random expression with a randomly determined depth (1-15)
        Returns:
        a randomly generated Picasso expression string
      • generateExpression

        public String generateExpression​(int depth)
        Generates a random expression with the given depth
        Parameters:
        depth - the maximum nesting depth
        Returns:
        a randomly generated Picasso expression string