lti-provider/src/main/java/ru/oa2/lti/domain/valueobject/Script.java

32 lines
775 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ru.oa2.lti.domain.valueobject;
import java.util.Objects;
import ru.oa2.lti.domain.valueobject.ScriptType;
/**
* Value Object для скрипта с типом и содержимым
*/
public record Script(ScriptType type, String content) {
public Script {
Objects.requireNonNull(type, "Script type cannot be null");
Objects.requireNonNull(content, "Script content cannot be null");
}
public static Script of(ScriptType type, String content) {
return new Script(type, content);
}
public static Script empty(ScriptType type) {
return new Script(type, "");
}
public boolean isEmpty() {
return content.isBlank();
}
public boolean isExecutable() {
return !isEmpty();
}
}