Returns null if all of the given bindings cannot be included in compatible Tuple.
Otherwise, returns a new compatible Tuple containing all of the given bindings.
427568
public static Tuple of( Collection<VarBindingDef> tupleBindings)
    {
    Tuple tuple = new Tuple();
    
    boolean bindingsCompatible;
    Iterator<VarBindingDef> bindings;
    VarBindingDef nextBinding;
    for( bindings = tupleBindings.iterator(),
           bindingsCompatible = true; 

         bindings.hasNext()
           && (bindingsCompatible = isBindingCompatible( tuple, (nextBinding = bindings.next())));

         tuple.add( nextBinding));
    
    return
      bindingsCompatible && tuple.isCompatible()
      ? tuple
      : null;
    }
384372
<T> InternalProviderImpl<T> toProvider(Binding<T> binding) {
    if (binding == null) {
      throw new IllegalStateException("null binding are not allowed. Should not happen unless getBindingSet is overridden.");
    }
    ConfigurationHolder.configuration.checkIllegalBinding(binding, this);

    switch (binding.getMode()) {
      case SIMPLE:
        return createInternalProvider(this,
            binding.getKey(),
            false,
            binding.isCreatingInstancesInScope(),
            binding.isCreatingSingletonInScope(),
            false);
      case CLASS:
        return createInternalProvider(this,
            binding.getImplementationClass(),
            false,
            binding.isCreatingInstancesInScope(),
            binding.isCreatingSingletonInScope(),
            false);
      case INSTANCE:
        return new InternalProviderImpl<>(binding.getInstance());
      case PROVIDER_INSTANCE:
        // to ensure providers do not have to deal with concurrency, we wrap them in a thread safe provider
        // We do not need to pass the scope here because the provider won't use any scope to create the instance
        return new InternalProviderImpl<>(binding.getProviderInstance(), binding.isProvidingSingletonInScope());
      case PROVIDER_CLASS:
        return createInternalProvider(this,
            binding.getProviderClass(),
            true,
            binding.isCreatingInstancesInScope(),
            binding.isCreatingSingletonInScope(),
            binding.isProvidingSingletonInScope());
      //JACOCO:OFF
      default:
        throw new IllegalStateException(format("mode is not handled: %s. This should not happen.", binding.getMode()));
        //JACOCO:ON
    }
  }
1337699
private Tuple toTuple( List<VarDef> combinedVars, TupleRef tupleRef)
    {
    if( tupleRef.size() != getTupleSize())
      {
      throw new IllegalStateException( String.valueOf( tupleRef) + " does not match combiner tuple size=" + getTupleSize());
      }

    Tuple tuple = new Tuple();
    for( Iterator<VarBinding> bindings = tupleRef.getVarBindings(); bindings.hasNext(); )
      {
      VarBinding binding = bindings.next();
      VarDef var = findVarPath( combinedVars, binding.getVar());
      if( var == null)
        {
        throw new IllegalStateException( "Var=" + binding.getVar() + " is not included in this combination");
        }

      VarValueDef value = var.getValue( binding.getValue());
      if( value == null)
        {
        throw new IllegalStateException( "Value=" + binding.getValue() + " is not defined for var=" + binding.getVar());
        }

      if( !value.isValid())
        {
        throw new IllegalStateException( "Value=" + binding.getValue() + " is a failure value for var=" + binding.getVar());
        }

      tuple.add( new VarBindingDef( var, value));
      }

    return tuple;
    }
419972
public boolean compatible( PropertySet properties)
    {
    boolean isCompatible;
    Iterator<IDisjunct> disjuncts;
    
    for( disjuncts = getDisjuncts(),
           isCompatible = true;
           

         isCompatible
           && disjuncts.hasNext();

         isCompatible = disjuncts.next().compatible( properties));
    
    return isCompatible;
    }
1322448
public void add(Binding binding) {
	if (values == null) values = new LinkedList();
	values.add(binding);
    }
849353
public static <T, U extends Unifiable<? super T>> Choice<Unifier> unifyList(
      Unifier unifier, @Nullable List<U> toUnify, @Nullable final List<? extends T> targets) {
    return unifyList(unifier, toUnify, targets, /* allowVarargs= */ false);
  }
121571
@SuppressWarnings("unchecked")
	// Suppressing warnings since Commons Collections is gangster...
	@Override
	public void addBindings(Bindings bindings) {
		try {
			SlingHttpServletRequest request = (SlingHttpServletRequest) bindings
					.get("request");
			String resourceType = request.getResource().getResourceType();
			Collection<ComponentBindingsProvider> cis = cif
					.getComponentBindingsProviders(resourceType);
			if (cis != null && cis.size() > 0) {
				CQVariables variables = variablesService.getVariables(bindings);
				for (ComponentBindingsProvider ci : cis) {
					try {
						log.debug("Invoking component bindings provider {}", ci);
						ci.addBindings(variables, bindings);
					} catch (Exception e) {
						log.error(
								"Exception invoking component bindings provider "
										+ ci, e);
						recentExceptions
								.add(new ComponentBindingsExceptionData(ci, e));
					}
				}
			}
		} catch (Exception e) {
			log.error("Exception invoking component binding providers", e);
		}
	}
500587
public static <T, U extends Unifiable<? super T>> Choice<Unifier> unifyList(
      Unifier unifier,
      @Nullable List<U> toUnify,
      @Nullable final List<? extends T> targets,
      boolean allowVarargs) {
    if (toUnify == null && targets == null) {
      return Choice.of(unifier);
    } else if (toUnify == null
        || targets == null
        || (allowVarargs
            ? toUnify.size() - 1 > targets.size()
            : toUnify.size() != targets.size())) {
      return Choice.none();
    }
    Choice<Unifier> choice = Choice.of(unifier);
    int index;
    for (index = 0; index < toUnify.size(); index++) {
      U toUnifyNext = toUnify.get(index);
      if (allowVarargs && toUnifyNext instanceof URepeated) {
        final URepeated repeated = (URepeated) toUnifyNext;
        final int startIndex = index;
        return choice
            .condition(index + 1 == toUnify.size())
            .thenOption(
                new Function<Unifier, Optional<Unifier>>() {
                  @Override
                  public Optional<Unifier> apply(Unifier unifier) {
                    List<JCExpression> expressions = new ArrayList<>();
                    for (int j = startIndex; j < targets.size(); j++) {
                      Optional<Unifier> forked =
                          repeated.unify((JCTree) targets.get(j), unifier.fork()).first();
                      if (!forked.isPresent()) {
                        return Optional.absent();
                      }
                      JCExpression boundExpr = repeated.getUnderlyingBinding(forked.get());
                      if (boundExpr == null) {
                        return Optional.absent();
                      }
                      expressions.add(boundExpr);
                    }
                    unifier.putBinding(repeated.key(), expressions);
                    return Optional.of(unifier);
                  }
                });
      }
      if (index >= targets.size()) {
        return Choice.none();
      }
      choice = choice.thenChoose(unifications(toUnifyNext, targets.get(index)));
    }
    if (index < targets.size()) {
      return Choice.none();
    }
    return choice;
  }
714629
public static FilterParams fromTuples(Object... tuples) {
		StringValueMap map = StringValueMap.fromTuplesArray(tuples);
		return new FilterParams(map);
	}
868104
private Iterator<Tuple> getSatisfyingTuples( final TestCaseDef testCase, VarTupleSet varTupleSet)
    {
    final Comparator<VarBindingDef> byUsage = byUsage( varTupleSet);

    return
      IteratorUtils.transformedIterator(
        // Iterate over all combinations of bindings...
        new CartesianProduct<VarBindingDef>(

          // ...combining members from all sets of bindings...
          new ArrayList<Set<VarBindingDef>>(
            CollectionUtils.collect(
              // ...where each set of bindings is derived from a disjunct of unsatisfied test case conditions....
              testCase.getRequired().getDisjuncts(),

              // ...and contains the set of compatible bindings that could satisfy this disjunct...
              disjunct ->
                {
                Set<String> unsatisfied =
                  CollectionUtils.collect(
                    disjunct.getAssertions(),
                    assertion -> assertion.getProperty(),
                    new HashSet<String>());

                Iterator<VarBindingDef> satisfyingBindings =
                  IteratorUtils.filteredIterator(
                    getPropertyProviders( unsatisfied).iterator(),
                    binding -> testCase.isCompatible( binding));

                // ...arranging satisfying bindings in order of decreasing preference...
                return
                  CollectionUtils.collect(
                    satisfyingBindings,
                    nopTransformer(),
                    new TreeSet<VarBindingDef>( byUsage));
                },

              // ...arranging sets in a well-defined order for repeatable combinations...
              new TreeSet<Set<VarBindingDef>>( varBindingSetSorter_))),
          
          // ...ignoring any infeasible combinations...
          bindings -> Tuple.of( bindings) != null),
        
         // ... forming each combination of satisfying bindings into a tuple...
        Tuple::of);
    }
825863
private <T> void bindIfNotNull(final Class<T> interfaceType, @Nullable final Class<? extends T> implementationType, final Scope scope) {
        if (implementationType != null) {
            bind(interfaceType).to(implementationType).in(scope);
        }
    }
1278594
public boolean isAllBindingTables(final Collection<String> logicTableNames) {
        if (logicTableNames.isEmpty()) {
            return false;
        }
        Optional<BindingTableRule> bindingTableRule = findBindingTableRule(logicTableNames);
        if (!bindingTableRule.isPresent()) {
            return false;
        }
        Collection<String> result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
        result.addAll(bindingTableRule.get().getAllLogicTables());
        return !result.isEmpty() && result.containsAll(logicTableNames);
    }
140368
private ImmutableList<UTypeVar> freeTypeVars(Unifier unifier) {
    ImmutableList.Builder<UTypeVar> builder = ImmutableList.builder();
    for (UTypeVar var : typeVariables(unifier.getContext())) {
      if (unifier.getBinding(var.key()) == null) {
        builder.add(var);
      }
    }
    return builder.build();
  }
498856
def compatibility_or_constraints(self, target):
    
    if self.get_options().is_flagged('interpreter_constraints'):
      return tuple(self.interpreter_constraints)
    return tuple(target.compatibility or self.interpreter_constraints)
442243
public static <T extends SyntacticItem> java.util.function.Function<Identifier, SyntacticItem> bindingFunction(
			Tuple<Template.Variable> variables, Tuple<T> arguments) {
		//
		return (Identifier var) -> {
			for (int i = 0; i != variables.size(); ++i) {
				if (var.equals(variables.get(i).getName())) {
					return arguments.get(i);
				}
			}
			return null;
		};
	}
743991
private static Tuple2<List<String>, List<String>> normalizeSupportedProperties(TableFactory factory) {
		List<String> supportedProperties = factory.supportedProperties();
		if (supportedProperties == null) {
			throw new TableException(
				String.format("Supported properties of factory '%s' must not be null.",
					factory.getClass().getName()));
		}
		List<String> supportedKeys = supportedProperties.stream()
			.map(p -> p.toLowerCase())
			.collect(Collectors.toList());

		// extract wildcard prefixes
		List<String> wildcards = extractWildcardPrefixes(supportedKeys);
		return Tuple2.of(supportedKeys, wildcards);
	}
1354475
@Override
    public List<AbstractExpression> bindingToIndexedExpression(AbstractExpression expr) {
        if (equals(expr)) {
            return s_reusableImmutableEmptyBinding;
        }
        return null;
    }