package com.lxzn.framework.domain.nc.ext; import com.fasterxml.jackson.annotation.JsonIgnore; import com.lxzn.framework.domain.nc.DeviceGroup; import com.lxzn.framework.utils.BeanMapper; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.util.List; @Data @NoArgsConstructor @EqualsAndHashCode(callSuper = false) public class DeviceGroupExt extends DeviceGroup { private DeviceGroupExt parent; private List children; @JsonIgnore private String userId; public boolean hasChild() { boolean b = true; if(this.getChildren() == null || this.getChildren().size() < 1) { b = false; } return b; } public List getAllChildren(List groups) { if(this.hasChild()) { List extList = this.getChildren(); for(DeviceGroupExt ext : extList) { groups = ext.getAllChildren(groups); } DeviceGroup group = new DeviceGroup(); BeanMapper.copy(this, group); groups.add(group); }else { DeviceGroup group = new DeviceGroup(); BeanMapper.copy(this, group); groups.add(group); } return groups; } }