Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
twitch
live-coding-fr
Commits
0813ae3b
Commit
0813ae3b
authored
Nov 24, 2020
by
Colin DAMON
Browse files
Extract floor entry recuperation
parent
5cabb1e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
tcr-roman-numerals/src/main/java/fr/ippon/kata/numeral/Numerals.java
View file @
0813ae3b
...
...
@@ -10,7 +10,11 @@ public class Numerals {
private
static
final
NavigableMap
<
Integer
,
String
>
CONVERSIONS
=
buildConversions
();
public
static
String
toRoman
(
int
arabic
)
{
return
Optional
.
ofNullable
(
CONVERSIONS
.
floorEntry
(
arabic
)).
map
(
romanRepresentation
(
arabic
)).
orElse
(
""
);
return
highestKnownConversion
(
arabic
).
map
(
romanRepresentation
(
arabic
)).
orElse
(
""
);
}
private
static
Optional
<
Entry
<
Integer
,
String
>>
highestKnownConversion
(
int
arabic
)
{
return
Optional
.
ofNullable
(
CONVERSIONS
.
floorEntry
(
arabic
));
}
private
static
Function
<
Entry
<
Integer
,
String
>,
String
>
romanRepresentation
(
int
arabic
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment