docs: @SuppressWarnings("unchecked")
      public static Predicate basicCreatePredicateFromSingleCriteria(CriteriaBuilder builder, Expression entityField, QueryCriteria criteria) {
          Predicate predicate = null;
          List<Object> parameters = criteria.getParameters();
          int numParameters = parameters.size();
          assert ! parameters.isEmpty() : "Empty parameters for criteria [" + criteria.toString() + "]";
          switch ( criteria.getType() ) {
          case NORMAL:
              if( numParameters == 1 ) {
                  Object parameter = parameters.get(0);
                  assert parameter != null : "Null parameter for criteria [" + criteria.toString() + "]";
                  predicate = builder.equal(entityField, parameter);
              } else {
                  assert parameters.get(0) != null : "Null 1rst parameter for criteria [" + criteria.toString() + "]";
                  assert parameters.get(parameters.size()-1) != null : "Null last parameter for criteria [" + criteria.toString() + "]";
                  predicate = entityField.in(parameters);
              }
              break;
          case REGEXP:
              List<Predicate> predicateList = new ArrayList<Predicate>();
              for( Object param : parameters ) {
                  assert param != null : "Null regular expression parameter for criteria [" + criteria.toString() + "]";
                  String likeRegex = convertRegexToJPALikeExpression((String) param );
                  Predicate regexPredicate = builder.like((Expression<String>) entityField, likeRegex);
                  predicateList.add(regexPredicate);
              }
              if( predicateList.size() == 1 ) {
                  predicate = predicateList.get(0);
              } else {
                  Predicate [] predicates = predicateList.toArray(new Predicate[predicateList.size()]);
                  if( criteria.isUnion() ) {
                      predicate = builder.or(predicates);
                  } else {
                      predicate = builder.and(predicates);
                  }
              }
              break;
          case RANGE:
              assert numParameters > 0 && numParameters < 3: "Range expressions may only contain between 1 and 2 parameters, not " + numParameters + " [" + criteria.toString() + "]";
              Object [] rangeObjArr = parameters.toArray();
              Class rangeType = rangeObjArr[0] != null ? rangeObjArr[0].getClass() : rangeObjArr[1].getClass();
              predicate = createRangePredicate( builder, entityField, rangeObjArr[0], rangeObjArr[1], rangeType);
              break;
          default:
              throw new IllegalStateException("Unknown criteria type: " + criteria.getType());
          }
          assert predicate != null : "No predicate created "
                  + "when evaluating " + criteria.getType().toString().toLowerCase() + " criteria "
                  + "[" + criteria.toString() + "]";
  
          return predicate;
      }