Coverage Report - org.jtheque.primary.view.impl.models.tree.Category
 
Classes in this File Line Coverage Branch Coverage Complexity
Category
0 %
0/19
0 %
0/2
1.083
 
 1  
 package org.jtheque.primary.view.impl.models.tree;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import javax.swing.Icon;
 20  
 import java.util.ArrayList;
 21  
 import java.util.List;
 22  
 
 23  
 /**
 24  
  * Represents a category of a tree model.
 25  
  *
 26  
  * @author Baptiste Wicht
 27  
  */
 28  
 public final class Category implements TreeElement {
 29  
         private final List<TreeElement> elements;
 30  
         private final String name;
 31  
 
 32  
         /**
 33  
          * Constructs a new category.
 34  
          *
 35  
          * @param name The name of element
 36  
          */
 37  
         public Category(String name){
 38  0
                 super();
 39  
 
 40  0
                 this.name = name;
 41  0
                 elements = new ArrayList<TreeElement>(20);
 42  0
         }
 43  
 
 44  
         @Override
 45  
         public String getElementName(){
 46  0
                 return name;
 47  
         }
 48  
 
 49  
         @Override
 50  
         public Icon getIcon(){
 51  0
                 return null;
 52  
         }
 53  
 
 54  
         @Override
 55  
         public boolean isRoot(){
 56  0
                 return false;
 57  
         }
 58  
 
 59  
         @Override
 60  
         public boolean isCategory(){
 61  0
                 return true;
 62  
         }
 63  
 
 64  
         @Override
 65  
         public boolean isLeaf(){
 66  0
                 return false;
 67  
         }
 68  
 
 69  
         @Override
 70  
         public TreeElement getChild(int index){
 71  0
                 return elements.get(index);
 72  
         }
 73  
 
 74  
         @Override
 75  
         public int getChildCount(){
 76  0
                 return elements.size();
 77  
         }
 78  
 
 79  
         @Override
 80  
         public int indexOf(TreeElement element){
 81  0
                 return elements.indexOf(element);
 82  
         }
 83  
 
 84  
         @Override
 85  
         public void add(TreeElement element){
 86  0
                 elements.add(element);
 87  0
         }
 88  
 
 89  
         @Override
 90  
         public void addAll(Iterable<? extends TreeElement> elements){
 91  0
                 for (TreeElement element : elements){
 92  0
                         add(element);
 93  
                 }
 94  0
         }
 95  
 
 96  
         @Override
 97  
         public void clear(){
 98  0
                 elements.clear();
 99  0
         }
 100  
 }