Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: JosePaumard/lambda-master-class-part1
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: victorsgDev/lambda-master-class-part1
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Jan 17, 2023

  1. Update Readme.md

    docs added
    victorsgDev authored Jan 17, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    23aa0c7 View commit details
  2. Update Readme.md

    victorsgDev authored Jan 17, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8d95822 View commit details
  3. Update Readme.md

    victorsgDev authored Jan 17, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7a11e87 View commit details
Showing with 61 additions and 4 deletions.
  1. +61 −4 Readme.md
65 changes: 61 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,65 @@
### 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.
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);
}

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
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);
}

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
## Comparator<T>:

Recibe dos argumentos y retorna un int.

- Método funcional:

int compare(T t1, T t2);

- Métodos:

static <T, U extends Comparable<? super U>> Comparator<T> comparing(Function<T, U> keyExtractor) {
Objects.requireNonNull(keyExtractor);
return (p1, p2) -> {
U u1 = keyExtractor.apply(p1);
U u2 = keyExtractor.apply(p2);
return u1.compareTo(u2);
};
}