办学质量监测教学评价系统
ageer
2024-04-01 dea23f13ef2d4918080ce8aeee1ee908188cdb19
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
73
74
package com.xmzs.midjourney.support;
 
import cn.hutool.core.text.CharSequenceUtil;
import com.xmzs.midjourney.Constants;
import com.xmzs.midjourney.enums.TaskAction;
import com.xmzs.midjourney.enums.TaskStatus;
import lombok.Data;
import lombok.experimental.Accessors;
 
import java.util.Set;
import java.util.function.Predicate;
 
 
@Data
@Accessors(chain = true)
public class TaskCondition implements Predicate<Task> {
    private String id;
 
    private Set<TaskStatus> statusSet;
    private Set<TaskAction> actionSet;
 
    private String prompt;
    private String promptEn;
    private String description;
 
    private String finalPromptEn;
    private String messageId;
    private String messageHash;
    private String progressMessageId;
    private String nonce;
 
    @Override
    public boolean test(Task task) {
        if (task == null) {
            return false;
        }
        if (CharSequenceUtil.isNotBlank(this.id) && !this.id.equals(task.getId())) {
            return false;
        }
        if (this.statusSet != null && !this.statusSet.isEmpty() && !this.statusSet.contains(task.getStatus())) {
            return false;
        }
        if (this.actionSet != null && !this.actionSet.isEmpty() && !this.actionSet.contains(task.getAction())) {
            return false;
        }
        if (CharSequenceUtil.isNotBlank(this.prompt) && !this.prompt.equals(task.getPrompt())) {
            return false;
        }
        if (CharSequenceUtil.isNotBlank(this.promptEn) && !this.promptEn.equals(task.getPromptEn())) {
            return false;
        }
        if (CharSequenceUtil.isNotBlank(this.description) && !CharSequenceUtil.contains(task.getDescription(), this.description)) {
            return false;
        }
 
        if (CharSequenceUtil.isNotBlank(this.finalPromptEn) && !this.finalPromptEn.equals(task.getProperty(Constants.TASK_PROPERTY_FINAL_PROMPT))) {
            return false;
        }
        if (CharSequenceUtil.isNotBlank(this.messageId) && !this.messageId.equals(task.getProperty(Constants.TASK_PROPERTY_MESSAGE_ID))) {
            return false;
        }
        if (CharSequenceUtil.isNotBlank(this.messageHash) && !this.messageHash.equals(task.getProperty(Constants.TASK_PROPERTY_MESSAGE_HASH))) {
            return false;
        }
        if (CharSequenceUtil.isNotBlank(this.progressMessageId) && !this.progressMessageId.equals(task.getProperty(Constants.TASK_PROPERTY_PROGRESS_MESSAGE_ID))) {
            return false;
        }
        if (CharSequenceUtil.isNotBlank(this.nonce) && !this.nonce.equals(task.getProperty(Constants.TASK_PROPERTY_NONCE))) {
            return false;
        }
        return true;
    }
 
}