Skip to content

Commit

Permalink
remove legacy, contextless 'Endec.of'
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Apr 28, 2024
1 parent 5b91689 commit 426f545
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/main/java/io/wispforest/owo/serialization/Endec.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ default <E> T decodeFully(Function<E, Deserializer<E>> deserializerConstructor,

// --- Serializer Primitives ---

Endec<Void> VOID = Endec.of((serializer, unused) -> {}, deserializer -> null);
Endec<Void> VOID = Endec.of((ctx, serializer, unused) -> {}, (ctx, deserializer) -> null);

Endec<Boolean> BOOLEAN = Endec.of((ctx, serializer, value) -> serializer.writeBoolean(ctx, value), (ctx, deserializer) -> deserializer.readBoolean(ctx));
Endec<Byte> BYTE = Endec.of((ctx, serializer, value) -> serializer.writeByte(ctx, value), (ctx, deserializer) -> deserializer.readByte(ctx));
Expand Down Expand Up @@ -143,20 +143,6 @@ default Endec<Optional<T>> optionalOf() {

// --- Constructors ---

static <T> Endec<T> of(BiConsumer<Serializer<?>, T> encode, Function<Deserializer<?>, T> decode) {
return new Endec<>() {
@Override
public void encode(SerializationContext ctx, Serializer<?> serializer, T value) {
encode.accept(serializer, value);
}

@Override
public T decode(SerializationContext ctx, Deserializer<?> deserializer) {
return decode.apply(deserializer);
}
};
}

static <T> Endec<T> of(Encoder<T> encode, Decoder<T> decode) {
return new Endec<>() {
@Override
Expand Down

0 comments on commit 426f545

Please sign in to comment.