package com.atlassian.bitbucket.mesh.git;

import com.google.protobuf.ByteString;

import javax.annotation.Nonnull;
import java.util.List;

import static com.atlassian.bitbucket.mesh.rpc.util.ByteStringUtils.toStringsLazily;

/**
 * Assists with decoding git command line arguments before they get executed.
 */
public interface RpcArgumentDecoder {

    /**
     * Decode {@code git} command line arguments from RPC {@link ByteString}s.
     *
     * @param arguments the arguments passed to the command line
     * @return the potentially decoded arguments
     */
    default List<String> decodeByteStrings(@Nonnull List<ByteString> arguments) {
        return decode(toStringsLazily(arguments));
    }

    /**
     * Decode the git command line arguments.
     *
     * @param arguments the arguments passed to the command line
     * @return the potentially decoded arguments
     */
    @Nonnull
    List<String> decode(@Nonnull List<String> arguments);
}
