
com.annimon.stream.test.OptionalMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stream-test Show documentation
Show all versions of stream-test Show documentation
Hamcrest and Mockito matchers for Lightweight-Stream-API
package com.annimon.stream.test;
import com.annimon.stream.Optional;
import static org.hamcrest.CoreMatchers.not;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
public class OptionalMatcher {
private OptionalMatcher() { }
public static Matcher> isPresent() {
return new IsPresentMatcher();
}
public static Matcher> isEmpty() {
return not(isPresent());
}
public static class IsPresentMatcher extends TypeSafeDiagnosingMatcher> {
@Override
protected boolean matchesSafely(Optional> optional, Description mismatchDescription) {
mismatchDescription.appendText("Optional was empty");
return optional.isPresent();
}
@Override
public void describeTo(Description description) {
description.appendText("Optional value should be present");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy