1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 18:48:20 +08:00

feat: Make function interface "serializable"

This commit is contained in:
2025-09-10 08:22:37 +08:00
parent 5df66e59d2
commit fcb4ced610
6 changed files with 16 additions and 6 deletions
@@ -2,8 +2,10 @@ package cc.carm.lib.configuration.function;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
@FunctionalInterface @FunctionalInterface
public interface DataConsumer<T> { public interface DataConsumer<T> extends Serializable {
void accept(@NotNull T data) throws Exception; void accept(@NotNull T data) throws Exception;
@@ -4,10 +4,11 @@ package cc.carm.lib.configuration.function;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
@FunctionalInterface @FunctionalInterface
public interface DataFunction<T, R> { public interface DataFunction<T, R> extends Serializable {
@NotNull R handle(@NotNull T data) throws Exception; @NotNull R handle(@NotNull T data) throws Exception;
@@ -2,8 +2,10 @@ package cc.carm.lib.configuration.function;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.Serializable;
@FunctionalInterface @FunctionalInterface
public interface DataValidator<T> { public interface DataValidator<T> extends Serializable {
void validate(@Nullable T value) throws Exception; void validate(@Nullable T value) throws Exception;
@@ -4,8 +4,10 @@ package cc.carm.lib.configuration.function;
import cc.carm.lib.configuration.source.ConfigurationHolder; import cc.carm.lib.configuration.source.ConfigurationHolder;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
@FunctionalInterface @FunctionalInterface
public interface ValueComposer<T, U> { public interface ValueComposer<T, U> extends Serializable {
/** /**
* Accept the value and the data, and then compose the value. * Accept the value and the data, and then compose the value.
@@ -7,10 +7,11 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
@FunctionalInterface @FunctionalInterface
public interface ValueHandler<T, R> { public interface ValueHandler<T, R> extends Serializable {
@Nullable R handle(@NotNull ConfigurationHolder<?> holder, @NotNull T data) throws Exception; @Nullable R handle(@NotNull ConfigurationHolder<?> holder, @NotNull T data) throws Exception;
@@ -4,8 +4,10 @@ import cc.carm.lib.configuration.source.ConfigurationHolder;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.Serializable;
@FunctionalInterface @FunctionalInterface
public interface ValueValidator<T> { public interface ValueValidator<T> extends Serializable {
void validate(@NotNull ConfigurationHolder<?> holder, @Nullable T value) throws Exception; void validate(@NotNull ConfigurationHolder<?> holder, @Nullable T value) throws Exception;