<commit_before>// $Id: MergeData.java,v 1.8 2009/04/27 13:19:09 belaban Exp $

package org.jgroups.protocols.pbcast;


import org.jgroups.Address;
import org.jgroups.View;
import org.jgroups.util.Digest;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;


/**
 * Encapsulates data sent with a MERGE_RSP (handleMergeResponse()) and INSTALL_MERGE_VIEW
 * (handleMergeView()).
 *
 * @author <NAME> Oct 22 2001
 */
public class MergeData implements Externalizable {
    Address   sender=null;
    boolean   merge_rejected=false;
    View      view=null;
    Digest    digest=null;

    /**
     * Empty constructor needed for externalization
     */
    public MergeData() {
    }

    public MergeData(Address sender, View view, Digest digest) {
        this.sender=sender;
        this.view=view;
        this.digest=digest;
    }

    public Address getSender() {
        return sender;
    }

    public View getView() {
        return view;
    }

    public Digest getDigest() {
        return digest;
    }

    public void setView(View v) {
        view=v;
    }

    public void setDigest(Digest d) {
        digest=d;
    }


    public boolean equals(Object other) {
        return sender != null && other != null && other instanceof MergeData &&
                ((MergeData)other).sender != null && ((MergeData)other).sender.equals(sender);
    }


    public void writeExternal(ObjectOutput out) throws IOException {
        out.writeObject(sender);
        out.writeBoolean(merge_rejected);
        if(!merge_rejected) {
            out.writeObject(view);
            out.writeObject(digest);
        }
    }

    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        sender=(Address)in.readObject();
        merge_rejected=in.readBoolean();
        if(!merge_rejected) {
            view=(View)in.readObject();
            digest=(Digest)in.readObject();
        }
    }


    public String toString() {
        StringBuilder sb=new StringBuilder();
        sb.append("sender=").append(sender);
        if(merge_rejected)
            sb.append(" (merge_rejected)");
        else {
            sb.append(", view=").append(view).append(", digest=").append(digest);
        }
        return sb.toString();
    }<commit_msg>findbugs: added hashCode()<commit_after>// $Id: MergeData.java,v 1.9 2009/09/20 15:02:40 belaban Exp $

package org.jgroups.protocols.pbcast;


import org.jgroups.Address;
import org.jgroups.View;
import org.jgroups.util.Digest;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;


/**
 * Encapsulates data sent with a MERGE_RSP (handleMergeResponse()) and INSTALL_MERGE_VIEW
 * (handleMergeView()).
 *
 * @author <NAME> Oct 22 2001
 */
public class MergeData implements Externalizable {
    Address   sender=null;
    boolean   merge_rejected=false;
    View      view=null;
    Digest    digest=null;

    /**
     * Empty constructor needed for externalization
     */
    public MergeData() {
    }

    public MergeData(Address sender, View view, Digest digest) {
        this.sender=sender;
        this.view=view;
        this.digest=digest;
    }

    public Address getSender() {
        return sender;
    }

    public View getView() {
        return view;
    }

    public Digest getDigest() {
        return digest;
    }

    public void setView(View v) {
        view=v;
    }

    public void setDigest(Digest d) {
        digest=d;
    }


    public boolean equals(Object other) {
        return sender != null && other != null && other instanceof MergeData &&
                ((MergeData)other).sender != null && ((MergeData)other).sender.equals(sender);
    }

    public int hashCode() {
        return sender != null? sender.hashCode() : 0;
    }

    public void writeExternal(ObjectOutput out) throws IOException {
        out.writeObject(sender);
        out.writeBoolean(merge_rejected);
        if(!merge_rejected) {
            out.writeObject(view);
            out.writeObject(digest);
        }
    }

    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        sender=(Address)in.readObject();
        merge_rejected=in.readBoolean();
        if(!merge_rejected) {
            view=(View)in.readObject();
            digest=(Digest)in.readObject();
        }
    }


    public String toString() {
        StringBuilder sb=new StringBuilder();
        sb.append("sender=").append(sender);
        if(merge_rejected)
            sb.append(" (merge_rejected)");
        else {
            sb.append(", view=").append(view).append(", digest=").append(digest);
        }
        return sb.toString();
    }
{'fraction_non_alphanumeric': 0.11660037680552648, 'fraction_numerical': 0.009420138162026376, 'mean_word_length': 2.477438136826783, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5036960', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1377, 'n_words': 306}