code: @SuppressWarnings("unchecked")
      private static <Y extends Comparable<? super Y>> Predicate createRangePredicate( CriteriaBuilder builder, Expression field, Object start, Object end, Class<Y> rangeType ) {
          if( start != null && end != null ) {
              // TODO :asserts!
              return builder.between(field, (Y) start, (Y) end);
          } else if ( start != null ) {
              return builder.greaterThanOrEqualTo(field, (Y) start);
          } else {
              return builder.lessThanOrEqualTo(field, (Y) end);
          }
      }
docs: Helper method for creating a ranged (between, open-ended) {@link Predicate}
  
  @param builder The {@link CriteriaBuilder}, helpful when creating {@link Predicate}s to add to the {@link CriteriaQuery}
  @param entityField The {@link Expression} representing a field/column in an entity/table.
  @param start The start value of the range, or null if open-ended (on the lower end)
  @param end The end value of the range, or null if open-ended (on the upper end)
  @param rangeType The {@link Class} or the parameter values
  @return The created {@link Predicate}