Returns a matcher that matches context elements whose {@link ContextElement#attributes()}
match against the supplied matcher.

@param matcher a {@code Map} (attributes) matcher
@return a {@code ContextElement} matcher
508799
public static Matcher<ContextElement> attributes(final Matcher<Map<String, Object>> matcher) {
    return new Matcher<ContextElement>() {

      @Override
      protected boolean matchesSafely(ContextElement t) {
        return matcher.matches(t.attributes());
      }

      @Override
      public String toString() {
        return "an attributes " + matcher;
      }
    };
  }
776465
public static <T> ElementMatcher.Junction<T> not(ElementMatcher<? super T> matcher) {
        return new NegatingMatcher<T>(matcher);
    }
27451
public Configuration withMatcher(String matcherName, Matcher<?> matcher) {
        return new Configuration(tolerance, options, ignorePlaceholder, matchers.with(matcherName, matcher), pathsToBeIgnored, differenceListener);
    }
455055
static Matcher inlineMatchAnyPrecedingOr(Matcher matcher) {
    if (matcher instanceof ZeroOrMoreMatcher) {
      ZeroOrMoreMatcher zm = matcher.as();
      if (zm.repeated() instanceof AnyMatcher && zm.next() instanceof OrMatcher) {
        List<Matcher> matchers = zm.next().<OrMatcher>as().matchers();
        List<Matcher> ms = new ArrayList<>();
        for (Matcher m : matchers) {
          ms.add(new ZeroOrMoreMatcher(AnyMatcher.INSTANCE, m));
        }
        return OrMatcher.create(ms);
      }
    }
    return matcher;
  }
711421
public static Matcher not(final Matcher matcher) {
    return new Matcher() {
      @Override public boolean matches(Node node, NodeMetadata metadata) {
        return !matcher.matches(node, metadata);
      }
    };
  }
699294
public static Matcher<Map<String, Object>> hasAttribute(final String key, final Object value) {
    return new Matcher<Map<String, Object>>() {

      @Override
      protected boolean matchesSafely(Map<String, Object> object) {
        return object.containsKey(key) && value.equals(object.get(key));
      }
    };
  }
1072476
public ResultMatcher matches(final Matcher<?> matcher) {
        return new AbstractResultMatcher(path, configuration) {
            public void doMatch(Object actual) {
                isPresent(actual);
                Node node = getNode(actual);
                assertThat("Node \"" + path + "\" does not match.", node.getValue(), (Matcher<? super Object>) matcher);
            }
        };

    }
113973
public static <T extends Tree> Matcher<T> inLoop() {
    return new Matcher<T>() {
      @Override
      public boolean matches(Tree tree, VisitorState state) {
        TreePath path = state.getPath().getParentPath();
        Tree node = path.getLeaf();
        while (path != null) {
          switch (node.getKind()) {
            case METHOD:
            case CLASS:
              return false;
            case WHILE_LOOP:
            case FOR_LOOP:
            case ENHANCED_FOR_LOOP:
            case DO_WHILE_LOOP:
              return true;
            default:
              path = path.getParentPath();
              node = path.getLeaf();
              break;
          }
        }
        return false;
      }
    };
  }
213720
public static <T extends Tree> Matcher<T> hasModifier(final Modifier modifier) {
    return new Matcher<T>() {
      @Override
      public boolean matches(T tree, VisitorState state) {
        Symbol sym = ASTHelpers.getSymbol(tree);
        return sym != null && sym.getModifiers().contains(modifier);
      }
    };
  }
1342959
public static <T> DecomposableMatchBuilder1<T, T> caseThat(org.hamcrest.Matcher<T> matcher) {
    @SuppressWarnings("unchecked")
    List<Matcher<Object>> matchers = Lists.of((Matcher<Object>) HamcrestMatcher.of(matcher));

    return new DecomposableMatchBuilder1<>(matchers, 0, new IdentityFieldExtractor<>());
  }
600387
public static MultiMatcher<MethodTree, VariableTree> methodHasParameters(
      MatchType matchType, Matcher<VariableTree> parameterMatcher) {
    return new MethodHasParameters(matchType, parameterMatcher);
  }
641516
public static Matcher unwrap(Matcher matcher) {
        if (matcher instanceof MemoMismatchesMatcher) {
            MemoMismatchesMatcher memoMismatchesMatcher = (MemoMismatchesMatcher) matcher;
            return unwrap(memoMismatchesMatcher.inner);
        }
        return matcher;
    }
978007
public static <T extends Tree> Matcher<Tree> enclosingNode(final Matcher<T> matcher) {
    return new Matcher<Tree>() {
      @SuppressWarnings("unchecked") // TODO(cushon): this should take a Class<T>
      @Override
      public boolean matches(Tree t, VisitorState state) {
        TreePath path = state.getPath().getParentPath();
        while (path != null) {
          Tree node = path.getLeaf();
          state = state.withPath(path);
          if (matcher.matches((T) node, state)) {
            return true;
          }
          path = path.getParentPath();
        }
        return false;
      }
    };
  }
1235383
public static <T extends ByteCodeElement> ElementMatcher.Junction<T> hasDescriptor(String descriptor) {
        return new DescriptorMatcher<T>(new StringMatcher(descriptor, StringMatcher.Mode.EQUALS_FULLY));
    }
1326041
@Deprecated
    public static <T> CombinableEitherMatcher<T> either(Matcher<? super T> matcher) {
        return CoreMatchers.either(matcher);
    }
257593
public static Matcher newClass() {
    return new Matcher() {
      @Override public boolean matches(Node node, NodeMetadata metadata) {
        return node.isNew();
      }
    };
  }
1333215
public static <T extends Tree, V extends Tree> Matcher<T> contains(
      Class<V> clazz, Matcher<V> treeMatcher) {
    final Matcher<Tree> contains = new Contains(toType(clazz, treeMatcher));
    return contains::matches;
  }