Project

General

Profile

Revision 8c7285ac

ID8c7285ac1d02101023cef3c9683f3293b8143dcf
Parent dc572c3e
Child 1ed092db

Added by Andreas Müller over 1 year ago

fix asList(Recursive) methods

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/TermNode.java
558 558
     * term of this node and then recursively the list
559 559
     * of all children and grandChildren
560 560
     */
561
    public Collection<? extends T> asTermListRecursive(List<T> terms) {
561
    public Collection<? extends T> asTermListRecursive() {
562
        List<T> result = new ArrayList<>();
562 563
        T term = this.getTerm();
563 564
        if(term != null){
564
            terms.add(term);
565
            result.add(term);
565 566
        }
566 567
        for(TermNode<T> childNode : this.getChildNodes()){
567
            terms.addAll(childNode.asTermListRecursive(terms));
568
            result.addAll(childNode.asTermListRecursive());
568 569
        }
569
        return terms;
570
        return result;
570 571
    }
571 572

  
572 573
//*********************** CLONE ********************************************************/
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/TermTree.java
238 238
        List<T> result = new ArrayList<>();
239 239
        for (TermNode<T> node : getRootChildren()){
240 240
            result.add(node.getTerm());
241
            result.addAll(node.asTermListRecursive(result));
241
            for (TermNode<T> child : node.getChildNodes()){
242
                result.addAll(child.asTermListRecursive());
243
            }
242 244
        }
243 245
        return result;
244 246
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)