/*
 * Copyright 2018, TeamDev. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package io.spine.system.server;

import com.google.protobuf.Message;
import io.spine.annotation.Internal;
import io.spine.core.TenantId;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
 * A gateway for sending messages into a system bounded context.
 *
 * @author Dmytro Dashenkov
 */
@Internal
public interface SystemGateway {

    /**
     * Posts a system command.
     *
     * <p>In a multitenant environment, the command is posted for the current tenant.
     *
     * @param systemCommand command message
     */
    default void postCommand(Message systemCommand) {
        postCommand(systemCommand, null);
    }

    void postCommand(Message systemCommand, @Nullable TenantId tenantId);

    CommandIndex commandIndex();
}

@@ -1654,78 +1654,969 @@
     
-void postCommand(Message systemCommand, @Nullable TenantId tenantId);%0A
+/**%0A     * Posts a system command for the given tenant.%0A     *%0A     * %3Cp%3EIf the %7B@code tenantId%7D is %7B@code null%7D or%0A     * %7B@linkplain io.spine.validate.Validate#isDefault(Message) default%7D, posts the command for%0A     * the %7B@linkplain io.spine.server.tenant.TenantFunction current tenant%7D in multitenant%0A     * environment or the default tenant in a single-tenant environment.%0A     *%0A     * @param systemCommand the system command to post%0A     * @param tenantId      the ID of the tenant to post the command for%0A     */%0A    void postCommand(Message systemCommand, @Nullable TenantId tenantId);%0A%0A    /**%0A     * Obtains a %7B@link CommandIndex%7D over the commands of the associated domain bounded context.%0A     *%0A     * %3Cp%3EThe system bounded context keeps track of all the domain commands. %7B@link CommandIndex%7D is%0A     * a view on the data about domain commands managed by the system bounded context.%0A     *%0A     * @return the index over the domain commands%0A     */
 %0A   

Document `SystemGateway`.