Revision 7c5f89b4
Added by Katja Luther over 3 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermNodeDto.java | ||
---|---|---|
204 | 204 |
public int getIndex(TermNodeDto nodeDto) { |
205 | 205 |
int index = 0; |
206 | 206 |
for (TermNodeDto child: children){ |
207 |
if (child.getUuid().equals(nodeDto.getUuid())){ |
|
208 |
return index; |
|
207 |
if (child != null){ |
|
208 |
if (child.getUuid().equals(nodeDto.getUuid())){ |
|
209 |
return index; |
|
210 |
} |
|
209 | 211 |
} |
210 | 212 |
index++; |
211 | 213 |
} |
... | ... | |
228 | 230 |
} |
229 | 231 |
|
230 | 232 |
|
231 |
public boolean removeChild(TermNodeDto nodeDto){ |
|
233 |
public boolean removeChild(TermNodeDto nodeDto, boolean doRecursive){
|
|
232 | 234 |
int index = this.getIndex(nodeDto); |
233 | 235 |
if (index > -1){ |
234 | 236 |
this.getChildren().remove(index); |
235 | 237 |
return true; |
236 |
}else if (this.getChildren() != null && !this.getChildren().isEmpty()){ |
|
238 |
}else if (doRecursive && this.getChildren() != null && !this.getChildren().isEmpty()){
|
|
237 | 239 |
for (TermNodeDto child: children){ |
238 |
boolean result = child.removeChild(nodeDto); |
|
240 |
boolean result = child.removeChild(nodeDto, doRecursive);
|
|
239 | 241 |
if (result){ |
240 | 242 |
return true; |
241 | 243 |
} |
Also available in: Unified diff
ref #8774: avoid NPE in termNodeDto