// 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;

/** The X12 agreement framing settings. */
@Fluent
public final class X12FramingSettings {
    /*
     * The data element separator.
     */
    @JsonProperty(value = "dataElementSeparator", required = true)
    private int dataElementSeparator;

    /*
     * The component separator.
     */
    @JsonProperty(value = "componentSeparator", required = true)
    private int componentSeparator;

    /*
     * The value indicating whether to replace separators in payload.
     */
    @JsonProperty(value = "replaceSeparatorsInPayload", required = true)
    private boolean replaceSeparatorsInPayload;

    /*
     * The replacement character.
     */
    @JsonProperty(value = "replaceCharacter", required = true)
    private int replaceCharacter;

    /*
     * The segment terminator.
     */
    @JsonProperty(value = "segmentTerminator", required = true)
    private int segmentTerminator;

    /*
     * The X12 character set.
     */
    @JsonProperty(value = "characterSet", required = true)
    private X12CharacterSet characterSet;

    /*
     * The segment terminator suffix.
     */
    @JsonProperty(value = "segmentTerminatorSuffix", required = true)
    private SegmentTerminatorSuffix segmentTerminatorSuffix;

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

    /**
     * Get the dataElementSeparator property: The data element separator.
     *
     * @return the dataElementSeparator value.
     */
    public int dataElementSeparator() {
        return this.dataElementSeparator;
    }

    /**
     * Set the dataElementSeparator property: The data element separator.
     *
     * @param dataElementSeparator the dataElementSeparator value to set.
     * @return the X12FramingSettings object itself.
     */
    public X12FramingSettings withDataElementSeparator(int dataElementSeparator) {
        this.dataElementSeparator = dataElementSeparator;
        return this;
    }

    /**
     * Get the componentSeparator property: The component separator.
     *
     * @return the componentSeparator value.
     */
    public int componentSeparator() {
        return this.componentSeparator;
    }

    /**
     * Set the componentSeparator property: The component separator.
     *
     * @param componentSeparator the componentSeparator value to set.
     * @return the X12FramingSettings object itself.
     */
    public X12FramingSettings withComponentSeparator(int componentSeparator) {
        this.componentSeparator = componentSeparator;
        return this;
    }

    /**
     * Get the replaceSeparatorsInPayload property: The value indicating whether to replace separators in payload.
     *
     * @return the replaceSeparatorsInPayload value.
     */
    public boolean replaceSeparatorsInPayload() {
        return this.replaceSeparatorsInPayload;
    }

    /**
     * Set the replaceSeparatorsInPayload property: The value indicating whether to replace separators in payload.
     *
     * @param replaceSeparatorsInPayload the replaceSeparatorsInPayload value to set.
     * @return the X12FramingSettings object itself.
     */
    public X12FramingSettings withReplaceSeparatorsInPayload(boolean replaceSeparatorsInPayload) {
        this.replaceSeparatorsInPayload = replaceSeparatorsInPayload;
        return this;
    }

    /**
     * Get the replaceCharacter property: The replacement character.
     *
     * @return the replaceCharacter value.
     */
    public int replaceCharacter() {
        return this.replaceCharacter;
    }

    /**
     * Set the replaceCharacter property: The replacement character.
     *
     * @param replaceCharacter the replaceCharacter value to set.
     * @return the X12FramingSettings object itself.
     */
    public X12FramingSettings withReplaceCharacter(int replaceCharacter) {
        this.replaceCharacter = replaceCharacter;
        return this;
    }

    /**
     * Get the segmentTerminator property: The segment terminator.
     *
     * @return the segmentTerminator value.
     */
    public int segmentTerminator() {
        return this.segmentTerminator;
    }

    /**
     * Set the segmentTerminator property: The segment terminator.
     *
     * @param segmentTerminator the segmentTerminator value to set.
     * @return the X12FramingSettings object itself.
     */
    public X12FramingSettings withSegmentTerminator(int segmentTerminator) {
        this.segmentTerminator = segmentTerminator;
        return this;
    }

    /**
     * Get the characterSet property: The X12 character set.
     *
     * @return the characterSet value.
     */
    public X12CharacterSet characterSet() {
        return this.characterSet;
    }

    /**
     * Set the characterSet property: The X12 character set.
     *
     * @param characterSet the characterSet value to set.
     * @return the X12FramingSettings object itself.
     */
    public X12FramingSettings withCharacterSet(X12CharacterSet characterSet) {
        this.characterSet = characterSet;
        return this;
    }

    /**
     * Get the segmentTerminatorSuffix property: The segment terminator suffix.
     *
     * @return the segmentTerminatorSuffix value.
     */
    public SegmentTerminatorSuffix segmentTerminatorSuffix() {
        return this.segmentTerminatorSuffix;
    }

    /**
     * Set the segmentTerminatorSuffix property: The segment terminator suffix.
     *
     * @param segmentTerminatorSuffix the segmentTerminatorSuffix value to set.
     * @return the X12FramingSettings object itself.
     */
    public X12FramingSettings withSegmentTerminatorSuffix(SegmentTerminatorSuffix segmentTerminatorSuffix) {
        this.segmentTerminatorSuffix = segmentTerminatorSuffix;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (characterSet() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property characterSet in model X12FramingSettings"));
        }
        if (segmentTerminatorSuffix() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property segmentTerminatorSuffix in model X12FramingSettings"));
        }
    }

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