Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tree.node;
- import rbvs.product.CompositeProduct;
- import rbvs.product.IProduct;
- import rbvs.product.Product;
- public class ProductTreeNode extends GenericTreeNode<IProduct> { // Eldira 11815163
- private ProductTreeNode(CompositeProduct value) {
- super(value.getName(), value);
- }
- public ProductTreeNode(IProduct value) {
- this(value.getName(), value);
- }
- public ProductTreeNode(String label, IProduct value) {
- super(label, value);
- initialize(value);
- }
- private void initialize(IProduct item) {
- if (item instanceof CompositeProduct) {
- CompositeProduct compositeProduct = (CompositeProduct) item;
- for (Product product : compositeProduct.getProducts()) {
- this.getChildren().add(new ProductTreeNode(product));
- }
- } else {
- this.getChildren().clear();
- }
- }
- public ProductTreeNode deepCopy() {
- return (ProductTreeNode) super.deepCopy();
- }
- }
Add Comment
Please, Sign In to add comment