
org.cthul.matchers.object.InstanceThat Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cthul-matchers Show documentation
Show all versions of cthul-matchers Show documentation
Provides hamcrest.org matchers for strings and exceptions,
allows matching code blocks, and provides several utilities for
combining matchers.
The newest version!
package org.cthul.matchers.object;
import org.cthul.matchers.chain.AndChainMatcher;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.core.Is;
import org.hamcrest.core.IsInstanceOf;
/**
*
*/
public class InstanceThat {
@Factory
@SuppressWarnings("unchecked")
public static AndChainMatcher.Builder instanceThat(Class clazz, Matcher super T2> m) {
return (AndChainMatcher.Builder) AndChainMatcher.both(IsInstanceOf.instanceOf(clazz), m);
}
@Factory
@SuppressWarnings("unchecked")
public static AndChainMatcher.Builder instanceThat(Class clazz, Matcher super T2>... m) {
Matcher[] matchers = new Matcher[m.length+1];
matchers[0] = IsInstanceOf.instanceOf(clazz);
System.arraycopy(m, 0, matchers, 1, m.length);
return AndChainMatcher.both(matchers);
}
@Factory
@SuppressWarnings("unchecked")
public static AndChainMatcher.Builder isInstanceThat(Class clazz, Matcher super T2> m) {
return (AndChainMatcher.Builder) AndChainMatcher.both(Is.is(IsInstanceOf.instanceOf(clazz)), m);
}
@Factory
@SuppressWarnings("unchecked")
public static Matcher isInstanceThat(Class clazz, Matcher super T2>... m) {
return Is.is(InstanceThat.instanceThat(clazz, m));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy