/*
 * Copyright 2019, 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.server.type;

import com.google.protobuf.Message;
import io.spine.core.Origin;
import io.spine.string.Stringifiers;
import io.spine.type.MessageClass;

/**
 * A common interface for obtaining messages from wrapping objects.
 *
 * @param <I> the type of the message ID
 * @param <T> the type of the object that wraps a message
 * @param <C> the type of the message context
 */
public interface MessageEnvelope<I extends Message, T, C extends Message> {

    /**
     * The ID of the message.
     */
    I id();

    /**
     * Obtains string representation of the message identifier.
     *
     * @apiNote The primary purpose of this method is to display the identifier in human-readable
     *          form in debug and error messages.
     */
    default String idAsString() {
        return Stringifiers.toString(id());
    }

    /**
     * Obtains the object which contains the message of interest.
     */
    T outerObject();

    /**
     * Obtains the message.
     */
    Message message();

    /**
     * Obtains the message class.
     */
    MessageClass messageClass();

    /**
     * Obtains the context of the message.
     */
    C context();

    /**
     * Packs this message as an {@link Origin} of an event.
     */
    Origin asMessageOrigin();
}

@@ -1106,45 +1106,8 @@
 in;%0A
-import io.spine.string.Stringifiers;%0A
 impo
@@ -1502,328 +1502,8 @@
 );%0A%0A
-    /**%0A     * Obtains string representation of the message identifier.%0A     *%0A     * @apiNote The primary purpose of this method is to display the identifier in human-readable%0A     *          form in debug and error messages.%0A     */%0A    default String idAsString() %7B%0A        return Stringifiers.toString(id());%0A    %7D%0A%0A
     

Remove an unused method