obj is accessed as if it is non-null, but is marked as @Nullable!
37
38 node.node("index").set(obj.getIndex());
39 node.node("item").set(itemStack);
40 node.node("action").set(obj.getItemAction());41 }
42}
obj is accessed as if it is non-null, but is marked as @Nullable!
35 final SerializableUmbrellaItem obj, final ConfigurationNode node) throws SerializationException {
36 final ItemStack itemStack = obj.getItemStack();
37
38 node.node("index").set(obj.getIndex());39 node.node("item").set(itemStack);
40 node.node("action").set(obj.getItemAction());
41 }
obj is accessed as if it is non-null, but is marked as @Nullable!
33 @Override
34 public void serialize(final Type type, @Nullable
35 final SerializableUmbrellaItem obj, final ConfigurationNode node) throws SerializationException {
36 final ItemStack itemStack = obj.getItemStack();37
38 node.node("index").set(obj.getIndex());
39 node.node("item").set(itemStack);
obj is accessed as if it is non-null, but is marked as @Nullable!
29 public void serialize(final Type type, @Nullable
30 final ItemStack obj, final ConfigurationNode node) throws SerializationException {
31 node.node("material").set(obj.getType());
32 node.node("durability").set(obj.getDurability());33 node.node("meta").set(obj.getItemMeta());
34 }
35}
obj is accessed as if it is non-null, but is marked as @Nullable!
30 final ItemStack obj, final ConfigurationNode node) throws SerializationException {
31 node.node("material").set(obj.getType());
32 node.node("durability").set(obj.getDurability());
33 node.node("meta").set(obj.getItemMeta());34 }
35}
obj is accessed as if it is non-null, but is marked as @Nullable!
28 @Override
29 public void serialize(final Type type, @Nullable
30 final ItemStack obj, final ConfigurationNode node) throws SerializationException {
31 node.node("material").set(obj.getType());32 node.node("durability").set(obj.getDurability());
33 node.node("meta").set(obj.getItemMeta());
34 }
Description
This parameter is always used as if it is non-null, but the parameter may be null when the usage occurs.
Bad Practice
public void doWork(MyClass myClass) {
// ...
// Dereference without a null check.
myClass.myField = "value";
// ...
}
// ...
MyClass nullable;
// ...
if (condition) nullable = new MyClass();
else nullable = null;
// ...
doWork(nullable); // If nullable is null, we will get an NPE
Recommended
If you require that the parameter should never be null, consider changing the annotation to @NonNull
or an equivalent annotation to indicate that the method expects the value to be non-null.
If the variable is likely to be null, consider performing a null check before using the variable.