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

org.opensearch.commons.destination.response.LegacyBaseResponse Maven / Gradle / Ivy

/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.opensearch.commons.destination.response;

import java.io.IOException;

import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;

/**
 * This class holds the generic response attributes
 */
public abstract class LegacyBaseResponse implements Writeable {
    protected Integer statusCode;

    LegacyBaseResponse(final Integer statusCode) {
        if (statusCode == null) {
            throw new IllegalArgumentException("status code is invalid");
        }
        this.statusCode = statusCode;
    }

    public LegacyBaseResponse(StreamInput streamInput) throws IOException {
        this.statusCode = streamInput.readInt();
    }

    public int getStatusCode() {
        return statusCode;
    }

    @Override
    public void writeTo(StreamOutput streamOutput) throws IOException {
        streamOutput.writeInt(statusCode);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy