Functional Java
$4.99
Minimum price
$4.99
Suggested price

Functional Java

with Vavr

About the Book

About the Author

dimitris papadimitriou
dimitris papadimitriou

I have more than 14 years’ experience as full stack developer and Architect.

I Like to stay in touch with all the latest developments in the field, as well as the foundational Theoretical Computer science and algorithm Analysis and Design

https://www.linkedin.com/in/dimitrispapadimitriou/

Bundles that include this book

$12.99
Suggested Price
$10.99
Bundle Price

Table of Contents

  • 1 Language Functional support
    • 1.1 Pure functions and Side effects ... 6
    • 1.2 Functional Interfaces ... 9
    • 1.3 Function Composition ... 15
    • 1.3.1 Function<,> andThen method ... 15
    • 1.3.2 BiFunction<> Composition ... 16
    • 1.3.3 Supplier<> Composition ... 17
    • 1.3.4 Consumer<> Composition ... 17
    • 1.3.5 Predicate<> Composition ... 19
    • 1.4 Vavr’s Functional Interfaces ... 20
    • 1.5 Currying and partial application ... 21
    • 1.5.1 Currying and partial application with Vavr ... 24
  • 2 Functors
    • 2.1 The Identity Functor ... 26
    • 2.2 Commutative Diagrams ... 27
    • 2.3 The Functor Laws ... 28
    • 2.4 Pattern Matching ... 30
    • 2.4.1 The Basic Functor Mechanics ... 36
    • 2.5 IO Functor, a Lazy Id Functor ... 37
    • 2.5.1 Supplier as a Functor ... 37
    • 2.6 Maybe Functor – Optional and Option ... 38
    • 2.6.1 Dealing with null ... 38
    • 2.6.2 The Null Object Design pattern ... 39
    • 2.6.3 The Functional equivalent - Maybe as Functor ... 41
    • 2.6.4 Java native Maybe aka Optional ... 43
    • 2.6.5 Maybe Functor Example with java Optional ... 44
    • 2.6.6 Maybe in Vavr aka Option ... 45
    • 2.6.7 Maybe Functor Example with Vavr Option ... 46
    • 2.7 Either Functor ... 48
    • 2.7.1 Pattern matching for Either ... 50
    • 2.7.2 Either in Vavr ... 50
    • 2.7.3 Either Functor Example ... 51
    • 2.7.4 Vavr’s pattern matching Support for Either ... 53
    • 2.7.5 Using Either for exception handling ... 54
    • 2.8 Explicitly Compositing Functor ... 56
    • 2.9 Extending CompletableFuture to Functor ... 58
    • 2.10 Combining Future and Optional - Future> ... 60
    • 2.11 Combining Future and Option - Future> ... 62
    • 2.12 Combining Future and Either - Future> ... 64
  • 3 Monads
    • 3.1 The Stream Monad ... 68
    • 3.2 Maybe Monad ... 68
    • 3.3 The Java Optional Monad Example ... 70
    • 3.3.1 Using Vavr Option ... 72
    • 3.4 Either Monad ... 72
    • 3.4.1 Using Either Monad for exception handling ... 74
    • 3.4.2 Using Either for Validation ... 75
    • 3.5 Validation Monad ... 76
    • 3.5.1 Using Validation.Apply to Collect validations ... 77
    • 3.6 CompletableFuture as Monad ... 78
    • 3.7 The CompletableFuture - Optional Monad Combination ... 80
    • 3.8 The CompletableFuture - Option Monad Combination ... 82
    • 3.9 The CompletableFuture - Either Monad Combination ... 85
  • 4 A Clean Functional Architecture Example
    • 4.1 Download and Setup the Project ... 87
    • 4.1.1 Clean Architecture with Spring Boot ... 88
    • 4.2 A Functional Applications Architecture ... 90
    • 4.3 Clean Architecture with Spring Boot and Vavr.io ... 91
    • 4.4 Web Api ... 92
    • 4.5 Domain Model ... 93
    • 4.5.1 Repositories ... 96
    • 4.6 CQRS ... 97
    • 4.7 CQRS and Mediator Design Pattern ... 99
    • 4.7.1 The Command Pattern with a Mediator ... 99
    • 4.7.2 Query Workflow ... 102
    • 4.7.3 Command Workflow ... 106

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$11,043,141writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub