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

io.streamthoughts.kafka.specs.model.V1SpecsObject Maven / Gradle / Ivy

Go to download

A command-line tool to help you automate the management of the configurations that live on your Apache Kafka clusters.

There is a newer version: 0.30.0
Show newest version
/*
 * Copyright 2021 StreamThoughts.
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.streamthoughts.kafka.specs.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

public class V1SpecsObject implements Serializable {

    private final V1ConfigMaps configMaps;

    private final List quotas;

    private final List topics;

    private final V1SecurityObject security;

    private final List brokers;

    /**
     * @param topics the {@link V1TopicObject} list.
     *
     * @return a new {@link V1SpecFile} instance.
     */
    public static V1SpecsObject withTopics(final List topics) {
        return new V1SpecsObject(
            Collections.emptyList(),
            topics,
            null,
            Collections.emptyList(),
            Collections.emptyList()
        );
    }

    /**
     * @param brokers the {@link V1BrokerObject} list.
     *
     * @return a new {@link V1SpecFile} instance.
     */
    public static V1SpecsObject withBrokers(final List brokers) {
        return new V1SpecsObject(
                brokers,
                Collections.emptyList(),
                null,
                Collections.emptyList(),
                Collections.emptyList()
        );
    }

    /**
     * @param security the {@link V1SecurityObject}.
     *
     * @return a new {@link V1SpecFile} instance.
     */
    public static V1SpecsObject withSecurity(final V1SecurityObject security) {
        return new V1SpecsObject(
                Collections.emptyList(),
                Collections.emptyList(),
                security,
                Collections.emptyList(),
                Collections.emptyList()
        );
    }

    /**
     * @param quotas the list {@link V1QuotaObject}.
     *
     * @return a new {@link V1SpecFile} instance.
     */
    public static V1SpecsObject withQuotas(final List quotas) {
        return new V1SpecsObject(
                Collections.emptyList(),
                Collections.emptyList(),
                null,
                Collections.emptyList(),
                quotas
        );
    }

    /**
     * Creates a new {@link V1SpecFile} instance.
     */
    public V1SpecsObject() {
        this(null, null, null, null, null);
    }

    /**
     * Creates a new {@link V1SpecFile} instance.
     *
     * @param brokers    the list of {@link V1BrokerObject}.
     * @param topics     the list of {@link V1TopicObject}.
     * @param security   the {@link V1SecurityObject}.
     * @param configMaps the list of {@link V1ConfigMap}.
     * @param quotas     the {@link V1QuotaObject}.
     */
    @JsonCreator
    public V1SpecsObject(@JsonProperty("brokers") final List brokers,
                         @JsonProperty("topics") final List topics,
                         @JsonProperty("security") final V1SecurityObject security,
                         @JsonProperty("config_maps") final List configMaps,
                         @JsonProperty("quotas") final List quotas) {
        this.brokers = Optional.ofNullable(brokers).orElse(Collections.emptyList());
        this.topics = Optional.ofNullable(topics).orElse(Collections.emptyList());
        this.quotas = Optional.ofNullable(quotas).orElse(Collections.emptyList());
        this.security = security;
        this.configMaps = new V1ConfigMaps(configMaps);
    }

    @JsonProperty
    public List topics() {
        return topics;
    }

    public V1SpecsObject topics(final List topics) {
        return new V1SpecsObject(brokers, topics, security, configMaps.all(), quotas);
    }

    @JsonProperty
    public Collection brokers() {
        return brokers;
    }

    @JsonProperty
    public Optional security() {
        return Optional.ofNullable(security);
    }

    public V1SpecsObject quotas(final List quotas) {
        return new V1SpecsObject(brokers, topics, security, configMaps.all(), quotas);
    }

    @JsonProperty
    public List quotas() {
        return quotas;
    }

    @JsonIgnore
    public V1ConfigMaps configMaps() {
        return configMaps;
    }

    @JsonIgnore
    public V1SpecsObject configMaps(final List configMaps) {
        return new V1SpecsObject(brokers, topics, security, configMaps, quotas);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        V1SpecsObject that = (V1SpecsObject) o;
        return Objects.equals(configMaps, that.configMaps) &&
               Objects.equals(topics, that.topics) &&
               Objects.equals(security, that.security) &&
               Objects.equals(brokers, that.brokers);
    }

    @Override
    public int hashCode() {
        return Objects.hash(configMaps, topics, security, brokers);
    }

    @Override
    public String toString() {
        return "V1SpecsObject{" +
                "configMaps=" + configMaps +
                ", topics=" + topics +
                ", security=" + security +
                ", brokers=" + brokers +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy