11ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot/* Copyright (c) 2000-2006 hamcrest.org 21ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot */ 31ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabotpackage org.hamcrest.core; 41ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 51ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabotimport org.hamcrest.Description; 61ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabotimport org.hamcrest.Matcher; 71ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabotimport org.hamcrest.Factory; 81ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabotimport org.hamcrest.BaseMatcher; 91ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 101ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 111ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot/** 121ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot * A matcher that always returns <code>true</code>. 131ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot */ 141ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabotpublic class IsAnything<T> extends BaseMatcher<T> { 151ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 161ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot private final String description; 171ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 181ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot public IsAnything() { 191ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot this("ANYTHING"); 201ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot } 211ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 221ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot public IsAnything(String description) { 231ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot this.description = description; 241ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot } 251ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 261ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot public boolean matches(Object o) { 271ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot return true; 281ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot } 291ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 301ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot public void describeTo(Description description) { 311ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot description.appendText(this.description); 321ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot } 331ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 341ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot /** 351ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot * This matcher always evaluates to true. 361ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot */ 371ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot @Factory 381ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot public static <T> Matcher<T> anything() { 391ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot return new IsAnything<T>(); 401ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot } 411ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 421ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot /** 431ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot * This matcher always evaluates to true. 441ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot * 451ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot * @param description A meaningful string used when describing itself. 461ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot */ 471ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot @Factory 481ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot public static <T> Matcher<T> anything(String description) { 491ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot return new IsAnything<T>(description); 501ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot } 511ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot 521ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot /** 531ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot * This matcher always evaluates to true. With type inference. 541ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot */ 551ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot @Factory 561ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot public static <T> Matcher<T> any(@SuppressWarnings("unused")Class<T> type) { 571ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot return new IsAnything<T>(); 581ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot } 591ecfda91236a8970119144e59e0ba6113dc22c0fBrett Chabot} 60