Top Description Constructors Methods
org.hamcrest.core

public Class AnyOf<T>

extends ShortcutCombination<T>
Class Inheritance
Imports
org.hamcrest.Description, .Matcher, java.util.Arrays

Calculates the logical disjunction of multiple matchers. Evaluation is shortcut, so subsequent matchers are not called if an earlier matcher returns true.

Constructor Summary

AccessConstructor and Description
public
AnyOf(Matcher<? super T>... matchers)

public
AnyOf(Iterable<Matcher<? super T>> matchers)

Method Summary

Modifier and TypeMethod and Description
public static <T> AnyOf<T>
anyOf(Iterable<Matcher<? super T>> matchers)

Creates a matcher that matches if the examined object matches ANY of the specified matchers.

public static <T> AnyOf<T>
anyOf(Matcher<? super T>... matchers)

Creates a matcher that matches if the examined object matches ANY of the specified matchers.

public void
describeTo(Description
The description to be built or appended to.
description
)

Implements abstract org.hamcrest.core.ShortcutCombination.describeTo.

Implements org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object.
public boolean
matches(Object
the object against which the matcher is evaluated.
o
)

Implements abstract org.hamcrest.core.ShortcutCombination.matches.

Implements org.hamcrest.Matcher.matches.

Evaluates the matcher for argument item.
Inherited from org.hamcrest.core.ShortcutCombination:
describeTomatches

Constructor Detail

AnyOfback to summary
public AnyOf(Matcher<? super T>... matchers)
Annotations
@SafeVarargs
AnyOfback to summary
public AnyOf(Iterable<Matcher<? super T>> matchers)

Method Detail

anyOfback to summary
public static <T> AnyOf<T> anyOf(Iterable<Matcher<? super T>> matchers)

Creates a matcher that matches if the examined object matches ANY of the specified matchers. For example:

assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))
anyOfback to summary
public static <T> AnyOf<T> anyOf(Matcher<? super T>... matchers)

Creates a matcher that matches if the examined object matches ANY of the specified matchers. For example:

assertThat("myValue", anyOf(startsWith("foo"), containsString("Val")))
Annotations
@SafeVarargs
describeToback to summary
public void describeTo(Description description)

Implements abstract org.hamcrest.core.ShortcutCombination.describeTo.

Implements org.hamcrest.SelfDescribing.describeTo.

Doc from org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.

Parameters
description:Description

The description to be built or appended to.

Annotations
@Override
matchesback to summary
public boolean matches(Object o)

Implements abstract org.hamcrest.core.ShortcutCombination.matches.

Implements org.hamcrest.Matcher.matches.

Doc from org.hamcrest.Matcher.matches.

Evaluates the matcher for argument item. This method matches against Object, instead of the generic type T. This is because the caller of the Matcher does not know at runtime what the type is (because of type erasure with Java generics). It is down to the implementations to check the correct type.

Parameters
o:Object

the object against which the matcher is evaluated.

Returns:boolean

true if item matches, otherwise false.

Annotations
@Override