code: @SuppressWarnings("unchecked")
      @Override
      public <S> S[] toArray(S[] targetArray) {
          if (this.size > targetArray.length) {
              Class<?> componentType = this.storage.getClass().getComponentType();
              targetArray = (S[]) Array.newInstance(componentType, this.size);
          }
  
          System.arraycopy(this.storage, 0, targetArray, 0, this.size);
  
          if (this.size < targetArray.length) {
              for (int offset = this.size; offset < targetArray.length; offset++) {
                  targetArray[offset] = null;
              }
          }
  
          return targetArray;
      }
docs: {@inheritDoc}