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

org.elasticsearch.action.fieldcaps.FieldCapabilitiesNodeResponse Maven / Gradle / Ivy

There is a newer version: 8.14.0
Show newest version
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0 and the Server Side Public License, v 1; you may not use this file except
 * in compliance with, at your election, the Elastic License 2.0 or the Server
 * Side Public License, v 1.
 */

package org.elasticsearch.action.fieldcaps;

import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.index.shard.ShardId;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

class FieldCapabilitiesNodeResponse extends ActionResponse implements Writeable {
    private final List indexResponses;
    private final Map failures;
    private final Set unmatchedShardIds;

    FieldCapabilitiesNodeResponse(
        List indexResponses,
        Map failures,
        Set unmatchedShardIds
    ) {
        this.indexResponses = Objects.requireNonNull(indexResponses);
        this.failures = Objects.requireNonNull(failures);
        this.unmatchedShardIds = Objects.requireNonNull(unmatchedShardIds);
    }

    FieldCapabilitiesNodeResponse(StreamInput in) throws IOException {
        super(in);
        this.indexResponses = in.readList(FieldCapabilitiesIndexResponse::new);
        this.failures = in.readMap(ShardId::new, StreamInput::readException);
        this.unmatchedShardIds = in.readSet(ShardId::new);
    }

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        out.writeList(indexResponses);
        out.writeMap(failures, (o, v) -> v.writeTo(o), StreamOutput::writeException);
        out.writeCollection(unmatchedShardIds);
    }

    public Map getFailures() {
        return failures;
    }

    public List getIndexResponses() {
        return indexResponses;
    }

    public Set getUnmatchedShardIds() {
        return unmatchedShardIds;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FieldCapabilitiesNodeResponse that = (FieldCapabilitiesNodeResponse) o;
        return Objects.equals(indexResponses, that.indexResponses)
            && Objects.equals(failures, that.failures)
            && unmatchedShardIds.equals(that.unmatchedShardIds);
    }

    @Override
    public int hashCode() {
        return Objects.hash(indexResponses, failures, unmatchedShardIds);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy