String (@Nullable String defaultTarget) { boolean useDefaultTarget = defaultTarget != null && myEnv.generateValue(Generator.booleans(), null); if (useDefaultTarget) return defaultTarget; boolean useConstant = myEnv.generateValue(Generator.booleans(), null); if (useConstant) return "\"foo\""; if (myMethodParams.isEmpty() && myRegisteredVars.isEmpty()) return declareParameter(); List<String> targets = new ArrayList<>(myMethodParams); targets.addAll(myRegisteredVars); targets.add("\"foo\""); if (defaultTarget != null) targets.add(defaultTarget); int nTargets = myEnv.generateValue(Generator.integers(1, 3), null); String target = IntStream.range(1, nTargets + 1) .mapToObj(i -> myEnv.generateValue(Generator.sampledFrom(targets), null)) .collect(Collectors.joining("+")); return nTargets > 1 ? "(" + target + ")" : target; }