package de.assecutor.votianlt.messaging.plugin;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * Metadata about a messaging plugin.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PluginMetadata {

    /**
     * Plugin name
     */
    private String name;

    /**
     * Plugin version
     */
    private String version;

    /**
     * Plugin description
     */
    private String description;

    /**
     * Plugin author/vendor
     */
    private String author;

    /**
     * Supported features
     */
    @Builder.Default
    private List<String> supportedFeatures = new ArrayList<>();

    /**
     * Whether the plugin supports wildcards in topic patterns
     */
    @Builder.Default
    private boolean supportsWildcards = false;

    /**
     * Whether the plugin supports retained messages
     */
    @Builder.Default
    private boolean supportsRetainedMessages = false;

    /**
     * Whether the plugin supports QoS levels
     */
    @Builder.Default
    private boolean supportsQos = false;

    /**
     * Maximum QoS level supported (0, 1, 2)
     */
    @Builder.Default
    private int maxQosLevel = 0;

    /**
     * Check if a feature is supported.
     *
     * @param feature Feature name
     * @return true if supported
     */
    public boolean supportsFeature(String feature) {
        return supportedFeatures.contains(feature);
    }

    /**
     * Add a supported feature.
     *
     * @param feature Feature name
     */
    public void addSupportedFeature(String feature) {
        if (!supportedFeatures.contains(feature)) {
            supportedFeatures.add(feature);
        }
    }
}

