You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2021/06/12 16:15:00 UTC

[jira] [Commented] (GEOMETRY-125) DoubleFormats Builder

    [ https://issues.apache.org/jira/browse/GEOMETRY-125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17362351#comment-17362351 ] 

Gilles Sadowski commented on GEOMETRY-125:
------------------------------------------

bq. {{build()}} [vs] {{buildScientific()}}

An {{enum}}, maybe? ;-)

{code}
public enum DoubleFormat {
    PLAIN( /* ... */),
    SCIENTIFIC( /* ... */ ),
    ENGINEER( /* ... */ ),
    DEFAULT( /* ... */ )

    // ...
}
{code}

> DoubleFormats Builder
> ---------------------
>
>                 Key: GEOMETRY-125
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-125
>             Project: Apache Commons Geometry
>          Issue Type: Improvement
>            Reporter: Matt Juntunen
>            Priority: Major
>
> Use a {{Builder}} class in {{DoubleFormats}} to make the API more self-documenting. Ex:
> {code:java}
> // current
> DoubleFunction<String> def = DoubleFormats.createDefault(5, -3);
> DoubleFunction<String> sci = DoubleFormats.createScientific(5, -3);
> // new
> DoubleFunction<String> def = DoubleFormats.builder()
>     .withMaxPrecision(5)
>     .withMinExponent(-3)
>     .build();
> DoubleFunction<String> sci = DoubleFormats.builder()
>     .withMaxPrecision(5)
>     .withMinExponent(-3)
>     .buildScientific();
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)