powsybl-core icon indicating copy to clipboard operation
powsybl-core copied to clipboard

Reporter: provide a TypedValue constructor overload for undefined type

Open geofjamg opened this issue 2 years ago • 1 comments

  • Do you want to request a feature or report a bug? Feature

  • What is the current behavior? We should provide a TypedValue constructor overload in case of an undefined type.

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)));
  • What is the expected behavior?

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)

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

    • PowSyBl Version: ...
    • OS Version: ...
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, spectrum, etc)

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

geofjamg avatar Jul 03 '22 20:07 geofjamg

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

sylvlecl avatar Jul 04 '22 07:07 sylvlecl

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

  • withTypedValue(valueKey, value, type)
  • withUntypedValue(valueKey, value)

flo-dup avatar Mar 11 '24 10:03 flo-dup