Create a new criteria from an expression

@link https://hoa-project.net/En/Literature/Hack/Ruler.html
355504
public function criteria(string $expression): CriteriaInterface
    {
        return $this->visitor()->visit(\Hoa\Ruler\Ruler::interpret($expression));
    }
582552
protected <O> CriteriaQuery<O> createCriteriaQuery(Class<O> clazz)
	{
		return getCriteriaBuilder().createQuery(clazz);
	}
812814
public function buildCriteria()
    {
        $criteria = new Criteria(LoginLogTableMap::DATABASE_NAME);

        if ($this->isColumnModified(LoginLogTableMap::COL_ID)) {
            $criteria->add(LoginLogTableMap::COL_ID, $this->id);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_TYPE)) {
            $criteria->add(LoginLogTableMap::COL_TYPE, $this->type);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_DATE_TIME)) {
            $criteria->add(LoginLogTableMap::COL_DATE_TIME, $this->date_time);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_USER_ID)) {
            $criteria->add(LoginLogTableMap::COL_USER_ID, $this->user_id);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_USERNAME)) {
            $criteria->add(LoginLogTableMap::COL_USERNAME, $this->username);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_SESSION_ID)) {
            $criteria->add(LoginLogTableMap::COL_SESSION_ID, $this->session_id);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_ADDRESS)) {
            $criteria->add(LoginLogTableMap::COL_CLIENT_ADDRESS, $this->client_address);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_IP)) {
            $criteria->add(LoginLogTableMap::COL_CLIENT_IP, $this->client_ip);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_AGENT)) {
            $criteria->add(LoginLogTableMap::COL_CLIENT_AGENT, $this->client_agent);
        }
        if ($this->isColumnModified(LoginLogTableMap::COL_CLIENT_PLATFORM)) {
            $criteria->add(LoginLogTableMap::COL_CLIENT_PLATFORM, $this->client_platform);
        }

        return $criteria;
    }
1316385
public void addOrCriteria(Criteria pc)
    {
        if (!m_criteria.isEmpty())
        {
            pc.setEmbraced(true);
            pc.setType(OR);
            addCriteria(pc);
        }
        else
        {
            setEmbraced(false);
            pc.setType(OR);
            addCriteria(pc);
        }
    }
847409
public static <T> JDOQuery<T> select(Expression<T> expr) {
        return new JDOQuery<Void>().select(expr);
    }
1222814
public void addExpression() {
        SWRL expression = getOWLModel().createSWRLExpression(null);
        if (getOWLValueObject().owlValue().isIndividual()) {
            SWRLIndividual swrlIndividual = swrl().wrapIndividual(getOWLValueObject().owlValue().castTo(OWLIndividual.class));
            Atom atom = swrl().createSameIndividualAtom(swrlIndividual, swrlIndividual);
            expression.setBody(swrl().createList(atom));
            asOWLSResult().addEffect(expression);
        }       
    }
726458
@Override
    public List<AbstractExpression> bindingToIndexedExpression(AbstractExpression expr) {
        if (m_originalValue == null || ! m_originalValue.equals(expr)) {
            return null;
        }
        // This parameter's value was matched, so return this as one bound parameter.
        List<AbstractExpression> result = new ArrayList<AbstractExpression>();
        result.add(this);
        return result;
    }
278978
public org.grails.datastore.mapping.query.api.Criteria le(String propertyName, Object propertyValue) {
        if (!validateSimpleExpression()) {
            throwRuntimeException(new IllegalArgumentException("Call to [le] with propertyName [" +
                    propertyName + "] and value [" + propertyValue + "] not allowed here."));
        }

        propertyName = calculatePropertyName(propertyName);
        propertyValue = calculatePropertyValue(propertyValue);
        Criterion le;
        if (propertyValue instanceof org.hibernate.criterion.DetachedCriteria) {
            le = Property.forName(propertyName).le((org.hibernate.criterion.DetachedCriteria) propertyValue);
        }
        else {
            le = Restrictions.le(propertyName, propertyValue);
        }
        addToCriteria(le);
        return this;
    }
862820
public function buildCriteria()
    {
        $criteria = new Criteria(DealerShedulesVersionTableMap::DATABASE_NAME);

        if ($this->isColumnModified(DealerShedulesVersionTableMap::ID)) $criteria->add(DealerShedulesVersionTableMap::ID, $this->id);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::DEALER_ID)) $criteria->add(DealerShedulesVersionTableMap::DEALER_ID, $this->dealer_id);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::DAY)) $criteria->add(DealerShedulesVersionTableMap::DAY, $this->day);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::BEGIN)) $criteria->add(DealerShedulesVersionTableMap::BEGIN, $this->begin);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::END)) $criteria->add(DealerShedulesVersionTableMap::END, $this->end);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::CLOSED)) $criteria->add(DealerShedulesVersionTableMap::CLOSED, $this->closed);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::PERIOD_BEGIN)) $criteria->add(DealerShedulesVersionTableMap::PERIOD_BEGIN, $this->period_begin);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::PERIOD_END)) $criteria->add(DealerShedulesVersionTableMap::PERIOD_END, $this->period_end);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::CREATED_AT)) $criteria->add(DealerShedulesVersionTableMap::CREATED_AT, $this->created_at);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::UPDATED_AT)) $criteria->add(DealerShedulesVersionTableMap::UPDATED_AT, $this->updated_at);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::VERSION)) $criteria->add(DealerShedulesVersionTableMap::VERSION, $this->version);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::VERSION_CREATED_AT)) $criteria->add(DealerShedulesVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::VERSION_CREATED_BY)) $criteria->add(DealerShedulesVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
        if ($this->isColumnModified(DealerShedulesVersionTableMap::DEALER_ID_VERSION)) $criteria->add(DealerShedulesVersionTableMap::DEALER_ID_VERSION, $this->dealer_id_version);

        return $criteria;
    }
208037
@Nonnull
    private static RuleEvaluator makeRuleEvaluator(final ExpressionFactory expressionFactory, final FunctionMapper functionMapper) {
        // Make the expression evaluation context.
        final Map<String, Object> testConstants = Collections.emptyMap();

        return new RuleEvaluator(expressionFactory, functionMapper, testConstants);
    }
1128696
final public ThenExpressionBuilder<T> ifExp() {
    return new ThenExpressionBuilder<T>(new ExpressionHandler<ThenBuilder<T>>() {
      public ThenBuilder<T> handleExpression(final Expression e) {
        return new ThenBuilder<T>(e, new IfStatementHandler<T>() {
          public T handleStatement(IfStatement ifStatement) {
            return statementHandler().handleStatement(ifStatement);
          }
        }, builder);
      }
    });
  }
728101
public static Criteria parseConditionToCriteria(Condition condition,
			Criteria criteria, Class<?> persistentClass) {
		// 创建一个Or的连接条件集合
		Disjunction disjunction = Restrictions.disjunction();
		parseConditionToJunction(condition, disjunction, persistentClass);
		return criteria.add(disjunction);
	}
1048273
@Nullable
  public VirtualColumn getOrCreateVirtualColumnForExpression(
      PlannerContext plannerContext,
      DruidExpression expression,
      SqlTypeName typeName
  )
  {
    if (!isAggregateSignature && !virtualColumnsByExpression.containsKey(expression.getExpression())) {
      final String virtualColumnName = virtualColumnPrefix + virtualColumnCounter++;
      final VirtualColumn virtualColumn = expression.toVirtualColumn(
          virtualColumnName,
          Calcites.getValueTypeForSqlTypeName(typeName),
          plannerContext.getExprMacroTable()
      );
      virtualColumnsByExpression.put(
          expression.getExpression(),
          virtualColumn
      );
      virtualColumnsByName.put(
          virtualColumnName,
          virtualColumn
      );
    }

    return virtualColumnsByExpression.get(expression.getExpression());
  }
134503
public <R> Predicate createPredicate(QueryCriteria criteria, CriteriaQuery<R> query, CriteriaBuilder builder) {
        // subquery and root
        Root<TaskImpl> taskRoot = getRoot(query, TaskImpl.class);
        Subquery<Long> subQuery = query.subquery(Long.class);
        Root<TaskVariableImpl> taskVarRoot = subQuery.from(TaskVariableImpl.class);
        subQuery.select(taskVarRoot.get(TaskVariableImpl_.taskId));

        // task variable predicate (in subquery)
        Predicate taskVariablePredicate = null;
        String listId = criteria.getListId();
        if( TASK_VARIABLE_COMBINED_ID.equals(listId) ) {
            List<QueryCriteria> taskVarSubCriteriaList = criteria.getCriteria();
            int size = taskVarSubCriteriaList.size();
            Predicate[] taskVarSubPredicates = new Predicate[size];
            for( int i = 0; i < size; ++i ) {
                taskVarSubPredicates[i] = createSingleTaskVariableCriteriaPredicate(
                        builder, taskVarRoot, taskVarSubCriteriaList.get(i));
            }
            taskVariablePredicate = builder.and(taskVarSubPredicates);
        } else {
            taskVariablePredicate = createSingleTaskVariableCriteriaPredicate(builder, taskVarRoot, criteria);
        }

        // add predicate to subquery
        subQuery.where(taskVariablePredicate);

        // create predicate for actual query that references subquery
        return taskRoot.get(TaskImpl_.id).in(subQuery);
    }
534356
@SuppressWarnings({ "rawtypes", "unchecked" })
    private Predicate[] analyzeParamMap(CriteriaBuilder criteriaBuilder, Root from, Map<String, Object> param) {
        List<Predicate> predicates = new ArrayList<Predicate>();

        for (Map.Entry<String, Object> entry : param.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (key.equals("timestamp")) {
                predicates.add(criteriaBuilder.le(from.get("timestamp"), (Long) value));
            } else if (key.equals("committer")) {
                predicates.add(criteriaBuilder.equal(from.get("committer"), value));
            } else if (key.equals("context")) {
                predicates.add(criteriaBuilder.equal(from.get("context"), value));
            }
        }
        Predicate[] temp = new Predicate[predicates.size()];
        for (int i = 0; i < predicates.size(); i++) {
            temp[i] = predicates.get(i);
        }

        return temp;
    }
1183054
public function buildCriteria()
    {
        $criteria = new Criteria(DealerAdminVersionTableMap::DATABASE_NAME);

        if ($this->isColumnModified(DealerAdminVersionTableMap::ID)) $criteria->add(DealerAdminVersionTableMap::ID, $this->id);
        if ($this->isColumnModified(DealerAdminVersionTableMap::DEALER_ID)) $criteria->add(DealerAdminVersionTableMap::DEALER_ID, $this->dealer_id);
        if ($this->isColumnModified(DealerAdminVersionTableMap::ADMIN_ID)) $criteria->add(DealerAdminVersionTableMap::ADMIN_ID, $this->admin_id);
        if ($this->isColumnModified(DealerAdminVersionTableMap::CREATED_AT)) $criteria->add(DealerAdminVersionTableMap::CREATED_AT, $this->created_at);
        if ($this->isColumnModified(DealerAdminVersionTableMap::UPDATED_AT)) $criteria->add(DealerAdminVersionTableMap::UPDATED_AT, $this->updated_at);
        if ($this->isColumnModified(DealerAdminVersionTableMap::VERSION)) $criteria->add(DealerAdminVersionTableMap::VERSION, $this->version);
        if ($this->isColumnModified(DealerAdminVersionTableMap::VERSION_CREATED_AT)) $criteria->add(DealerAdminVersionTableMap::VERSION_CREATED_AT, $this->version_created_at);
        if ($this->isColumnModified(DealerAdminVersionTableMap::VERSION_CREATED_BY)) $criteria->add(DealerAdminVersionTableMap::VERSION_CREATED_BY, $this->version_created_by);
        if ($this->isColumnModified(DealerAdminVersionTableMap::DEALER_ID_VERSION)) $criteria->add(DealerAdminVersionTableMap::DEALER_ID_VERSION, $this->dealer_id_version);

        return $criteria;
    }
1260240
def [](property)
      property_instance = @entity_set.new_entity.get_property(property)
      property_instance = property if property_instance.nil?
      OData::Query::Criteria.new(property: property_instance)
    end