Given a list of instances, and the conditions active for
        this switch, returns a boolean reprsenting if any
        conditional is met, including a non-instance default.
167815
def has_active_condition(self, conditions, instances):
        
        return_value = None
        for instance in itertools.chain(instances, [None]):
            if not self.can_execute(instance):
                continue
            result = self.is_active(instance, conditions)
            if result is False:
                return False
            elif result is True:
                return_value = True
        return return_value
653794
def instances(self, skip_exist_test=False):
        
        self.reset_result_type()
        self._instances = True
        self._instances_skip_exist_test = skip_exist_test
        return self
934262
public static OptionBuilder hasOptionalArgs()
    {
        OptionBuilder.numberOfArgs = Option.UNLIMITED_VALUES;
        OptionBuilder.optionalArg = true;

        return INSTANCE;
    }
310475
def is_instance_factory(_type):
    
    if isinstance(_type, (tuple, list)):
        _type = tuple(_type)
        type_repr = "|".join(map(str, _type))
    else:
        type_repr = "'%s'" % _type

    def inner(x):
        if not isinstance(x, _type):
            raise ValueError("Value must be an instance of %s" % type_repr)

    return inner
1358636
def boolean_or_list(config_name, args, configs, alternative_names=[]):
    """"""

    # when argument flag present, set to wildcard regex
    for key in alternative_names + [config_name]:
        if hasattr(args, key) and getattr(args, key):
            setattr(args, config_name, ['.*'])
            return

    setattr(args, config_name, [])

    option = None
    alternative_names.insert(0, config_name)
    for key in alternative_names:
        if configs.has_option('settings', key):
            option = configs.get('settings', key)
            break

    if option is not None:
        if option.strip().lower() == 'true':
            setattr(args, config_name, ['.*'])
        elif option.strip().lower() != 'false':
            for pattern in option.split("\n"):
                if pattern.strip() != '':
                    getattr(args, config_name).append(pattern)
1349225
public boolean isMatched(String value, Boolean defaultValue)
    {
        if (value == null)
            return false;

        if (_match != null) {
            for (int i = 0; i < _match.length; i++) {
                if (value.equals(_match[i]))
                    return true;
            }
        }
        else {
            // a provided default value will override the group
            if (defaultValue != null)
                return defaultValue.booleanValue();

            // if we have a singleton definition then use that
            if (_defaultSingleton)
                return _defaultSingleValue;

            // check to see if we have a default arraylist with the value in it
            if (_defaultSelections != null)
                return _defaultSelections.contains(value);
        }

        return false;
    }
1311612
private void matchInstances(@NonNull ArrayMap<View, TransitionValues> unmatchedStart,
                                @NonNull ArrayMap<View, TransitionValues> unmatchedEnd) {
        for (int i = unmatchedStart.size() - 1; i >= 0; i--) {
            View view = unmatchedStart.keyAt(i);
            if (view != null && isValidTarget(view)) {
                TransitionValues end = unmatchedEnd.remove(view);
                if (end != null && isValidTarget(end.view)) {
                    TransitionValues start = unmatchedStart.removeAt(i);
                    mStartValuesList.add(start);
                    mEndValuesList.add(end);
                }
            }
        }
    }
399302
function instance(defaults, options) {
  if (!singletonQS) {
    singletonQS = queryState(defaults, options);
  } else if (defaults) {
    singletonQS.setIfEmpty(defaults);
  }

  return singletonQS;
}
1181307
def first_true(iterable, default=False, pred=None):
    
    # first_true([a,b,c], x) --> a or b or c or x
    # first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
    return next(filter(pred, iterable), default)
1048106
def is_true(key, default=False):
    
    value = get(key, default)
    if isinstance(value, list):
        value = value[0]
    if isinstance(value, bool):
        return value
    if value is default:
        return default
    return value.lower() in TRUE_VALUES
22114
def terminate(instance_id=None, name=None, region=None,
              key=None, keyid=None, profile=None, filters=None):
    '''
    
    '''
    instances = find_instances(instance_id=instance_id, name=name,
                               region=region, key=key, keyid=keyid,
                               profile=profile, return_objs=True,
                               filters=filters)
    if instances in (False, None, []):
        return instances

    if len(instances) == 1:
        instances[0].terminate()
        return True
    else:
        log.warning('Refusing to terminate multiple instances at once')
        return False
336480
public void isEqualToDefaultInstance() {
    if (actual() == null) {
      failWithoutActual(
          simpleFact(
              lenientFormat(
                  "Not true that %s is a default proto instance. It is null.", actualAsString())));
    } else if (!actual().equals(actual().getDefaultInstanceForType())) {
      failWithoutActual(
          simpleFact(
              lenientFormat(
                  "Not true that %s is a default proto instance. It has set values.",
                  actualAsString())));
    }
  }
571507
def switch_on(self, *args):
        
        if self.on_check(*args):
            return self._switch.switch(True)
        else:
            return False
1078664
private boolean evaluateConditional(Siren4JCondition condition, EntityContext context) {
        boolean result = true;
        if (condition != null && !("null".equals(condition.name()))) {
            result = false;
            Object val = null;
            ConditionFactory factory = ConditionFactory.getInstance();
            Condition cond = factory.getCondition(condition.logic());
            Object obj = condition.name().startsWith("parent.")
                    ? context.getParentObject()
                    : context.getCurrentObject();
            String name = condition.name().startsWith("parent.")
                    ? condition.name().substring(7)
                    : condition.name();
            if (obj == null) {
                throw new Siren4JRuntimeException(
                        "No object found. Conditional probably references a parent but does not have a parent: " + condition
                                .name());
            }
            if (condition.type().equals(Type.METHOD)) {
                try {
                    Method method = ReflectionUtils.findMethod(obj.getClass(), name,
                            null);
                    if (method != null) {
                        method.setAccessible(true);
                        val = method.invoke(obj, new Object[]{});
                        result = cond.evaluate(val);
                    } else {
                        throw new Siren4JException(
                                "Method referenced in condition does not exist: " + condition.name());
                    }
                } catch (Exception e) {
                    throw new Siren4JRuntimeException(e);
                }
            } else {
                try {
                    Field field = ReflectionUtils.findField(obj.getClass(), name);
                    if (field != null) {
                        field.setAccessible(true);
                        val = field.get(obj);
                        result = cond.evaluate(val);
                    } else {
                        throw new Siren4JException("Field referenced in condition does not exist: " + condition.name());
                    }
                } catch (Exception e) {
                    throw new Siren4JRuntimeException(e);
                }
            }
        }
        return result;
    }
457033
function Base(condition, negate) {
  // Set up flags
  var self = this;
  this.flags = {
    not: false,
    deep: false,
    chain: false,
    noCase: false,
    unordered: false
  };

  // Add this condition to the current list
  this.current = [{
    val: condition,
    negate: negate,
    actual: condition
  }];

  // Set up helpers
  _.each(['And', 'But', 'Or', 'Xor'], function(joiner) {
    self.__defineGetter__(joiner, function() {
      return utils.delegate(self.test(), joiner.toLowerCase());
    });
  });
  _.each(['does', 'should', 'has', 'have', 'is', 'to', 'be', 'been'], function(getter) {
    self.__defineGetter__(getter, function() {
      return self;
    });
  });
  _.each(['deep', 'deeply'], function(getter) {
    self.__defineGetter__(getter, function() {
      self.flags.deep = true;
      return self;
    });
  });
  self.__defineGetter__('roughly', function() {
    self.flags.unordered = true;
    return self;
  });
  self.__defineGetter__('not', function() {
    self.flags.not = true;
    return self;
  });
  self.__defineGetter__('Not', function() {
    self.flags.groupNot = true;
    return self;
  });
  _.each(['noCase', 'caseless'], function(getter) {
    self.__defineGetter__(getter, function() {
      self.flags.noCase = true;
      return self;
    });
  });
}
816178
boolean valuesAreTheSameAsDefault()
    {
        if (getDefaultValues() == null || getDefaultValues().size() == 0)
            return false;
        if (getValues() == null || getValues().size() == 0)
            return false;
        if (getDefaultValues().size() != getValues().size())
            return false;
        for (int v = 0; v < getDefaultValues().size(); v++)
            if (!getDefaultValues().get(v).equals(getValues().get(v)))
                return false;
        return true;
    }
473771
private boolean allReady() {
    if (currentContext == null) return false;
    List<InstanceContext> instances = new ArrayList<>();
    boolean match = true;
    outer: for (ComponentContext<?> component : currentContext.components()) {
      instances.addAll(component.instances());
      for (InstanceContext instance : component.instances()) {
        if (!ready.contains(instance.address())) {
          match = false;
          break outer;
        }
      }
    }
    return match;
  }