All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nameapi.client.services.development.exceptionthrower.ExceptionThrowerCommand Maven / Gradle / Ivy

The newest version!
package org.nameapi.client.services.development.exceptionthrower;

import com.google.common.base.Optional;
import com.optimaize.command4j.ExecutionContext;
import org.jetbrains.annotations.NotNull;
import org.nameapi.client.services.NameApiBaseCommand;

import java.util.concurrent.Callable;

/**
 * Tells the server to throw an exception. This is to debug and test on the client how things work.
 */
public class ExceptionThrowerCommand extends NameApiBaseCommand {

    private static final String SERVICE_PATH = "/development/exceptionthrower";

    public ExceptionThrowerCommand() {
        super(RestPort.class);
    }

    @Override
    public String call(@NotNull Optional arg, @NotNull ExecutionContext ec) throws Exception {
        return getPort(ec).call(getApiKey(ec), arg.get().getExceptionType(), arg.get().getExceptionChance());
    }

    @NotNull @Override
    protected Callable createPort(@NotNull final ExecutionContext ec) {
        return new Callable() {
            @Override
            public RestPort call() throws Exception {
                return new RestPort(makeClient(ec), SERVICE_PATH);
            }
        };
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy