code: public int addTerm(Term term) {
          if (term == null) {
              throw new InvalidArgument("term is null");
          }
  
          // if we have already seen this term, return its index
          Integer visitedIndex = visitedTerms.get(term);
          if (visitedIndex != null) {
              return visitedIndex;
          }
  
          String termSignature = term.toTermSignature();
          final String shared = termStrings.get(termSignature);
          if (shared != null) {
              termSignature = shared;
          } else {
              termStrings.put(termSignature, termSignature);
          }
  
          // add this new term
          int termIndex = termValues.size();
          termValues.add(termSignature);
  
          // index the new term
          visitedTerms.put(term, termIndex);
          indexedTerms.put(termIndex, term);
          globalTermIndex.put(termIndex, globalTermIndex.size());
  
          return termIndex;
      }
docs: Adds a term to the {@code terms} set. The insertion index and term
  occurrences are also indexed in the {@code index} and {@code count} map.
  
  @param term {@link Term}, the term to be added as a {@link String} to the
  {@code terms} set, which cannot be null
  @throws InvalidArgument Thrown if {@code term} is null