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

io.quarkus.pulsar.SchemaProviderRecorder Maven / Gradle / Ivy

There is a newer version: 3.15.0
Show newest version
package io.quarkus.pulsar;

import java.nio.ByteBuffer;
import java.util.function.Supplier;

import org.apache.pulsar.client.api.Schema;

import io.quarkus.pulsar.schema.BufferSchema;
import io.quarkus.pulsar.schema.JsonArraySchema;
import io.quarkus.pulsar.schema.JsonObjectSchema;
import io.quarkus.pulsar.schema.ObjectMapperSchema;
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;

@Recorder
public class SchemaProviderRecorder {

    public  Supplier> createJsonSchema(Class type) {
        return new Supplier>() {
            @Override
            public Schema get() {
                return Schema.JSON(type);
            }
        };
    };

    public  Supplier> createAvroSchema(Class type) {
        return new Supplier>() {
            @Override
            public Schema get() {
                return Schema.AVRO(type);
            }
        };
    };

    public Supplier> createProtoBufSchema(Class type) {
        return new Supplier>() {
            @Override
            public Schema get() {
                return Schema.PROTOBUF((Class) type);
            }
        };
    }

    public  RuntimeValue> createObjectMapperSchema(Class type) {
        return new RuntimeValue<>(ObjectMapperSchema.of(type));
    }

    public RuntimeValue> createBufferSchema() {
        return new RuntimeValue<>(BufferSchema.INSTANCE);
    }

    public RuntimeValue> createJsonObjectSchema() {
        return new RuntimeValue<>(JsonObjectSchema.INSTANCE);
    }

    public RuntimeValue> createJsonArraySchema() {
        return new RuntimeValue<>(JsonArraySchema.INSTANCE);
    }

    public RuntimeValue> createByteBufferSchema() {
        return new RuntimeValue<>(Schema.BYTEBUFFER);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy