Builds the PushDownBooleanExpressionProposal.
438767
private Optional<PushDownBooleanExpressionProposal> buildProposal(
            JoinOrFilterNode providerNode, ImmutableMultimap<Recipient, ImmutableExpression> recipientMap) {

        ImmutableCollection<Map.Entry<Recipient, ImmutableExpression>> recipientEntries = recipientMap.entries();
        /*
         * Collect new direct recipients nodes for each expression,
         * filtering out provider nodes, and therefore also LeftJoinNodes.
         */
        ImmutableMultimap<CommutativeJoinOrFilterNode, ImmutableExpression> directRecipientNodes = recipientEntries.stream()
                .filter(e -> e.getKey().directRecipientNode.isPresent())
                .filter(e -> e.getKey().directRecipientNode.get() != providerNode)
                .map(e -> new AbstractMap.SimpleEntry<>(
                        (CommutativeJoinOrFilterNode) e.getKey().directRecipientNode.get(), e.getValue()))
                .collect(ImmutableCollectors.toMultimap());
        /*
         * Collect indirect recipient nodes
         */
        ImmutableMultimap<QueryNode, ImmutableExpression> indirectRecipientNodes = recipientEntries.stream()
                .filter(e -> e.getKey().indirectRecipientNode.isPresent())
                .map(e -> new AbstractMap.SimpleEntry<>(e.getKey().indirectRecipientNode.get(), e.getValue()))
                .collect(ImmutableCollectors.toMultimap());

        if (directRecipientNodes.isEmpty() && indirectRecipientNodes.isEmpty()) {
            return Optional.empty();
        } else {
            ImmutableList<ImmutableExpression> expressionsToKeep = recipientEntries.stream()
                    .filter(e -> e.getKey().directRecipientNode.isPresent())
                    .filter(e -> e.getKey().directRecipientNode.get() == providerNode)
                    .map(Map.Entry::getValue)
                    .collect(ImmutableCollectors.toList());

            return Optional.of(new PushDownBooleanExpressionProposalImpl(providerNode, directRecipientNodes,
                    indirectRecipientNodes, expressionsToKeep));
        }
    }
114261
def build(self, builder):
        """"""

        params = dict(ItemOID=self.oid, Mandatory=bool_to_yes_no(self.mandatory))

        if self.order_number is not None:
            params["OrderNumber"] = str(self.order_number)

        if self.key_sequence is not None:
            params["KeySequence"] = str(self.key_sequence)

        if self.imputation_method_oid is not None:
            params["ImputationMethodOID"] = self.imputation_method_oid

        if self.role is not None:
            params["Role"] = self.role

        if self.role_codelist_oid is not None:
            params["RoleCodeListOID"] = self.role_codelist_oid

        builder.start("ItemRef", params)

        for attribute in self.attributes:
            attribute.build(builder)
        builder.end("ItemRef")
614911
public void build(final PackageBuildContext context,
                      final ReturnValueConstraintEvaluator constraintNode,
                      final ReturnValueDescr descr,
                      final ContextResolver contextResolver) {

        final String className = getClassName(context);
        
        AnalysisResult analysis = getAnalysis(context, descr);

        if ( analysis == null ) {
            // not possible to get the analysis results
            return;
        }

        buildReturnValueEvaluator(context, 
                                  constraintNode, 
                                  descr, 
                                  contextResolver, 
                                  className, 
                                  analysis);
    }
1360581
def build(self, builder):
        """"""

        params = dict(
            OID=self.oid,
            Name=self.name,
            Repeating=bool_to_yes_no(self.repeating),
            IsReferenceData=bool_to_yes_no(self.is_reference_data),
        )

        if self.sas_dataset_name is not None:
            params["SASDatasetName"] = self.sas_dataset_name

        if self.domain is not None:
            params["Domain"] = self.domain

        if self.origin is not None:
            params["Origin"] = self.origin

        if self.role is not None:
            params["Role"] = self.role

        if self.purpose is not None:
            params["Purpose"] = self.purpose

        if self.comment is not None:
            params["Comment"] = self.comment

        builder.start("ItemGroupDef", params)

        for itemref in self.item_refs:
            itemref.build(builder)

        # Extensions always listed AFTER core elements
        for labelref in self.label_refs:
            labelref.build(builder)

        for alias in self.aliases:
            alias.build(builder)

        builder.end("ItemGroupDef")
