code: private ProcPattern createPattern(Pattern pattern) {
          if (pattern.isEmpty()) {
              throw new IllegalStateException("Pattern elements list can't be empty.");
          }
  
          List<ProcPatternElement> elements = new ArrayList<ProcPatternElement>();
          for (PatternElement element : pattern.getElements()) {
              elements.add(patternElementFactory.create(element));
          }
          return new ProcPattern(elements);
      }
docs: Create a pattern for text parsing
  
  @param pattern pattern definition
  @return pattern pattern