code: public int size() {
          if (size == -1) {
              if ((from instanceof Integer || from instanceof Long)
                      && (to instanceof Integer || to instanceof Long)) {
                  // let's fast calculate the size
                  long fromNum = ((Number) from).longValue();
                  long toNum = ((Number) to).longValue();
                  size = (int) (toNum - fromNum + 1);
              } else if (from instanceof Character && to instanceof Character) {
                  // let's fast calculate the size
                  char fromNum = (Character) from;
                  char toNum = (Character) to;
                  size = toNum - fromNum + 1;
              } else if (from instanceof BigDecimal || to instanceof BigDecimal ||
                         from instanceof BigInteger || to instanceof BigInteger) {
                  // let's fast calculate the size
                  BigDecimal fromNum = new BigDecimal(from.toString());
                  BigDecimal toNum = new BigDecimal(to.toString());
                  BigInteger sizeNum = toNum.subtract(fromNum).add(new BigDecimal(1.0)).toBigInteger();
                  size = sizeNum.intValue();
              } else {
                  // let's lazily calculate the size
                  size = 0;
                  Comparable first = from;
                  Comparable value = from;
                  while (compareTo(to, value) >= 0) {
                      value = (Comparable) increment(value);
                      size++;
                      if (compareTo(first, value) >= 0) break; // handle back to beginning due to modulo incrementing
                  }
              }
          }
          return size;
      }
docs: {@inheritDoc}