powsybl / powsybl-core

A framework to build power system oriented software
https://www.powsybl.org
Mozilla Public License 2.0
126 stars 41 forks source link

Reporter: provide a TypedValue constructor overload for undefined type #2194

Closed geofjamg closed 8 months ago

geofjamg commented 2 years ago
reporter.createSubReporter("lfNetwork", "Network CC${networkNumCc} SC${networkNumSc}",
                Map.of(NETWORK_NUM_CC, new TypedValue(networkNumCc, TypedValue.UNTYPED),
                        NETWORK_NUM_SC, new TypedValue(networkNumSc, TypedValue.UNTYPED)));

could be written

reporter.createSubReporter("lfNetwork", "Network CC${networkNumCc} SC${networkNumSc}",
                Map.of(NETWORK_NUM_CC, new TypedValue(networkNumCc),
                        NETWORK_NUM_SC, new TypedValue(networkNumSc)));

Or even better

reporter.createSubReporter("lfNetwork", "Network CC${networkNumCc} SC${networkNumSc}",
                Map.of(NETWORK_NUM_CC, TypedValue.of(networkNumCc),
                        NETWORK_NUM_SC, TypedValue.of(networkNumSc)));

And provides an overload for all supported types to avoid .of(Object obj)

(if a question doesn't apply, you can delete it)

sylvlecl commented 2 years ago

Maybe TypedValue.untyped(value) to be more explicit ?

flo-dup commented 8 months ago

TypedValue cannot be instantiated anymore, adder/builder should be used instead with methods: