package com.xfestudio.xfeservermanager.api.policy;
import com.xfestudio.xfeservermanager.api.util.ApiChecks;
import com.xfestudio.xfeservermanager.api.command.CommandNames;
import java.util.Set;
public record CommandConstraints(
SelectorConstraint selector,
ItemConstraint item,
Set<String> allowedFunctionIds,
boolean denyUnlistedFunctions
) {
public CommandConstraints {
if (selector == null) {
throw new NullPointerException("selector");
}
if (item == null) {
throw new NullPointerException("item");
}
allowedFunctionIds = ApiChecks.immutableLowercaseSet(allowedFunctionIds, "allowedFunctionIds").stream()
.map(CommandNames::canonicalize)
.collect(java.util.stream.Collectors.toUnmodifiableSet());
}
public static CommandConstraints unrestricted() {
return new CommandConstraints(
SelectorConstraint.unrestricted(), ItemConstraint.unrestricted(), Set.of(), false);
}
}
package com.xfestudio.xfeservermanager.api.policy;
import com.xfestudio.xfeservermanager.api.util.ApiChecks;
import com.xfestudio.xfeservermanager.api.command.CommandNames;
import java.util.Set;
public record CommandConstraints(
SelectorConstraint selector,
ItemConstraint item,
Set<String> allowedFunctionIds,
boolean denyUnlistedFunctions
) {
public CommandConstraints {
if (selector == null) {
throw new NullPointerException("selector");
}
if (item == null) {
throw new NullPointerException("item");
}
allowedFunctionIds = ApiChecks.immutableLowercaseSet(allowedFunctionIds, "allowedFunctionIds").stream()
.map(CommandNames::canonicalize)
.collect(java.util.stream.Collectors.toUnmodifiableSet());
}
public static CommandConstraints unrestricted() {
return new CommandConstraints(
SelectorConstraint.unrestricted(), ItemConstraint.unrestricted(), Set.of(), false);
}
}