cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to handle Variant Value Category sibling validation exception in Integration Object.

former_member678491
Discoverer
0 Likes
484

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Slava
Product and Topic Expert
Product and Topic Expert
0 Likes

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)) { ... }