-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from JarvisCraft/functional-shorthands
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
java-commons/src/main/java/ru/progrm_jarvis/javacommons/util/function/Predicates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T> alwaysTrue() { | ||
return value -> true; | ||
} | ||
|
||
/** | ||
* Creates a predicate which is always {@code false}. | ||
* | ||
* @return predicate which is always {@code false} | ||
*/ | ||
public <@Any T> @NotNull Predicate<T> alwaysFalse() { | ||
return value -> false; | ||
} | ||
} |