Hamcrest Optional

A set of Hamcrest matchers for java.util.Optional.

Лицензия

Лицензия

Группа

Группа

com.github.baev
Идентификатор

Идентификатор

hamcrest-optional
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Hamcrest Optional
A set of Hamcrest matchers for java.util.Optional.
Ссылка на сайт

Ссылка на сайт

https://github.com/npathai/hamcrest-optional/
Система контроля версий

Система контроля версий

https://github.com/baev/hamcrest-optional/

Скачать hamcrest-optional

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.baev/hamcrest-optional/ -->
<dependency>
    <groupId>com.github.baev</groupId>
    <artifactId>hamcrest-optional</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.baev/hamcrest-optional/
implementation 'com.github.baev:hamcrest-optional:1.0'
// https://jarcasting.com/artifacts/com.github.baev/hamcrest-optional/
implementation ("com.github.baev:hamcrest-optional:1.0")
'com.github.baev:hamcrest-optional:jar:1.0'
<dependency org="com.github.baev" name="hamcrest-optional" rev="1.0">
  <artifact name="hamcrest-optional" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.baev', module='hamcrest-optional', version='1.0')
)
libraryDependencies += "com.github.baev" % "hamcrest-optional" % "1.0"
[com.github.baev/hamcrest-optional "1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.hamcrest : hamcrest-core jar 1.3

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

Hamcrest Optional

release Maven Central build covarage

An extension to Java Hamcrest which provides matchers for java.util.Optional.

Usage

The artifact is available at Maven Central:

<dependency>
    <groupId>com.github.baev</groupId>
    <artifactId>hamcrest-optional</artifactId>
    <version>1.0</version>
</dependency>

hamcrest-optional provides four matchers for Optional: isEmpty(), isPresent(), hasValue(Object) and hasValue(Matcher).

isEmpty()

This matcher matches when the examined Optional contains no value.

import static com.github.npathai.hamcrestopt.OptionalMatchers.isEmpty;

Optional<Object> optional = Optional.empty();
assertThat(optional, isEmpty());

isPresent()

This matcher matches when the examined Optional contains a value.

import static com.github.npathai.hamcrestopt.OptionalMatchers.isPresent;

Optional<String> optional = Optional.of("dummy value");
assertThat(optional, isPresent());

hasValue(Object)

This matcher matches when the examined Optional contains a value that is logically equal to the specified object.

import static com.github.npathai.hamcrestopt.OptionalMatchers.hasValue;

Optional<String> optional = Optional.of("dummy value");
assertThat(optional, hasValue("dummy value"));

hasValue(Matcher)

This matcher matches when the examined Optional contains a value that satisfies the specified matcher.

import static com.github.npathai.hamcrestopt.OptionalMatchers.hasValue;
import static org.hamcrest.Matchers.startsWith;

Optional<String> optional = Optional.of("dummy value");
assertThat(optional, hasValue(startsWith("dummy")));

Development Guide

hamcrest-optional is build with Maven. If you want to contribute code then

  • Please write a test for your change.
  • Ensure that you don't break the build by running mvn test.
  • Fork the repo and create a pull request. (See Understanding the GitHub Flow)

hamcrest-optional supports Travis CI for continuous integration. Your pull request is automatically build by Travis CI.

Версии библиотеки

Версия
1.0