Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
live-coding-fr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
twitch
live-coding-fr
Merge requests
!83
Resolve "Java monades code"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Java monades code"
111-java-monades-code
into
master
Overview
0
Commits
1
Pipelines
0
Changes
9
Merged
Colin DAMON
requested to merge
111-java-monades-code
into
master
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
9
Expand
Closes
#111 (closed)
Edited
3 years ago
by
Colin DAMON
0
0
Merge request reports
Viewing commit
3d5e994c
Show latest version
9 files
+
188
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
9
Search (e.g. *.vue) (Ctrl+P)
3d5e994c
Coding monades in Java
· 3d5e994c
Colin DAMON
authored
3 years ago
java-monades/src/main/java/fr/ippon/monad/Maybe.java
0 → 100644
+
35
−
0
Options
package
fr.ippon.monad
;
import
java.util.Optional
;
import
java.util.function.Function
;
public
class
Maybe
<
T
>
{
private
final
Optional
<
T
>
value
;
private
Maybe
(
Optional
<
T
>
value
)
{
this
.
value
=
value
;
}
public
static
<
T
>
Maybe
<
T
>
pure
(
T
value
)
{
return
new
Maybe
<>(
Optional
.
of
(
value
));
}
public
static
<
T
>
Maybe
<
T
>
fail
()
{
return
new
Maybe
<>(
Optional
.
empty
());
}
public
<
U
>
Maybe
<
U
>
map
(
Function
<
T
,
U
>
mapper
)
{
return
new
Maybe
<>(
value
.
map
(
mapper
));
}
public
<
U
>
Maybe
<
U
>
bind
(
Function
<
T
,
Maybe
<
U
>>
other
)
{
return
value
.
map
(
other
)
.
orElse
(
Maybe
.
fail
());
}
@Override
public
String
toString
()
{
return
value
.
toString
();
}
}
Loading