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

com.dottydingo.hyperion.client.builder.DeleteRequestBuilder Maven / Gradle / Ivy

The newest version!
package com.dottydingo.hyperion.client.builder;

import com.dottydingo.hyperion.api.ApiObject;
import com.dottydingo.hyperion.client.*;

import java.io.Serializable;

/**
 * A request builder for deletes
 */
public class DeleteRequestBuilder,ID extends Serializable> extends RequestBuilder
{
    private ID[] ids;

    /**
     * Create the request builder using the specified parameters
     * @param version The entity version
     * @param objectType The API type
     * @param entityName The entity name
     * @param ids The ids to delete
     */
    public DeleteRequestBuilder(int version, Class objectType, String entityName, ID[] ids)
    {
        super(version, objectType, entityName);
        this.ids = ids;
    }

    @Override
    public DeleteRequestBuilder addParameter(String name, String value)
    {
        super.addParameter(name, value);
        return this;
    }

    @Override
    public DeleteRequestBuilder setParameter(String name, String value)
    {
        super.setParameter(name, value);
        return this;
    }

    @Override
    public DeleteRequestBuilder addHeader(String name, String value)
    {
        super.addHeader(name, value);
        return this;
    }

    @Override
    public DeleteRequestBuilder setHeader(String name, String value)
    {
        super.setHeader(name, value);
        return this;
    }

    @Override
    public DeleteRequestBuilder withHeaderFactory(HeaderFactory headerFactory)
    {
        super.withHeaderFactory(headerFactory);
        return this;
    }

    @Override
    public DeleteRequestBuilder withParameterFactory(ParameterFactory parameterFactory)
    {
        super.withParameterFactory(parameterFactory);
        return this;
    }

    @Override
    public Request build()
    {
        Request request = super.build();
        request.setRequestMethod(RequestMethod.DELETE);
        request.setPath(join(ids));
        return request;
    }

    /**
     * Execute the request using the supplied client
     * @param client the client
     * @return The request
     */
    public int execute(HyperionClient client)
    {
        return client.delete(build());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy