The filter of the parent array?

Guys, Hello!
Have the parent array is an array with nested array. You need to compare the array input and a nested array if they are given the conditions are the same, then to remove the object from the parent array. Here is the code, but it crookedly works.

public void sort(List<productcomponentsresponse> filterData) {
 productsList = new ArrayList<>(mSortModels);
 for (ProductComponentsResponse component : filterData) {
 String componentId = component.getId();
 int componentState = component.getState();
 Iterator<productresponse> iterator = productsList.iterator();
 while (iterator.hasNext()) {
 ProductResponse next = iterator.next();
 for (ProductComponentsResponse productComponentsResponse : next.getProductComponents()) {
 boolean containComponent = productComponentsResponse.getId().contains(componentId);
 if (componentState == ProductComponentsResponse.FilterState.NONE) {
continue;
 } 
 if (componentState == ProductComponentsResponse.FilterState.SELECTED) {
 if (!containComponent) {
 Log.d("component", String.valueOf(productComponentsResponse.getId()));
 Log.d("componentState", String.valueOf(componentState));
iterator.remove();
break;
}
 } else if (componentState == ProductComponentsResponse.FilterState.UNSELECTED) {
 if (containComponent) {
 Log.d("_component", String.valueOf(productComponentsResponse.getId()));
 Log.d("_componentState", String.valueOf(componentState));
iterator.remove();
break;
}
}
}
}
}
notifyDataSetChanged();
 }</productresponse></productcomponentsresponse>
June 14th 19 at 20:46

Find more questions by tags Android