My code below is working but I am searching for performance and improvement.
It consists of looping my PartList
elements and check if my string parameter orginalDataStringList
contains the elements on label string for each Part
element.
private boolean excludeAllInformationVariation(List<String> orginalDataStringList, PartList parts) {
for (Part part : parts) {
List<String> listTemp = new ArrayList<String>();
listTemp.addAll(orginalDataStringList);
if (!part.getOptLogic().isLabelNullOrEmpty()) {
String[] dataArrays = part.getOptLogic().getLabel().split("( )");
for (String data : dataArrays) {
listTemp.remove(data);
}
} else {
return false;
}
if (!listTemp.isEmpty()) {
return false;
}
}
return true;
}
public class PartList extends ArrayList<Part> {
public PartList() {
//Empty constructor
}
}
public class Part {
private Logic optLogic;
public Logic getOptLogic() { return optLogic; }
public void setOptLogic(Logic optLogic) { this.optLogic = optLogic; }
}
public class Logic {
private String label;
public String getLabel() { return label; }
public void setLabel(String label) { this.label = label; }
}
public boolean isLabelNullOrEmpty() {
return (this.getLabel() == null || this.getLabel().isEmpty()) ? true : false;
}
return (condition) ? true : false;
don't do that! Just return the condition! \$\endgroup\$