predicates

The intention of this project is to improve readability of equality and relational operators using predefined [Predicates](https://docs.oracle.com/javase/8/docs/api/java/util/function/Predicate.html).

Лицензия

Лицензия

Группа

Группа

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

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

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

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

0.4
Дата

Дата

Тип

Тип

jar
Описание

Описание

predicates
The intention of this project is to improve readability of equality and relational operators using predefined [Predicates](https://docs.oracle.com/javase/8/docs/api/java/util/function/Predicate.html).
Ссылка на сайт

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

https://github.com/puddingspudding/java-predicates
Система контроля версий

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

https://github.com/puddingspudding/java-predicates

Скачать predicates

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

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

Зависимости

test (1)

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

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

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

Java8 Predicates

The intention of this project is to improve readability of equality and relational operators (< > <= >= == !=) using predefined Predicates. It also contains a Predicate interface with then(), orElse() and elseIf() to replace if-then and if-then-else statements.


mvn

<dependency>
    <groupId>com.github.puddingspudding</groupId>
    <artifactId>predicates</artifactId>
    <version>0.4</version>
</dependency>

Predicates

  • isEqualTo { a == b }
  • isNotEqualTo { a != b }
  • isBiggerThan { a > b }
  • isSmallerThan { a < b }
  • isEqualOrBiggerThan { a >= b }
  • isEqualOrSmallerThan { a <= b }
  • isInRange { a <= x && x <= b }
  • isNotInRage { x < a && b < x }
  • isNegative { a < 0 }
  • isPositive { a > 0 }
  • isEven { x % 2 == 0 }
  • isOdd { x % 2 != 0 }

Examples

java.util.function.Predicate

import java.util.function.Predicate;
import static com.github.puddingspudding.IntegerPredicates.*;
import static com.github.puddingspudding.LongPredicates.*;

// isEqualTo
Predicate<Integer> isEqualToOne = isEqualTo(1);
if (isEqualToOne.test(1)) {
    // do something
}

// isNotEqualTo
Predicate<Integer> isNotEqualToOne = isNotEqualTo(1);
if (isNotEqualToOne.test(2)) {
    // do something
}

// ...

if (isBiggerThan(10).or(isSmallerThan(-10)).test(x))) {
    // x is awesome
    // or use isNotInRange(-10).apply(10).test(x)
}

Stream.of(1,2,3,4,5,6)
	.filter(isBiggerThan(3))
	.collect(Collectors.toList());
	// [4, 5, 6]

License

Apache 2.0

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

Версия
0.4
0.3
0.2
0.1