1134605
def build(self, builder):
        """"""
        params = dict(OID=self.oid, Language=self.language)
        builder.start("mdsol:CustomFunctionDef", params)
        builder.data(self.code)
        builder.end("mdsol:CustomFunctionDef")
820254
def build(self, builder):
        """"""
        params = dict(StudyOID=self.study_oid,
                      MetaDataVersionOID=self.metadata_version_oid,
                      EffectiveDate=dt_to_iso8601(self.effective_date))
        builder.start("MetaDataVersionRef", params)
        builder.end("MetaDataVersionRef")
15775
public HashRangeExpression build(Integer hashColumnIndex) {
        Map<Integer, Integer> ranges = m_builder.build();
        HashRangeExpression predicate = new HashRangeExpression();
        predicate.setRanges(ranges);
        predicate.setHashColumnIndex(hashColumnIndex);
        return predicate;
    }
1209343
private Optional<PushUpBooleanExpressionProposal> adjustProposal(PushUpBooleanExpressionProposal proposal,
                                                            IntermediateQuery query) {

        QueryNode currentNode = proposal.getUpMostPropagatingNode();
        Optional<QueryNode> optChild;
        // Will be removed from the list of inbetween projectors
        ImmutableSet.Builder<ExplicitVariableProjectionNode> removedProjectors = ImmutableSet.builder();

        while ((optChild = query.getFirstChild(currentNode)).isPresent()) {
            if (currentNode instanceof ConstructionNode || currentNode instanceof  QueryModifierNode) {
                if(currentNode instanceof ConstructionNode) {
                    removedProjectors.add((ConstructionNode) currentNode);
                }
                currentNode = optChild.get();
                continue;
            }
            // Note that the iteration is stopped (among other) by any binary operator
            break;
        }
        // If we went back to the provider node
        if(proposal.getProvider2NonPropagatedExpressionMap().keySet().contains(currentNode)){
            return Optional.empty();
        }
        // adjust the upmost propagating node
        QueryNode upMostPropagatingNode = currentNode;
        // if it it a filter or join, use it as a recipient for the expression
        Optional<JoinOrFilterNode> recipient = currentNode instanceof CommutativeJoinOrFilterNode ?
                Optional.of((JoinOrFilterNode) currentNode) :
                Optional.empty();
        // update inbetween projectors
        ImmutableSet<ExplicitVariableProjectionNode> inbetweenProjectors = computeDifference(
                proposal.getInbetweenProjectors(),
                removedProjectors.build()
        );

        return Optional.of(
                new PushUpBooleanExpressionProposalImpl(
                    proposal.getPropagatedExpression(),
                    proposal.getProvider2NonPropagatedExpressionMap(),
                    upMostPropagatingNode,
                    recipient,
                    inbetweenProjectors
                ));
    }
156164
public EventsStream buildForEntitlement(final Collection<BlockingState> blockingStatesForAccount,
                                            final ImmutableAccountData account,
                                            final SubscriptionBaseBundle bundle,
                                            final SubscriptionBase baseSubscription,
                                            final Collection<SubscriptionBase> allSubscriptionsForBundle,
                                            final int accountBCD,
                                            final Catalog catalog,
                                            final InternalTenantContext internalTenantContext) throws EntitlementApiException {
        final Map<UUID, Integer> bcdCache = new HashMap<UUID, Integer>();
        return buildForEntitlement(blockingStatesForAccount, account, bundle, baseSubscription, baseSubscription, allSubscriptionsForBundle, accountBCD, bcdCache, catalog, internalTenantContext);
    }
1254413
private SyntaxNode buildByTokenHolder(TokenHolder tokenHolder) throws XpathSyntaxErrorException {
        Preconditions.checkArgument(!tokenHolder.type.equals(Token.OPERATOR));
        // return TokenNodeFactory.hintAndGen(tokenHolder);
        return TokenAnalysisRegistry.findHandler(tokenHolder.getType()).parseToken(tokenHolder.expression);
    }
