diff --git a/java-commons/src/main/freemarker/includes/ru/progrm_jarvis/javacommons/util/function/PrimitivePredicateBase.java.ftl b/java-commons/src/main/freemarker/includes/ru/progrm_jarvis/javacommons/util/function/PrimitivePredicateBase.java.ftl index 9b5ef9cd..4dd0c1ef 100644 --- a/java-commons/src/main/freemarker/includes/ru/progrm_jarvis/javacommons/util/function/PrimitivePredicateBase.java.ftl +++ b/java-commons/src/main/freemarker/includes/ru/progrm_jarvis/javacommons/util/function/PrimitivePredicateBase.java.ftl @@ -143,7 +143,7 @@ public interface ${className} extends Predicate${'<@NotNull ${wrapperType}>'}<#i /** * Creates a predicate which is always {@code true}. * - * @return predicate which is always {@code true}. + * @return predicate which is always {@code true} */ @Contract(value = "-> _", pure = true) static @NotNull DoublePredicate alwaysTrue() { @@ -153,7 +153,7 @@ public interface ${className} extends Predicate${'<@NotNull ${wrapperType}>'}<#i /** * Creates a predicate which is always {@code false}. * - * @return predicate which is always {@code false}. + * @return predicate which is always {@code false} */ @Contract(value = "-> _", pure = true) static @NotNull DoublePredicate alwaysFalse() { diff --git a/java-commons/src/main/java/ru/progrm_jarvis/javacommons/util/function/Predicates.java b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/util/function/Predicates.java new file mode 100644 index 00000000..46b69059 --- /dev/null +++ b/java-commons/src/main/java/ru/progrm_jarvis/javacommons/util/function/Predicates.java @@ -0,0 +1,32 @@ +package ru.progrm_jarvis.javacommons.util.function; + +import lombok.experimental.UtilityClass; +import org.jetbrains.annotations.NotNull; +import ru.progrm_jarvis.javacommons.annotation.Any; + +import java.util.function.Predicate; + +/** + * Common implementations of {@link Predicate}. + */ +@UtilityClass +public class Predicates { + + /** + * Creates a predicate which is always {@code true}. + * + * @return predicate which is always {@code true} + */ + public <@Any T> @NotNull Predicate alwaysTrue() { + return value -> true; + } + + /** + * Creates a predicate which is always {@code false}. + * + * @return predicate which is always {@code false} + */ + public <@Any T> @NotNull Predicate alwaysFalse() { + return value -> false; + } +}