XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEServerManager

【Java】我的世界XFE服务器管理器

公开
关注 0 Fork 0 Star 0
UTF-8
package com.xfestudio.xfeservermanager.core.trigger;

import java.time.Instant;
import java.util.Objects;
import java.util.UUID;

/** A switchable namespace for related triggers. */
public record TriggerGroup(UUID id, String name, String description, boolean enabled,
                           long revision, String createdBy, Instant createdAt, Instant updatedAt,
                           boolean migrated) {
    public TriggerGroup {
        Objects.requireNonNull(id, "id");
        name = require(name, "name", 120);
        description = description == null ? "" : description.strip();
        if (description.length() > 500) throw new IllegalArgumentException("description is too long");
        createdBy = require(createdBy, "createdBy", 120);
        Objects.requireNonNull(createdAt, "createdAt");
        Objects.requireNonNull(updatedAt, "updatedAt");
        if (revision < 0) throw new IllegalArgumentException("revision must not be negative");
    }

    private static String require(String value, String field, int maximum) {
        if (value == null || value.isBlank()) throw new IllegalArgumentException(field + " is required");
        String normalized = value.strip();
        if (normalized.length() > maximum) throw new IllegalArgumentException(field + " is too long");
        return normalized;
    }
}