EldiraSesto

CategoryTreeNode

May 20th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package tree.node;
  2.  
  3. public class CategoryTreeNode<NODETYPE, CATEGORY> extends GenericTreeNode<NODETYPE> { //Eldira 11815163
  4.     private CATEGORY category;
  5.  
  6.     public CategoryTreeNode(CATEGORY category) {
  7.         super(category.toString(), null);
  8.         this.category = category;
  9.     }
  10.  
  11.     public CATEGORY getCategory() {
  12.         return category;
  13.     }
  14.    
  15.     public CategoryTreeNode<NODETYPE, CATEGORY> deepCopy()
  16.     {
  17.            
  18.             CategoryTreeNode<NODETYPE,CATEGORY> clone = new CategoryTreeNode<>((CATEGORY) this.getLabel());
  19.            
  20.             if(!this.isLeaf())
  21.             {
  22.                 for(ITreeNode<NODETYPE> node:this.getChildren())
  23.                 {
  24.                     clone.getChildren().add(node.deepCopy());
  25.                 }
  26.             }
  27.             return clone;
  28.      }
  29.    
  30.     public String getLabel() {
  31.         return super.getLabel();
  32.     }
  33.    
  34.     public NODETYPE nodeValue() {
  35.         return null;
  36.     }
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment