Class GoogleQueryBuilder<T>

  • Type Parameters:
    T - the type of original source content (String or TextFragment)

    public class GoogleQueryBuilder<T>
    extends Object
    Builder for Google Cloud Translation API v3 queries. Manages batching of translation requests.
    • Constructor Detail

      • GoogleQueryBuilder

        public GoogleQueryBuilder​(String sourceLanguage,
                                  String targetLanguage)
    • Method Detail

      • addQuery

        public void addQuery​(String queryText,
                             T originalSource)
        Add a query to the batch. * @param queryText the text to translate
        Parameters:
        originalSource - the original source object
      • hasCapacity

        public boolean hasCapacity​(String text)
        Check if there is capacity to add the given text. * @param text the text to check
        Returns:
        true if the text can be added without exceeding limits
      • reset

        public void reset()
        Reset the builder for a new batch.
      • getSourceLanguage

        public String getSourceLanguage()
      • getTargetLanguage

        public String getTargetLanguage()
      • getSources

        public List<T> getSources()
      • getSourceCount

        public int getSourceCount()
      • getQuery

        public String getQuery()