本文整理了Java中org.hamcrest.Matcher.matches()
方法的一些代码示例,展示了Matcher.matches()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matcher.matches()
方法的具体详情如下:
包路径:org.hamcrest.Matcher
类名称: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.
[中]计算参数项的匹配器。
此方法匹配对象,而不是泛型类型T。这是因为匹配器的调用方在运行时不知道类型是什么(因为Java泛型的类型擦除)。检查正确的类型取决于实现。
代码示例来源:origin: org.mockito/mockito-core
public boolean matches(Object argument) {
return this.matcher.matches(argument);
}
代码示例来源:origin: junit-team/junit4
@Override
protected boolean matchesSafely(T item) {
return throwableMatcher.matches(item);
}
代码示例来源:origin: google/j2objc
private boolean safelyMatches(Matcher m, Object arg) {
try {
return m.matches(arg);
} catch (Throwable t) {
return false;
}
}
代码示例来源:origin: junit-team/junit4
@Override
protected boolean matchesSafely(T item) {
return causeMatcher.matches(item.getCause());
}
代码示例来源:origin: junit-team/junit4
@Override
protected boolean matchesSafely(T item) {
return matcher.matches(item.getMessage());
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean matches(Object item) {
Throwable cause = null;
if (item != null && item instanceof Throwable) {
cause = ((Throwable)item).getCause();
}
return matcher.matches(cause);
}
代码示例来源:origin: neo4j/neo4j
@Override
protected boolean matchesSafely( Iterable<T> items )
{
for ( T item : items )
{
if ( itemMatcher.matches( item ) )
{
return true;
}
}
return false;
}
代码示例来源:origin: neo4j/neo4j
protected boolean matches( LogCall logCall )
{
return logCall != null &&
contextMatcher.matches( logCall.context ) &&
levelMatcher.matches( logCall.level ) &&
messageMatcher.matches( logCall.message ) &&
argumentsMatcher.matches( logCall.arguments ) &&
throwableMatcher.matches( logCall.throwable );
}
代码示例来源:origin: neo4j/neo4j
@Override
protected boolean matchesSafely( Iterable<T> items )
{
for ( T item : items )
{
if ( itemMatcher.matches( item ) )
{
return false;
}
}
return true;
}
代码示例来源:origin: google/j2objc
@Override
public boolean matching(Matcher<T> matcher, String message) {
if (matcher.matches(theValue)) {
return true;
}
mismatch.appendText(message);
matcher.describeMismatch(theValue, mismatch);
return false;
}
代码示例来源:origin: google/j2objc
@Override
protected boolean matchesSafely(T item, Description mismatch) {
if (!matcher.matches(item)) {
matcher.describeMismatch(item, mismatch);
return false;
}
return true;
}
代码示例来源:origin: google/j2objc
@Override
protected boolean matchesSafely(T actual, Description mismatch) {
final U featureValue = featureValueOf(actual);
if (!subMatcher.matches(featureValue)) {
mismatch.appendText(featureName).appendText(" ");
subMatcher.describeMismatch(featureValue, mismatch);
return false;
}
return true;
};
代码示例来源:origin: neo4j/neo4j
@Override
protected boolean matchesSafely( Throwable throwable )
{
return matcher.matches( throwable.getMessage() );
}
代码示例来源:origin: neo4j/neo4j
@Override
protected boolean matchesSafely( Exception item )
{
return message.matches( item.getMessage() );
}
代码示例来源:origin: junit-team/junit4
@Override
public boolean matchesSafely(PrintableResult item) {
return item.failureCount() == 1 && matcher.matches(item.failures().get(0).getException());
}
代码示例来源:origin: LMAX-Exchange/disruptor
@Override
public boolean matchesSafely(final RingBuffer<Object[]> ringBuffer)
{
boolean matches = true;
for (int i = 0; i < expectedValueMatchers.length; i++)
{
final Matcher<?> expectedValueMatcher = expectedValueMatchers[i];
matches &= expectedValueMatcher.matches(ringBuffer.get(i)[0]);
}
return matches;
}
代码示例来源:origin: apache/flink
@Override
protected boolean matchesSafely(StreamRecord<? extends T> streamRecord) {
return valueMatcher.matches(streamRecord.getValue())
&& timestampMatcher.matches(streamRecord.getTimestamp());
}
}
代码示例来源:origin: ben-manes/caffeine
public <T> DescriptionBuilder expectThat(String reason, T actual, Matcher<? super T> matcher) {
if (!matcher.matches(actual)) {
addError(reason, actual, matcher);
}
return this;
}
代码示例来源:origin: apache/flink
@Override
protected boolean matchesSafely(StreamRecord<? extends WindowedValue<? extends T, ? extends W>> streamRecord) {
return valueMatcher.matches(streamRecord.getValue().value())
&& timestampMatcher.matches(streamRecord.getTimestamp())
&& windowMatcher.matches(streamRecord.getValue().window());
}
}
代码示例来源:origin: neo4j/neo4j
@Override
protected boolean matchesSafely( Notification item )
{
return code.equals( item.getCode() ) &&
description.matches( item.getDescription() ) &&
position.matches( item.getPosition() ) &&
severity.equals( item.getSeverity() );
}
内容来源于网络,如有侵权,请联系作者删除!