Details
-
Improvement
-
Status: Resolved
-
High
-
Resolution: Done
-
None
Description
When we are enforcing non-null keys we use a very generic "Supplied value may not be null".
I.e. we have a stack trace:
java.lang.NullPointerException: Supplied value may not be null
at java.base/java.util.Objects.requireNonNull(Objects.java:246)
at org.opendaylight.yangtools.yang.binding.CodeHelpers.requireValue(CodeHelpers.java:63)
at org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey.<init>(FlowKey.java:18)
at org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder$FlowImpl.<init>(FlowBuilder.java:514)
from this code:
public FlowKey(@NonNull FlowId _id) { CodeHelpers.requireValue(_id); this._id = _id; }
so the code generator knows this is a key, and it knows each property's name, so this snippet should look like this:
public FlowKey(@NonNull FlowId _id) { this._id = CodeHelpers.requireLeaf(_id, "id"); }
where "id" should be QName.getLocalName(). The resulting component should then report something like 'Key component "id" must not be null'.
Since these properties can be copied through a lot of builders, from unkeyed to keyed lists, knowing the property name will go a long way.