// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.logic.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The X12 agreement protocol settings. */
@Fluent
public final class X12ProtocolSettings {
    /*
     * The X12 validation settings.
     */
    @JsonProperty(value = "validationSettings", required = true)
    private X12ValidationSettings validationSettings;

    /*
     * The X12 framing settings.
     */
    @JsonProperty(value = "framingSettings", required = true)
    private X12FramingSettings framingSettings;

    /*
     * The X12 envelope settings.
     */
    @JsonProperty(value = "envelopeSettings", required = true)
    private X12EnvelopeSettings envelopeSettings;

    /*
     * The X12 acknowledgment settings.
     */
    @JsonProperty(value = "acknowledgementSettings", required = true)
    private X12AcknowledgementSettings acknowledgementSettings;

    /*
     * The X12 message filter.
     */
    @JsonProperty(value = "messageFilter", required = true)
    private X12MessageFilter messageFilter;

    /*
     * The X12 security settings.
     */
    @JsonProperty(value = "securitySettings", required = true)
    private X12SecuritySettings securitySettings;

    /*
     * The X12 processing settings.
     */
    @JsonProperty(value = "processingSettings", required = true)
    private X12ProcessingSettings processingSettings;

    /*
     * The X12 envelope override settings.
     */
    @JsonProperty(value = "envelopeOverrides")
    private List<X12EnvelopeOverride> envelopeOverrides;

    /*
     * The X12 validation override settings.
     */
    @JsonProperty(value = "validationOverrides")
    private List<X12ValidationOverride> validationOverrides;

    /*
     * The X12 message filter list.
     */
    @JsonProperty(value = "messageFilterList")
    private List<X12MessageIdentifier> messageFilterList;

    /*
     * The X12 schema references.
     */
    @JsonProperty(value = "schemaReferences", required = true)
    private List<X12SchemaReference> schemaReferences;

    /*
     * The X12 delimiter override settings.
     */
    @JsonProperty(value = "x12DelimiterOverrides")
    private List<X12DelimiterOverrides> x12DelimiterOverrides;

    /** Creates an instance of X12ProtocolSettings class. */
    public X12ProtocolSettings() {
    }

    /**
     * Get the validationSettings property: The X12 validation settings.
     *
     * @return the validationSettings value.
     */
    public X12ValidationSettings validationSettings() {
        return this.validationSettings;
    }

    /**
     * Set the validationSettings property: The X12 validation settings.
     *
     * @param validationSettings the validationSettings value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withValidationSettings(X12ValidationSettings validationSettings) {
        this.validationSettings = validationSettings;
        return this;
    }

    /**
     * Get the framingSettings property: The X12 framing settings.
     *
     * @return the framingSettings value.
     */
    public X12FramingSettings framingSettings() {
        return this.framingSettings;
    }

    /**
     * Set the framingSettings property: The X12 framing settings.
     *
     * @param framingSettings the framingSettings value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withFramingSettings(X12FramingSettings framingSettings) {
        this.framingSettings = framingSettings;
        return this;
    }

    /**
     * Get the envelopeSettings property: The X12 envelope settings.
     *
     * @return the envelopeSettings value.
     */
    public X12EnvelopeSettings envelopeSettings() {
        return this.envelopeSettings;
    }

    /**
     * Set the envelopeSettings property: The X12 envelope settings.
     *
     * @param envelopeSettings the envelopeSettings value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withEnvelopeSettings(X12EnvelopeSettings envelopeSettings) {
        this.envelopeSettings = envelopeSettings;
        return this;
    }

    /**
     * Get the acknowledgementSettings property: The X12 acknowledgment settings.
     *
     * @return the acknowledgementSettings value.
     */
    public X12AcknowledgementSettings acknowledgementSettings() {
        return this.acknowledgementSettings;
    }

    /**
     * Set the acknowledgementSettings property: The X12 acknowledgment settings.
     *
     * @param acknowledgementSettings the acknowledgementSettings value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withAcknowledgementSettings(X12AcknowledgementSettings acknowledgementSettings) {
        this.acknowledgementSettings = acknowledgementSettings;
        return this;
    }

    /**
     * Get the messageFilter property: The X12 message filter.
     *
     * @return the messageFilter value.
     */
    public X12MessageFilter messageFilter() {
        return this.messageFilter;
    }

    /**
     * Set the messageFilter property: The X12 message filter.
     *
     * @param messageFilter the messageFilter value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withMessageFilter(X12MessageFilter messageFilter) {
        this.messageFilter = messageFilter;
        return this;
    }

    /**
     * Get the securitySettings property: The X12 security settings.
     *
     * @return the securitySettings value.
     */
    public X12SecuritySettings securitySettings() {
        return this.securitySettings;
    }

    /**
     * Set the securitySettings property: The X12 security settings.
     *
     * @param securitySettings the securitySettings value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withSecuritySettings(X12SecuritySettings securitySettings) {
        this.securitySettings = securitySettings;
        return this;
    }

    /**
     * Get the processingSettings property: The X12 processing settings.
     *
     * @return the processingSettings value.
     */
    public X12ProcessingSettings processingSettings() {
        return this.processingSettings;
    }

    /**
     * Set the processingSettings property: The X12 processing settings.
     *
     * @param processingSettings the processingSettings value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withProcessingSettings(X12ProcessingSettings processingSettings) {
        this.processingSettings = processingSettings;
        return this;
    }

    /**
     * Get the envelopeOverrides property: The X12 envelope override settings.
     *
     * @return the envelopeOverrides value.
     */
    public List<X12EnvelopeOverride> envelopeOverrides() {
        return this.envelopeOverrides;
    }

    /**
     * Set the envelopeOverrides property: The X12 envelope override settings.
     *
     * @param envelopeOverrides the envelopeOverrides value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withEnvelopeOverrides(List<X12EnvelopeOverride> envelopeOverrides) {
        this.envelopeOverrides = envelopeOverrides;
        return this;
    }

    /**
     * Get the validationOverrides property: The X12 validation override settings.
     *
     * @return the validationOverrides value.
     */
    public List<X12ValidationOverride> validationOverrides() {
        return this.validationOverrides;
    }

    /**
     * Set the validationOverrides property: The X12 validation override settings.
     *
     * @param validationOverrides the validationOverrides value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withValidationOverrides(List<X12ValidationOverride> validationOverrides) {
        this.validationOverrides = validationOverrides;
        return this;
    }

    /**
     * Get the messageFilterList property: The X12 message filter list.
     *
     * @return the messageFilterList value.
     */
    public List<X12MessageIdentifier> messageFilterList() {
        return this.messageFilterList;
    }

    /**
     * Set the messageFilterList property: The X12 message filter list.
     *
     * @param messageFilterList the messageFilterList value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withMessageFilterList(List<X12MessageIdentifier> messageFilterList) {
        this.messageFilterList = messageFilterList;
        return this;
    }

    /**
     * Get the schemaReferences property: The X12 schema references.
     *
     * @return the schemaReferences value.
     */
    public List<X12SchemaReference> schemaReferences() {
        return this.schemaReferences;
    }

    /**
     * Set the schemaReferences property: The X12 schema references.
     *
     * @param schemaReferences the schemaReferences value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withSchemaReferences(List<X12SchemaReference> schemaReferences) {
        this.schemaReferences = schemaReferences;
        return this;
    }

    /**
     * Get the x12DelimiterOverrides property: The X12 delimiter override settings.
     *
     * @return the x12DelimiterOverrides value.
     */
    public List<X12DelimiterOverrides> x12DelimiterOverrides() {
        return this.x12DelimiterOverrides;
    }

    /**
     * Set the x12DelimiterOverrides property: The X12 delimiter override settings.
     *
     * @param x12DelimiterOverrides the x12DelimiterOverrides value to set.
     * @return the X12ProtocolSettings object itself.
     */
    public X12ProtocolSettings withX12DelimiterOverrides(List<X12DelimiterOverrides> x12DelimiterOverrides) {
        this.x12DelimiterOverrides = x12DelimiterOverrides;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (validationSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property validationSettings in model X12ProtocolSettings"));
        } else {
            validationSettings().validate();
        }
        if (framingSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property framingSettings in model X12ProtocolSettings"));
        } else {
            framingSettings().validate();
        }
        if (envelopeSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property envelopeSettings in model X12ProtocolSettings"));
        } else {
            envelopeSettings().validate();
        }
        if (acknowledgementSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property acknowledgementSettings in model X12ProtocolSettings"));
        } else {
            acknowledgementSettings().validate();
        }
        if (messageFilter() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property messageFilter in model X12ProtocolSettings"));
        } else {
            messageFilter().validate();
        }
        if (securitySettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property securitySettings in model X12ProtocolSettings"));
        } else {
            securitySettings().validate();
        }
        if (processingSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property processingSettings in model X12ProtocolSettings"));
        } else {
            processingSettings().validate();
        }
        if (envelopeOverrides() != null) {
            envelopeOverrides().forEach(e -> e.validate());
        }
        if (validationOverrides() != null) {
            validationOverrides().forEach(e -> e.validate());
        }
        if (messageFilterList() != null) {
            messageFilterList().forEach(e -> e.validate());
        }
        if (schemaReferences() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property schemaReferences in model X12ProtocolSettings"));
        } else {
            schemaReferences().forEach(e -> e.validate());
        }
        if (x12DelimiterOverrides() != null) {
            x12DelimiterOverrides().forEach(e -> e.validate());
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(X12ProtocolSettings.class);
}
