All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.auties.protobuf.builtin.ProtobufFutureMixin Maven / Gradle / Ivy

The newest version!
package it.auties.protobuf.builtin;

import it.auties.protobuf.annotation.ProtobufDefaultValue;
import it.auties.protobuf.annotation.ProtobufDeserializer;
import it.auties.protobuf.annotation.ProtobufSerializer;

import java.util.concurrent.CompletableFuture;

import static it.auties.protobuf.annotation.ProtobufDeserializer.BuilderBehaviour.OVERRIDE;

@SuppressWarnings("unused")
public class ProtobufFutureMixin {
    @ProtobufDefaultValue
    public static  CompletableFuture newCompletableFuture() {
        return CompletableFuture.completedFuture(null);
    }

    @ProtobufDeserializer(builderBehaviour = OVERRIDE)
    public static  CompletableFuture ofNullable(T value) {
        return CompletableFuture.completedFuture(value);
    }

    @ProtobufSerializer
    public static  T toValue(CompletableFuture future) {
        return future == null ? null : future.getNow(null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy