package net.anomalyxii.bot.api.server;

import net.anomalyxii.bot.api.server.strategies.FormatStrategy;
import net.anomalyxii.bot.api.server.strategies.ParseStrategy;

/**
 * Represents a {@code protocol} that is used by a
 * {@link Server}.
 * <p>
 * Can be used to create instances of various strategies that
 * are compatible with the underlying {@code protocol}.
 * <p>
 * Created by Anomaly on 06/05/17.
 */
public interface Protocol<T> {

    // *********************************
    // Interface Methods
    // *********************************

    /**
     * Get the raw message type that is used by this
     * {@code Protocol}.
     *
     * @return the {@link Class} for the raw messages
     */
    Class<T> getRawType();

    /**
     * Get a {@link ParseStrategy} that can be used to convert raw
     * messages into {@link ServerEvent ServerEvents} that are
     * compatible with this {@code Protocol}.
     *
     * @return a {@link ParseStrategy}
     */
    ParseStrategy<T> getParseStrategy();

    /**
     * Get a {@link FormatStrategy} that can be used to convert
     * {@link ServerEvent ServerEvents} into raw messages that
     * are compatible with this {@code Protocol}.
     *
     * @return a {@link FormatStrategy}
     */
    FormatStrategy<T> getFormatStrategy();

}