444636
String buildUpdateExpression(SubstitutionContext context) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, List<UpdateAction>> e: updates.entrySet()) {
            boolean firstOfUpdateType = true;
            for (UpdateAction expr: e.getValue()) {
                if (firstOfUpdateType) {
                    firstOfUpdateType = false;
                    final String operator = e.getKey();
                    if (sb.length() > 0)
                        sb.append(" ");
                    sb.append(operator).append(" ");
                } else {
                    sb.append(", ");
                }
                sb.append(expr.asSubstituted(context));
            }
        }
        return sb.toString();
    }
1296489
private void _buildProjection(
                    final Projection p,
                    final StringBuilder stmt
                    )
    {
        if (p instanceof Aggregation) {
            Aggregation  aggr = (Aggregation)p;
            stmt.append( aggr.getFunction().name() );
            stmt.append( "(" );
            String  expr = aggr.getExpression();
            if (Aggregation.WHOLE_OBJECT_EXPRESSION.equals( expr )) {
                stmt.append( expr );
            } else {
                _buildProperty( expr, stmt );
                //throws SearchException
            }
            stmt.append( ")" );
        } else if (p instanceof PropertyProjection) {
            PropertyProjection  pp = (PropertyProjection)p;
            _buildProperty( pp.getProperty(), stmt );
            //throws SearchException
        } else {
            throw new IllegalArgumentException( "unsupported projection: " + p );
        }
    }
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);
      }
    });
  }
1109057
public IExpressionBuilder addExpression() {
		final IExpressionBuilder builder = this.expressionProvider.get();
		builder.eInit(getXBlockExpression(), new Procedures.Procedure1<XExpression>() {
					private int index = -1;
					public void apply(XExpression it) {
						if (this.index >= 0) {
							getXBlockExpression().getExpressions().set(index, it);
						} else {
							getXBlockExpression().getExpressions().add(it);
							this.index = getXBlockExpression().getExpressions().size() - 1;
						}
					}
				}, getTypeResolutionContext());
		return builder;
	}
2259
def create_and_push_expression(token, expressions):
    
    if token == 'and':
        right_expr = expressions.pop()
        expressions.append(And(expressions.pop(), right_expr))
    elif token == 'or':
        right_expr = expressions.pop()
        expressions.append(Or(expressions.pop(), right_expr))
    elif token == 'not':
        expressions.append(Not(expressions.pop()))
    else:
        expressions.append(Literal(token))
119479
public static BooleanExpression asBoolean(Expression<Boolean> expr) {
        Expression<Boolean> underlyingMixin = ExpressionUtils.extract(expr);
        if (underlyingMixin instanceof PathImpl) {
            return new BooleanPath((PathImpl<Boolean>) underlyingMixin);
        } else if (underlyingMixin instanceof PredicateOperation) {
            return new BooleanOperation((PredicateOperation) underlyingMixin);
        } else if (underlyingMixin instanceof PredicateTemplate) {
            return new BooleanTemplate((PredicateTemplate) underlyingMixin);
        } else {
            return new BooleanExpression(underlyingMixin) {

                private static final long serialVersionUID = -8712299418891960222L;

                @Override
                public <R, C> R accept(Visitor<R, C> v, C context) {
                    return this.mixin.accept(v, context);
                }

            };
        }
    }
174918
private static void pushOp(String operation, Stack<MetricExpression> expressions, Stack<String> operations) {
        if (operation.equals("(")) {
            operations.push(operation);
            return;
        }

        if (operation.equals(")")) {
            while (!operations.isEmpty()) {
                String op = operations.pop();
                if (op.equals("("))
                    return;
                doOperation(op, expressions, operations);
            }
        }


        if (operation.equals("*") || operation.equals("/")) {
            if (operations.isEmpty())
                operations.push(operation);
            else {
                String op1 = operations.peek();
                if (!op1.equals("(")) {
                    if (op1.equals("+") || op1.equals("-")) {
                        operations.push(operation);
                    } else {
                        doOperation(operations.pop(), expressions, operations);
                        operations.push(operation);
                    }
                } else {
                    operations.push(operation);
                }

            }
        }
        if (operation.equals("+") || operation.equals("-")) {
            if (operations.isEmpty())
                operations.push(operation);
            else {
                String op1 = operations.peek();
                if (!op1.equals("(")) {
                    doOperation(operations.pop(), expressions, operations);
                }
                operations.push(operation);
            }
        }
    }