SlideShare a Scribd company logo
1 of 19
Presented By: Deepak Mehra(Sr.Software Consultant)
Introduction to Vavr : A functional
Java library
Agenda
01
● What is Vavr?
● Prerequisite for Vavr
● Tuples
● Functions
● Values
● Collections
● Pattern Matching
● Demo
What is Vavr?
01
● Vavr is essentially a functional Java library which aims to extend the features of Java8 and helps to
reduce the amount of code and increase code quality.
● It provides collections, functional interfaces for error handling, concurrent programming, and
pattern matching. There are many other modules which revolves around vavr core.
● Also, It provides immutable data structures(cannot be modified once created), persistent data
structures(does preserve the previous version of itself when being modified), functional data
structures(also known as purely functional data structures), they are immutable and persistent.
Prerequisite for Vavr
01
● Java8
● Maven/Gradle
Tuples
01
You must have seen Tuples in Scala if you have ever worked on Scala. Tuple is nothing but a data
structure which will have fixed number of elements and can hold objects of heterogeneous
types(different types).
Functions
01
In Java8 we have Function which accepts one parameter and BiFunction which accepts two
parameters and gives output whereas vavr provides functions with upto a limit of 8 parameters.
The functional interfaces are like this Function0, Function1, Function2 and so on.
Values
01
● Option
● Try
● Lazy
● Either
● Future
● Collections
● Pattern Matching
Values
01
An expression which can be further evaluated for calculations or other. In Java, this can be
expressed by making the state of an object final and call it immutable. Vavr’s functional value
abstracts over immutable objects. If variable and objects are immutable their state is unmodifiable
and unchangeable which provides thread safety. So, we can share the variable without any fear in
a multi threaded environment.
Option
01
Option – We saw Option in Scala language. However, in Java something similar was introduced
with the help Optional class which behaves pretty much similar to Scala’s Option. Instances of
Option are either an instance of Some or None. Honestly speaking I don’t see much difference in
Scala’s Option and Java’s Optional.
Try
01
Try – Try is nothing but a container that represents a computation that may either result in an
exception or return a value. This looks similar to Either but it is different than that. Instances of Try,
are either Success or Failure
Lazy
01
Lazy – Lazy is a container which will represent a lazy evaluated value. Lazy is memoized already, it
evaluates only once and next time onwards returns from a cache.
Either
01
Either – An instance of Either is either an instance of Left or Right. A common use of Either is as an
alternative to Option for dealing with possible missing values. You can relate it Option as well, so
Left is considered to be None type and Right is considered to be Some type. Instance Right will
hold success and Left will hold failure.
Future
01
Future – A Future represents the result of an asynchronous computation. When the asynchronous
task is created, a future object is returned
There is a get() with Futures which will compute the result from Future but it is blocking in nature. It
also has isComplete() which returns a boolean value to mention if a future has been completed.
A future has two states: pending and completed
Future
01
Pending – The computation is on going. A pending future may be completed or cancelled.
Completed – The computation finished successfully with a result, failed with an exception or
cancelled.
Java8 already has a rich set of APIs for future. Future has been there since Java5 and it has
improved with time. Java8 has provided improvements to it. Now, we have
CompletableFuture(class) and CompletionStage(interface) with several callback methods.
I personally love Java8’s future API. Vavr has also introduced future class in the library with some
additional feature which we can play around with.
Collections
01
Collections – In vavr library a new collection library has been introduced to meet the functional
requirements, which is immutable in nature. Vavr library will essentially reduce the boilerplate code
which we will see going forward. This new collection is essentially based on java.lang.Iterable.
List in Vavr – Vavr list is essentially an immutable linked list. Mutations will result in new instances.
Pattern Matching
01
Pattern matching was not introduced as part of Java8, although we have worked with pattern
matching in Scala but Java never had it. Vavr library has support for pattern matching, now you can
also use pattern matching in Java8.
In pattern matching match is essentially an expression which yields some result. Also, pattern
matching is really a great feature to save a lot of time as it avoids to write if else branches and the
code looks more clean and readable.
Vavr library provides a match API which is pretty much similar to Scala’s pattern matching.
Pattern Matching
01
Pattern matching was not introduced as part of Java8, although we have worked with pattern
matching in Scala but Java never had it. Vavr library has support for pattern matching, now you can
also use pattern matching in Java8.
In pattern matching match is essentially an expression which yields some result. Also, pattern
matching is really a great feature to save a lot of time as it avoids to write if else branches and the
code looks more clean and readable.
Vavr library provides a match API which is pretty much similar to Scala’s pattern matching.
References
01
● https://www.vavr.io/vavr-docs/
● https://github.com/vavr-io/vavr
● https://blog.knoldus.com/introduction-to-vavr-a-functional-library-for-java/
● https://blog.knoldus.com/functional-java-how-to-do-pattern-matching-in-java/
Thank You !

More Related Content

What's hot

java 8 new features
java 8 new features java 8 new features
java 8 new features Rohit Verma
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noiseNeeraj Bhusare
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in javaagorolabs
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8Talha Ocakçı
 
Functional programming principles and Java 8
Functional programming principles and Java 8Functional programming principles and Java 8
Functional programming principles and Java 8Dragos Balan
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PunePankaj kshirsagar
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scalaStratio
 
JavaScripts internals #1
JavaScripts internals #1JavaScripts internals #1
JavaScripts internals #1Martin Pernica
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with javaTechglyphs
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
Java Review
Java ReviewJava Review
Java Reviewpdgeorge
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with XtendSven Efftinge
 
Virtual function and abstract class
Virtual function and abstract classVirtual function and abstract class
Virtual function and abstract classShweta Shah
 

What's hot (20)

java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noise
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
 
Intro to Scala
 Intro to Scala Intro to Scala
Intro to Scala
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Functional programming principles and Java 8
Functional programming principles and Java 8Functional programming principles and Java 8
Functional programming principles and Java 8
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council Pune
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
JavaScripts internals #1
JavaScripts internals #1JavaScripts internals #1
JavaScripts internals #1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Core java
Core javaCore java
Core java
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
Java Review
Java ReviewJava Review
Java Review
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with Xtend
 
From Java to Kotlin
From Java to KotlinFrom Java to Kotlin
From Java to Kotlin
 
Virtual function and abstract class
Virtual function and abstract classVirtual function and abstract class
Virtual function and abstract class
 

Similar to Introduction To Vavr: A Functional Java Library

Learn scala and it's componenents learn it
Learn scala and it's componenents learn itLearn scala and it's componenents learn it
Learn scala and it's componenents learn itsiddharth30121
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2Sherihan Anver
 
Java Basics Presentation
Java Basics PresentationJava Basics Presentation
Java Basics PresentationOmid Sohrabi
 
Java Closures
Java ClosuresJava Closures
Java ClosuresBen Evans
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedyearninginjava
 
Top 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedGaurav Maheshwari
 
LSUG: How we (mostly) moved from Java to Scala
LSUG: How we (mostly) moved from Java to ScalaLSUG: How we (mostly) moved from Java to Scala
LSUG: How we (mostly) moved from Java to ScalaGraham Tackley
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Fresherszynofustechnology
 
Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...
Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...
Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...SynergisticMedia
 
Chapter1pp
Chapter1ppChapter1pp
Chapter1ppJ. C.
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questionsGradeup
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questionsSynergisticMedia
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1SURBHI SAROHA
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JSKnoldus Inc.
 
Java programming language
Java programming languageJava programming language
Java programming languageSubhashKumar329
 

Similar to Introduction To Vavr: A Functional Java Library (20)

Learn scala and it's componenents learn it
Learn scala and it's componenents learn itLearn scala and it's componenents learn it
Learn scala and it's componenents learn it
 
scala-intro
scala-introscala-intro
scala-intro
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
 
Volatile keyword
Volatile keywordVolatile keyword
Volatile keyword
 
Java_Interview Qns
Java_Interview QnsJava_Interview Qns
Java_Interview Qns
 
Java Basics Presentation
Java Basics PresentationJava Basics Presentation
Java Basics Presentation
 
Java Closures
Java ClosuresJava Closures
Java Closures
 
Java Faqs useful for freshers and experienced
Java Faqs useful for freshers and experiencedJava Faqs useful for freshers and experienced
Java Faqs useful for freshers and experienced
 
Top 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experiencedTop 371 java fa qs useful for freshers and experienced
Top 371 java fa qs useful for freshers and experienced
 
LSUG: How we (mostly) moved from Java to Scala
LSUG: How we (mostly) moved from Java to ScalaLSUG: How we (mostly) moved from Java to Scala
LSUG: How we (mostly) moved from Java to Scala
 
Java Interview Questions For Freshers
Java Interview Questions For FreshersJava Interview Questions For Freshers
Java Interview Questions For Freshers
 
Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...
Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...
Top 30 Java Phone Interview Questions Answers for Freshers, 1 to 2 Years Expe...
 
Chapter1pp
Chapter1ppChapter1pp
Chapter1pp
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1
 
Introduction to Scala JS
Introduction to Scala JSIntroduction to Scala JS
Introduction to Scala JS
 
Java programming language
Java programming languageJava programming language
Java programming language
 
ppt_on_java.pptx
ppt_on_java.pptxppt_on_java.pptx
ppt_on_java.pptx
 
Java_Roadmap.pptx
Java_Roadmap.pptxJava_Roadmap.pptx
Java_Roadmap.pptx
 

More from Knoldus Inc.

Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingKnoldus Inc.
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionKnoldus Inc.
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxKnoldus Inc.
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptxKnoldus Inc.
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfKnoldus Inc.
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxKnoldus Inc.
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingKnoldus Inc.
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesKnoldus Inc.
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxKnoldus Inc.
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxKnoldus Inc.
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxKnoldus Inc.
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxKnoldus Inc.
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxKnoldus Inc.
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationKnoldus Inc.
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationKnoldus Inc.
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIsKnoldus Inc.
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II PresentationKnoldus Inc.
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Configuring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAConfiguring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAKnoldus Inc.
 
Advanced Python (with dependency injection and hydra configuration packages)
Advanced Python (with dependency injection and hydra configuration packages)Advanced Python (with dependency injection and hydra configuration packages)
Advanced Python (with dependency injection and hydra configuration packages)Knoldus Inc.
 

More from Knoldus Inc. (20)

Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable Testing
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose Kubernetes
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptx
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptx
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptx
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptx
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake Presentation
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics Presentation
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIs
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II Presentation
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Configuring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAConfiguring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRA
 
Advanced Python (with dependency injection and hydra configuration packages)
Advanced Python (with dependency injection and hydra configuration packages)Advanced Python (with dependency injection and hydra configuration packages)
Advanced Python (with dependency injection and hydra configuration packages)
 

Recently uploaded

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Recently uploaded (20)

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Introduction To Vavr: A Functional Java Library

  • 1. Presented By: Deepak Mehra(Sr.Software Consultant) Introduction to Vavr : A functional Java library
  • 2. Agenda 01 ● What is Vavr? ● Prerequisite for Vavr ● Tuples ● Functions ● Values ● Collections ● Pattern Matching ● Demo
  • 3. What is Vavr? 01 ● Vavr is essentially a functional Java library which aims to extend the features of Java8 and helps to reduce the amount of code and increase code quality. ● It provides collections, functional interfaces for error handling, concurrent programming, and pattern matching. There are many other modules which revolves around vavr core. ● Also, It provides immutable data structures(cannot be modified once created), persistent data structures(does preserve the previous version of itself when being modified), functional data structures(also known as purely functional data structures), they are immutable and persistent.
  • 4. Prerequisite for Vavr 01 ● Java8 ● Maven/Gradle
  • 5. Tuples 01 You must have seen Tuples in Scala if you have ever worked on Scala. Tuple is nothing but a data structure which will have fixed number of elements and can hold objects of heterogeneous types(different types).
  • 6. Functions 01 In Java8 we have Function which accepts one parameter and BiFunction which accepts two parameters and gives output whereas vavr provides functions with upto a limit of 8 parameters. The functional interfaces are like this Function0, Function1, Function2 and so on.
  • 7. Values 01 ● Option ● Try ● Lazy ● Either ● Future ● Collections ● Pattern Matching
  • 8. Values 01 An expression which can be further evaluated for calculations or other. In Java, this can be expressed by making the state of an object final and call it immutable. Vavr’s functional value abstracts over immutable objects. If variable and objects are immutable their state is unmodifiable and unchangeable which provides thread safety. So, we can share the variable without any fear in a multi threaded environment.
  • 9. Option 01 Option – We saw Option in Scala language. However, in Java something similar was introduced with the help Optional class which behaves pretty much similar to Scala’s Option. Instances of Option are either an instance of Some or None. Honestly speaking I don’t see much difference in Scala’s Option and Java’s Optional.
  • 10. Try 01 Try – Try is nothing but a container that represents a computation that may either result in an exception or return a value. This looks similar to Either but it is different than that. Instances of Try, are either Success or Failure
  • 11. Lazy 01 Lazy – Lazy is a container which will represent a lazy evaluated value. Lazy is memoized already, it evaluates only once and next time onwards returns from a cache.
  • 12. Either 01 Either – An instance of Either is either an instance of Left or Right. A common use of Either is as an alternative to Option for dealing with possible missing values. You can relate it Option as well, so Left is considered to be None type and Right is considered to be Some type. Instance Right will hold success and Left will hold failure.
  • 13. Future 01 Future – A Future represents the result of an asynchronous computation. When the asynchronous task is created, a future object is returned There is a get() with Futures which will compute the result from Future but it is blocking in nature. It also has isComplete() which returns a boolean value to mention if a future has been completed. A future has two states: pending and completed
  • 14. Future 01 Pending – The computation is on going. A pending future may be completed or cancelled. Completed – The computation finished successfully with a result, failed with an exception or cancelled. Java8 already has a rich set of APIs for future. Future has been there since Java5 and it has improved with time. Java8 has provided improvements to it. Now, we have CompletableFuture(class) and CompletionStage(interface) with several callback methods. I personally love Java8’s future API. Vavr has also introduced future class in the library with some additional feature which we can play around with.
  • 15. Collections 01 Collections – In vavr library a new collection library has been introduced to meet the functional requirements, which is immutable in nature. Vavr library will essentially reduce the boilerplate code which we will see going forward. This new collection is essentially based on java.lang.Iterable. List in Vavr – Vavr list is essentially an immutable linked list. Mutations will result in new instances.
  • 16. Pattern Matching 01 Pattern matching was not introduced as part of Java8, although we have worked with pattern matching in Scala but Java never had it. Vavr library has support for pattern matching, now you can also use pattern matching in Java8. In pattern matching match is essentially an expression which yields some result. Also, pattern matching is really a great feature to save a lot of time as it avoids to write if else branches and the code looks more clean and readable. Vavr library provides a match API which is pretty much similar to Scala’s pattern matching.
  • 17. Pattern Matching 01 Pattern matching was not introduced as part of Java8, although we have worked with pattern matching in Scala but Java never had it. Vavr library has support for pattern matching, now you can also use pattern matching in Java8. In pattern matching match is essentially an expression which yields some result. Also, pattern matching is really a great feature to save a lot of time as it avoids to write if else branches and the code looks more clean and readable. Vavr library provides a match API which is pretty much similar to Scala’s pattern matching.
  • 18. References 01 ● https://www.vavr.io/vavr-docs/ ● https://github.com/vavr-io/vavr ● https://blog.knoldus.com/introduction-to-vavr-a-functional-library-for-java/ ● https://blog.knoldus.com/functional-java-how-to-do-pattern-matching-in-java/