- restore generic signatures, scoped variables and missing code from original bytecode - remove decompiler artifacts and document classes, methods, fields and packages - restore resources, add Batik/BouncyCastle dependencies and build/runtime docs
206 lines
5.1 KiB
Java
206 lines
5.1 KiB
Java
package com.midm.model.device;
|
||
|
||
import com.midm.model.GeneralProfile;
|
||
import java.util.List;
|
||
import java.util.UUID;
|
||
import org.springframework.data.annotation.Transient;
|
||
import org.springframework.data.mongodb.core.mapping.Document;
|
||
|
||
/**
|
||
* 【MongoDB 文档实体】{@code DeviceGroup}
|
||
*
|
||
* 类职责:
|
||
* <ul>
|
||
* <li>作为 MongoDB 集合文档,承载该领域对象的持久化字段与索引。</li>
|
||
* <li>通过字段/依赖注入持有运行期状态,字段含义见下方“核心字段”。</li>
|
||
* </ul>
|
||
*
|
||
* 核心字段(按声明顺序):
|
||
* <ul>
|
||
* <li>{@code siteUuid}(UUID):用户所属站点 UUID</li>
|
||
* <li>{@code parentUuid}(UUID):父级UUID</li>
|
||
* <li>{@code order}(Integer):字段 order</li>
|
||
* <li>{@code deviceNumbers}(Integer):设备Numbers</li>
|
||
* <li>{@code children}(List<DeviceGroup>):子级</li>
|
||
* </ul>
|
||
*
|
||
* 持久化/框架标记:{@code @Document} 映射为 MongoDB 集合。
|
||
*
|
||
* 学习提示:先看字段与 @Field/@Indexed,再看对应 Service/Repository 如何构造查询条件。
|
||
*/
|
||
@Document
|
||
public class DeviceGroup extends GeneralProfile implements Comparable<Object> {
|
||
/**
|
||
* 用户所属站点 UUID。
|
||
*/
|
||
private UUID siteUuid;
|
||
/**
|
||
* 父级UUID。
|
||
*/
|
||
private UUID parentUuid;
|
||
/**
|
||
* 字段 order。
|
||
*/
|
||
private Integer order;
|
||
/**
|
||
* 设备Numbers;不持久化到 MongoDB,仅运行时使用。
|
||
*
|
||
* 注解:{@code @Transient}。
|
||
*/
|
||
@Transient
|
||
private Integer deviceNumbers;
|
||
/**
|
||
* 子级。
|
||
*/
|
||
private List<DeviceGroup> children;
|
||
|
||
/**
|
||
* 构造 {@code DeviceGroup} 实例。
|
||
* 使用默认字段值,后续通常由 Spring/Mongo 或调用方填充。
|
||
*/
|
||
public DeviceGroup() {
|
||
this.deviceNumbers = 0;
|
||
}
|
||
|
||
/**
|
||
* 构造 {@code DeviceGroup} 实例。
|
||
*
|
||
* @param uuid 对象 UUID({@code UUID})
|
||
*/
|
||
public DeviceGroup(UUID uuid) {
|
||
this.uuid = uuid;
|
||
}
|
||
|
||
/**
|
||
* 构造 {@code DeviceGroup} 实例。
|
||
*
|
||
* @param siteUuid 站点 UUID({@code UUID})
|
||
* @param parentUuid 参数 {@code parentUuid}({@code UUID})
|
||
* @param name 参数 {@code name}({@code String})
|
||
*/
|
||
public DeviceGroup(UUID siteUuid, UUID parentUuid, String name) {
|
||
this.init();
|
||
this.siteUuid = siteUuid;
|
||
this.parentUuid = parentUuid;
|
||
this.setName(name);
|
||
}
|
||
|
||
/**
|
||
* 获取 {@code siteUuid}。
|
||
* @return UUID
|
||
*/
|
||
public UUID getSiteUuid() {
|
||
return this.siteUuid;
|
||
}
|
||
|
||
/**
|
||
* 设置 {@code siteUuid}。
|
||
*
|
||
* @param siteUuid 站点 UUID({@code UUID})
|
||
*/
|
||
public void setSiteUuid(UUID siteUuid) {
|
||
this.siteUuid = siteUuid;
|
||
}
|
||
|
||
/**
|
||
* 获取 {@code parentUuid}。
|
||
* @return UUID
|
||
*/
|
||
public UUID getParentUuid() {
|
||
return this.parentUuid;
|
||
}
|
||
|
||
/**
|
||
* 设置 {@code parentUuid}。
|
||
*
|
||
* @param parentUuid 参数 {@code parentUuid}({@code UUID})
|
||
*/
|
||
public void setParentUuid(UUID parentUuid) {
|
||
this.parentUuid = parentUuid;
|
||
}
|
||
|
||
/**
|
||
* 获取 {@code order}。
|
||
* @return 数量/长度
|
||
*/
|
||
public Integer getOrder() {
|
||
return this.order;
|
||
}
|
||
|
||
/**
|
||
* 设置 {@code order}。
|
||
*
|
||
* @param order 参数 {@code order}({@code Integer})
|
||
*/
|
||
public void setOrder(Integer order) {
|
||
this.order = order;
|
||
}
|
||
|
||
/**
|
||
* 获取 {@code deviceNumbers}。
|
||
* @return 数量/长度
|
||
*/
|
||
public Integer getDeviceNumbers() {
|
||
return this.deviceNumbers;
|
||
}
|
||
|
||
/**
|
||
* 设置 {@code deviceNumbers}。
|
||
*
|
||
* @param numbers 参数 {@code numbers}({@code Integer})
|
||
*/
|
||
public void setDeviceNumbers(Integer numbers) {
|
||
this.deviceNumbers = numbers == null ? 0 : numbers;
|
||
}
|
||
|
||
/**
|
||
* 获取 {@code children}。
|
||
* @return 设备分组列表,可能为空
|
||
*/
|
||
public List<DeviceGroup> getChildren() {
|
||
return this.children;
|
||
}
|
||
|
||
/**
|
||
* 设置 {@code children}。
|
||
*
|
||
* @param children 参数 {@code children}({@code List<DeviceGroup>})
|
||
*/
|
||
public void setChildren(List<DeviceGroup> children) {
|
||
this.children = children;
|
||
}
|
||
|
||
/**
|
||
* 比较当前对象与另一个对象是否相等。
|
||
*
|
||
* @param uuid 对象 UUID({@code UUID})
|
||
* @return 条件成立返回 {@code true},否则返回 {@code false}
|
||
*/
|
||
public boolean equals(UUID uuid) {
|
||
return this.uuid != null && this.uuid.equals(uuid);
|
||
}
|
||
|
||
/**
|
||
* 按业务字段比较两个对象的顺序。
|
||
*
|
||
* 实现要点:包含 3 个条件分支、0 个循环。
|
||
*
|
||
* @param target 参数 {@code target}({@code Object})
|
||
* @return 数量/长度
|
||
*/
|
||
public int compareTo(Object target) {
|
||
UUID targetUuid = null;
|
||
if (target instanceof UUID) {
|
||
targetUuid = (UUID)target;
|
||
} else if (target instanceof DeviceGroup) {
|
||
targetUuid = ((DeviceGroup)target).getUuid();
|
||
}
|
||
|
||
if (targetUuid == null) {
|
||
return this.uuid == null ? 0 : 1;
|
||
} else {
|
||
return this.uuid == null ? -1 : this.uuid.compareTo(targetUuid);
|
||
}
|
||
}
|
||
}
|