Class FactGenerator

java.lang.Object
hudson.plugins.chucknorris.FactGenerator

public class FactGenerator extends Object
FactGenerator provides Chuck Norris facts.
Author:
cliffano
  • 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

      public String randomCustomFact(List<String> customFacts, boolean customFactsOnly)
      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 facts
      customFactsOnly - true to pick only from the custom facts
      Returns:
      the custom fact, or null to use a built-in fact
    • getFact

      public static String getFact(int index, Locale locale)
      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 index
      locale - the locale to use for lookup
      Returns:
      the localized fact string