[ https://issues.apache.org/jira/browse/GEOMETRY-125?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17366240#comment-17366240 ]
Matt Juntunen commented on GEOMETRY-125: ---------------------------------------- So many enums... :-) I'd like to use builders to construct the instances. For example, {code:java} DoubleFunction<String> fmt = builder .withPrecision(3) .withMinExponent(2) .build(); {code} However, not all options would apply to all formats. For example, the {{default}} format requires a min and max plain value for determining when to switch to scientific format. These values do not apply to any of the other formats. I suppose, the builder class could contain a superset of all available options and just document which ones apply to what formats. Ex: {code:java} DoubleFunction<String> fmt = DoubleFormat.PLAIN.builder() .withPrecision(4) .withMaxPlainValue(1000) // does not apply in this case but is part of the builder class .build(); {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)