You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
commands (that can be cut-and-pasted into a command shell),
inputs,
outputs, and
expectation.
So I have this data structure: Nullable Map<String, Nullable Map<String, Nullable String>>
There are 3 nullable locations
But one can also pas non-null data into these locations, so one needs to write nonnull versions also like: Map<String, Map<String, String>>
But these are combinations, so the number of method signatures here is factorial, which is not great.
The context here is that I am ingesting json data with a known nullable shape, and am instantiating output classes containing that data this PR.
Is there a way for me to write fewer than factorial methods here which will cover all use cases?
Casting NonNull into Nullable would allow me to just use the the signature.
Is this covariance?
Also is there an active slack/discord/irc community for this tool?
I would prefer to ask there but only saw the mailing list mentioned as an option.
Apologies if this is the wrong place to ask this.
My real world example:
With this code invocation:
schema.validate(
MapMaker.makeMap(
new AbstractMap.SimpleEntry<>(
"foo",
"baz"
),
new AbstractMap.SimpleEntry<>(
"bar",
2
)
),
configuration
);
I get this error:
java: [argument] incompatible argument for parameter arg of validate.
found : @Initialized @NonNull Map<@Initialized @NonNull String, @Initialized @NonNull Object>
required: @Initialized @NonNull Map<@Initialized @NonNull String, @Initialized @Nullable Object>
And the validate method is defined as: public FrozenMap<@Nullable Object> validate(Map<String, @Nullable Object> arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException {
It is also worth noting that these maps will be read from only, so perhaps @Covariant on an interface method is what I should be using here?
The ingested maps are only ever being read by the inner code, they are not being modified.
The text was updated successfully, but these errors were encountered:
spacether
changed the title
Request for guidance, allowwance of nonnull in null, suggested path forward?
Request for guidance, allowance of nonnull in null, suggested path forward?
Dec 21, 2023
spacether
changed the title
Request for guidance, allowance of nonnull in null, suggested path forward?
Request for guidance, allowance of nonnull in nullable, suggested path forward?
Dec 21, 2023
Never mind, I was able to make this work by using a covariant type like: ? extends @Nullable Map<String, ? extends Nullable Map<String, ? extends Nullable String>>
Thanks for submitting an issue.
As explained in the instructions for submitting an issue at https://checkerframework.org/manual/#reporting-bugs, please include four pieces of information:
So I have this data structure:
Nullable Map<String, Nullable Map<String, Nullable String>>
There are 3 nullable locations
But one can also pas non-null data into these locations, so one needs to write nonnull versions also like:
Map<String, Map<String, String>>
But these are combinations, so the number of method signatures here is factorial, which is not great.
The context here is that I am ingesting json data with a known nullable shape, and am instantiating output classes containing that data this PR.
Is there a way for me to write fewer than factorial methods here which will cover all use cases?
Casting NonNull into Nullable would allow me to just use the the signature.
Is this covariance?
Also is there an active slack/discord/irc community for this tool?
I would prefer to ask there but only saw the mailing list mentioned as an option.
Apologies if this is the wrong place to ask this.
My real world example:
With this code invocation:
I get this error:
And the validate method is defined as:
public FrozenMap<@Nullable Object> validate(Map<String, @Nullable Object> arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException {
It is also worth noting that these maps will be read from only, so perhaps
@Covariant
on an interface method is what I should be using here?The ingested maps are only ever being read by the inner code, they are not being modified.
The text was updated successfully, but these errors were encountered: