Package hudson.plugins.chucknorris
Class FactGenerator
java.lang.Object
hudson.plugins.chucknorris.FactGenerator
FactGenerator provides Chuck Norris facts.- Author:
- cliffano
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringRetrieves a fact by index for the given locale.randomCustomFact(List<String> customFacts, boolean customFactsOnly) Picks a custom fact, or none so that a built-in fact is used.intRetrieves a random fact index.
-
Constructor Details
-
FactGenerator
public FactGenerator()
-
-
Method Details
-
randomIndex
public int randomIndex()Retrieves a random fact index.- Returns:
- a random index into the facts list
-
randomCustomFact
Picks a custom fact, or none so that a built-in fact is used. Every fact is equally likely: with the built-in facts mixed in, a custom fact is picked as often as any single built-in fact.- Parameters:
customFacts- the custom factscustomFactsOnly- true to pick only from the custom facts- Returns:
- the custom fact, or null to use a built-in fact
-
getFact
Retrieves a fact by index for the given locale. If there is no fact with that index (for example because facts were removed in a later release), the localized fallback fact is returned instead.- Parameters:
index- the fact indexlocale- the locale to use for lookup- Returns:
- the localized fact string
-