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

no.nav.familie.topic.Topic Maven / Gradle / Ivy

There is a newer version: 5.1_20200117132228_47cdf2f
Show newest version
package no.nav.familie.topic;

import java.util.Objects;

import org.apache.kafka.common.serialization.Serde;

@SuppressWarnings("rawtypes")
public class Topic {

    private final String topic;
    private final Serde serdeKey;
    private final Serde serdeValue;

     Topic(String topic, Serde serdeKey, Serde serdeValue) {
        Objects.requireNonNull(topic, "topic");
        Objects.requireNonNull(serdeKey, "serdeKey");
        Objects.requireNonNull(serdeValue, "serdeValue");
        this.topic = topic;
        this.serdeKey = serdeKey;
        this.serdeValue = serdeValue;
    }

    public String getTopic() {
        return topic;
    }

    public String getTopicWithEnv(String env) {
        Environment environment = Environment.valueOf(env);
        return topic + "-" + environment.name();
    }

    public Serde getSerdeKey() {
        return serdeKey;
    }

    public Serde getSerdeValue() {
        return serdeValue;
    }

    /**
     * Genererer clientId basert på standard definert på https://confluence.adeo.no/display/AURA/Kafka#Kafka-TopicogSikkerhetskonfigurasjon
     *
     * @return clientId
     */
    public String getProducerClientId() {
        return "KP-" + topic;
    }

    /**
     * Genererer clientId basert på standard definert på https://confluence.adeo.no/display/AURA/Kafka#Kafka-TopicogSikkerhetskonfigurasjon
     *
     * @return clientId
     */
    public String getConsumerClientId() {
        return "KC-" + topic;
    }

    @Override
    public String toString() {
        return "Topic{" +
                "topic='" + topic + '\'' +
                ", serdeKey=" + serdeKey +
                ", serdeValue=" + serdeValue +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy