on ‎2019 Jun 19 10:30 PM
While creating Integration object for VariantCategory and VariantValueCategory I am getting NullPointerException.
Logic written in Interceptor :
VariantValueCategoryModel currentCategory;
List siblings = variantCategory.getCategories();
if (!siblings.contains(currentCategory)) { sequences.add(currentCategory.getSequence()); }
Now if you see the above code, siblings must be null when you will try to create the first VariantValueCategory inside a VariantCategory. In that case null.contains() will throw exception.
How will I handle this or more correctly what I am supposed to do ?
Please help.
Request clarification before answering.
I'm assuming you're talking about a custom code. I don't fully understand your business case, but in terms of a technical solution here is what you can do:
List siblings = variantCategory.getCategories != null
? variantCategory.getCategories
: Collections.emptyList()
Another option would be:
if (siblings == null || !siblings.contains(currentCategory)) { ... }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.