1/*  Copyright (c) 2000-2006 hamcrest.org
2 */
3package org.hamcrest.core;
4
5import org.hamcrest.Description;
6import org.hamcrest.Matcher;
7import org.hamcrest.Factory;
8import org.hamcrest.BaseMatcher;
9
10
11/**
12 * A matcher that always returns <code>true</code>.
13 */
14public class IsAnything<T> extends BaseMatcher<T> {
15
16    private final String description;
17
18    public IsAnything() {
19        this("ANYTHING");
20    }
21
22    public IsAnything(String description) {
23        this.description = description;
24    }
25
26    public boolean matches(Object o) {
27        return true;
28    }
29
30    public void describeTo(Description description) {
31        description.appendText(this.description);
32    }
33
34    /**
35     * This matcher always evaluates to true.
36     */
37    @Factory
38    public static <T> Matcher<T> anything() {
39        return new IsAnything<T>();
40    }
41
42    /**
43     * This matcher always evaluates to true.
44     *
45     * @param description A meaningful string used when describing itself.
46     */
47    @Factory
48    public static <T> Matcher<T> anything(String description) {
49        return new IsAnything<T>(description);
50    }
51
52    /**
53     * This matcher always evaluates to true. With type inference.
54     */
55    @Factory
56    public static <T> Matcher<T> any(@SuppressWarnings("unused")Class<T> type) {
57        return new IsAnything<T>();
58    }
59}
60