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

org.jgroups.raft.Options Maven / Gradle / Ivy

There is a newer version: 1.0.13.Final
Show newest version
package org.jgroups.raft;

import org.jgroups.Global;
import org.jgroups.util.SizeStreamable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Options to pass to {@link Settable#setAsync(byte[], int, int)} call
 * @author Bela Ban
 * @since  1.0.9
 */
public class Options implements SizeStreamable {

    public static final Options DEFAULT_OPTIONS = new Options();

    protected boolean ignore_return_value;

    public boolean ignoreReturnValue() {return ignore_return_value;}

    public Options ignoreReturnValue(boolean ignore) {this.ignore_return_value=ignore; return this;}

    public static Options create(boolean ignore_retval) {
        return new Options().ignoreReturnValue(ignore_retval);
    }

    public void writeTo(DataOutput out) throws IOException {
        out.writeBoolean(ignore_return_value);
    }

    public void readFrom(DataInput in) throws IOException, ClassNotFoundException {
        ignore_return_value=in.readBoolean();
    }

    public int serializedSize() {
        return Global.BYTE_SIZE;
    }

    public String toString() {
        return String.format("%s", ignore_return_value? "[ignore-retval]" : "");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Options)) return false;

        Options options = (Options) o;

        return ignore_return_value == options.ignore_return_value;
    }

    @Override
    public int hashCode() {
        return (ignore_return_value ? 1 : 0);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy