// match takes the topic string of the published message and does a basic compare to the
// string of the current Route, if they match it returns true
329330
func (r *route) match(topic string) bool {
	return string(r.topicBytes) == topic || routeIncludesTopic(r.topicBytes, []byte(topic))
}
1330111
func (r *Route) MatchMessage(message *Message) bool {
	if r.matchAll() {
		return true
	}
	if len(r.FilterSources) > 0 && !contains(r.FilterSources, message.Source) {
		return false
	}
	return true
}
580186
func Match(ds *apps.DaemonSet, history *apps.ControllerRevision) (bool, error) {
	patch, err := getPatch(ds)
	if err != nil {
		return false, err
	}
	return bytes.Equal(patch, history.Data.Raw), nil
}
403963
func (ls Labels) Match(metric *dto.Metric) bool {
	lp := &labelPairs{metric.Label}
	return ls[lp.String()] || ls[""] // match empty string so no labels can be matched.
}
1006907
func (c *Constraint) Match(whats ...string) bool {
	var match bool

	// full string match
	for _, what := range whats {
		// case insensitive compare
		if strings.EqualFold(c.exp, what) {
			match = true
			break
		}
	}

	switch c.operator {
	case eq:
		return match
	case noteq:
		return !match
	}

	return false
}
291024
func (m Any) Match(adaptor Adaptor) bool {
	for _, m := range m {
		if m.Match(adaptor) {
			return true
		}
	}

	return false
}
454146
func (v *Validator) Match(field string, regex *regexp.Regexp) *ValidationResult {
	if !regex.MatchString(v.data.Get(field)) {
		return v.addMatchError(field)
	} else {
		return validationOk
	}
}
588178
func (p Path) Matches(other string) bool {
	if CaseSensitivePath {
		return strings.HasPrefix(string(p), other)
	}
	return strings.HasPrefix(strings.ToLower(string(p)), strings.ToLower(other))
}
1328653
func (r *Route) Match(addr Address) bool {
	if len(addr) != len(r.Destination) {
		return false
	}

	// Using header.Ipv4Broadcast would introduce an import cycle, so
	// we'll use a literal instead.
	if addr == "\xff\xff\xff\xff" {
		return true
	}

	for i := 0; i < len(r.Destination); i++ {
		if (addr[i] & r.Mask[i]) != r.Destination[i] {
			return false
		}
	}

	return true
}
927199
func Match(e *message.Entity, c *imap.SearchCriteria) (bool, error) {
	// TODO: support encoded header fields for Bcc, Cc, From, To
	// TODO: add header size for Larger and Smaller

	h := mail.Header{Header: e.Header}

	if !c.SentBefore.IsZero() || !c.SentSince.IsZero() {
		t, err := h.Date()
		if err != nil {
			return false, err
		}
		t = t.Round(24 * time.Hour)

		if !c.SentBefore.IsZero() && !t.Before(c.SentBefore) {
			return false, nil
		}
		if !c.SentSince.IsZero() && !t.After(c.SentSince) {
			return false, nil
		}
	}

	for key, wantValues := range c.Header {
		values, ok := e.Header[key]
		for _, wantValue := range wantValues {
			if wantValue == "" && !ok {
				return false, nil
			}
			if wantValue != "" {
				ok := false
				for _, v := range values {
					if matchString(v, wantValue) {
						ok = true
						break
					}
				}
				if !ok {
					return false, nil
				}
			}
		}
	}
	for _, body := range c.Body {
		if ok, err := matchBody(e, body); err != nil || !ok {
			return false, err
		}
	}
	for _, text := range c.Text {
		// TODO: also match header fields
		if ok, err := matchBody(e, text); err != nil || !ok {
			return false, err
		}
	}

	if c.Larger > 0 || c.Smaller > 0 {
		n, err := bodyLen(e)
		if err != nil {
			return false, err
		}

		if c.Larger > 0 && uint32(n) < c.Larger {
			return false, nil
		}
		if c.Smaller > 0 && uint32(n) > c.Smaller {
			return false, nil
		}
	}

	for _, not := range c.Not {
		ok, err := Match(e, not)
		if err != nil || ok {
			return false, err
		}
	}
	for _, or := range c.Or {
		ok1, err := Match(e, or[0])
		if err != nil {
			return ok1, err
		}

		ok2, err := Match(e, or[1])
		if err != nil || (!ok1 && !ok2) {
			return false, err
		}
	}

	return true, nil
}
621899
func (r *router) Match(url, method string) (*Route, Params) {
	cn, ok := r.trees[method]
	if !ok {
		return nil, nil
	}
	var params = make(Params, 0, strings.Count(url, "/"))
	for _, n := range cn.edges {
		e, newParams := r.matchNode(n, url, params)
		if e != nil {
			return e.handle, newParams
		}
	}
	return nil, nil
}
92644
func (s *Sublist) Match(subject string) []interface{} {
	s.RLock()
	rc, ok := s.cache[subject]
	s.RUnlock()
	if ok {
		return rc
	}

	tsa := [32]string{}
	tokens := tsa[:0]
	start := 0
	for i := 0; i < len(subject); i++ {
		if subject[i] == btsep {
			tokens = append(tokens, subject[start:i])
			start = i + 1
		}
	}
	tokens = append(tokens, subject[start:])
	result := make([]interface{}, 0, 4)

	s.Lock()
	matchLevel(s.root, tokens, &result)

	// Add to our cache
	s.cache[subject] = result
	// Bound the number of entries to sublistMaxCache
	if len(s.cache) > slCacheMax {
		for k := range s.cache {
			delete(s.cache, k)
			break
		}
	}
	s.Unlock()

	return result
}
712225
func (m MatcherFunc) Match(r *http.Request, match *RouteMatch) bool {
	return m(r, match)
}
726807
func (r *Matcher) Matches() bool {
	return r.scope() &&
		r.operation() &&
		r.group() &&
		r.version() &&
		r.resource()
}
540637
func (r *Rule) Matches(msg map[string]interface{}) bool {
	for field, values := range r.Matchers {
		if !fieldMatches(field, values, msg) {
			return false
		}
	}
	return true
}
363845
func (mr *MediaRange) Match(contentType string, params map[string][]string) bool {
	return mr.match(contentType, params).Valid
}
733994
func match(a, b string) bool {
	if wildcard(a) {
		return true
	}
	if wildcard(b) {
		return true
	}
	return strings.EqualFold(a, b)
}