Class PhraseTranslator

java.lang.Object
lv.id.jc.piglatin.core.PhraseTranslator
All Implemented Interfaces:
Function<String,String>, UnaryOperator<String>

@Component("phraseTranslator") public class PhraseTranslator extends Object implements UnaryOperator<String>
The PhraseTranslator class translates a phrase to Pig Latin.
  • Constructor Details

    • PhraseTranslator

      public PhraseTranslator(Function<String,Matcher> wordMatcher, @Validated @Qualifier("wordTranslator") UnaryOperator<String> wordTranslator)
      Constructs a new PhraseTranslator.
      Parameters:
      wordMatcher - a function that takes a string and returns a Matcher for words in the string
      wordTranslator - a function that takes a string and translates it to Pig Latin
  • Method Details

    • apply

      public String apply(String phrase)
      Translates a phrase to Pig Latin.
      Specified by:
      apply in interface Function<String,String>
      Parameters:
      phrase - the phrase to translate
      Returns:
      the translated phrase