办学质量监测教学评价系统
ageer
2025-03-31 412e8bdc105595889231417143b411ada3c761bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.ruoyi.chat.domain;
 
 
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
 
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
 
 
public class DomainObject implements Serializable {
    @Getter
    @Setter
    @ApiModelProperty("ID")
    protected String id;
 
    @Setter
    protected Map<String, Object> properties; // 扩展属性,仅支持基本类型
 
    @JsonIgnore
    private final transient Object lock = new Object();
 
    public void sleep() throws InterruptedException {
        synchronized (this.lock) {
            this.lock.wait();
        }
    }
 
    public void awake() {
        synchronized (this.lock) {
            this.lock.notifyAll();
        }
    }
 
    public DomainObject setProperty(String name, Object value) {
        getProperties().put(name, value);
        return this;
    }
 
    public DomainObject removeProperty(String name) {
        getProperties().remove(name);
        return this;
    }
 
    public Object getProperty(String name) {
        return getProperties().get(name);
    }
 
    @SuppressWarnings("unchecked")
    public <T> T getPropertyGeneric(String name) {
        return (T) getProperty(name);
    }
 
    public <T> T getProperty(String name, Class<T> clz) {
        return getProperty(name, clz, null);
    }
 
    public <T> T getProperty(String name, Class<T> clz, T defaultValue) {
        Object value = getProperty(name);
        return value == null ? defaultValue : clz.cast(value);
    }
 
    public Map<String, Object> getProperties() {
        if (this.properties == null) {
            this.properties = new HashMap<>();
        }
        return this.properties;
    }
}