From 23aa0c7fff26e3ac5721ff21f1d1cd3a6e273da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20S=C3=A1nchez=20Grande?= <107065114+victorsgDev@users.noreply.github.com> Date: Tue, 17 Jan 2023 20:11:52 +0100 Subject: [PATCH] Update Readme.md docs added --- Readme.md | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index c3effd3..8341685 100644 --- a/Readme.md +++ b/Readme.md @@ -1,8 +1,44 @@ -### Lambda Master class - part 1 +# FUNCTIONAL INTERFACES @FunctionalInterface: +## Consumer: -This is the examples used in the talk we made with Stuart Marks (@StuartMarks) at Devoxx Belgium 2018. - -The talk is available on YouTube: https://youtu.be/ePXnCezwRuw and the slides are on Slideshare: https://www.slideshare.net/jpaumard/lambda-and-stream-master-class-part-1 - -You can can see the code exercises without the solutions on this commit: https://github.com/JosePaumard/lambda-master-class-part1/releases/tag/Examples_without_solutions + Recibe un argumento pero no retorna nada. + + - Método funcional: + + void accept(T t); + + - Método default: + + default Consumer andThen(Consumer other) { + return (T t) -> { this.accept(t); other.accept(t);}; + } + + ## Predicate: + + Recibe un argumento y retorna un boolean. + + - Método funcional: + + boolean test(T t); + + - Métodos default: + + default Predicate negate() { + return t -> !this.test(t); + } + + default Predicate and(Predicate other) { + Objects.requireNonNull(other); + return t -> this.test(t) && other.test(t); + } + default Predicate or(Predicate other) { + Objects.requireNonNull(other); + return t -> this.test(t) || other.test(t); + } + + default Predicate isEqual(Object targetRef){ + return (null == targetRef) + ? Objects::isNull + : object -> targetRef.equals(object); + }