Skip to content

Commit

Permalink
Update Readme.md
Browse files Browse the repository at this point in the history
docs added
  • Loading branch information
victorsgDev authored Jan 17, 2023
1 parent a6aeb09 commit 23aa0c7
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
### Lambda Master class - part 1
# FUNCTIONAL INTERFACES @FunctionalInterface:
## Consumer<T>:

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<T> andThen(Consumer<T> other) {
return (T t) -> { this.accept(t); other.accept(t);};
}

## Predicate<T>:

Recibe un argumento y retorna un boolean.

- Método funcional:

boolean test(T t);

- Métodos default:

default Predicate<T> negate() {
return t -> !this.test(t);
}

default Predicate<T> and(Predicate<T> other) {
Objects.requireNonNull(other);
return t -> this.test(t) && other.test(t);
}

default Predicate<T> or(Predicate<T> other) {
Objects.requireNonNull(other);
return t -> this.test(t) || other.test(t);
}

default Predicate<T> isEqual(Object targetRef){
return (null == targetRef)
? Objects::isNull
: object -> targetRef.equals(object);
}

0 comments on commit 23aa0c7

Please sign in to comment.