use of net.andreinc.mockneat.types.enums.StringFormatType.CAPITALIZED in project mockneat by nomemory.
the class HrSchema method streeNameGenerator.
/**
* Returns an arbitrary street name.
* @return
*/
private static final MockUnitString streeNameGenerator() {
// A reference to the mock add associated with the current thread;
MockNeat m = MockNeat.threadLocal();
// Returns a random string from the 'STREET_SUFFIX' list;
// Eg: "Str"
MockUnitString streetNameSuffix = m.fromStrings(STREET_SUFFIX);
// Returns a potential street name
// - Streets names have 55% chances of containing two words;
// - Street names have 45% chances of containing one word;
// The single word is always a noun (1 syllable, 2 syllables or 3 syllables)
// The first word if exists is an adjective (1 syllable or 2 syllables)
MockUnitString streetNameGenerator = m.fmt("#{word1}#{word2}").param("word1", m.probabilites(String.class).add(0.55, m.dicts().types(EN_ADJECTIVE_1SYLL, EN_ADJECTIVE_2SYLL)).add(0.45, "").mapToString(s -> s.equals("") ? s : s + " ").format(CAPITALIZED)).param("word2", m.dicts().types(EN_NOUN_1SYLL, EN_NOUN_2SYLL, EN_NOUN_3SYLL).format(CAPITALIZED));
// - Last section is the suffix as obtained above
return m.fmt("#{no} #{name} #{suffix}").param("no", m.ints().range(1, 10000)).param("name", streetNameGenerator).param("suffix", streetNameSuffix);
}
Aggregations