package org.onlab.onos.mastership;

import java.util.Objects;

import org.onlab.onos.cluster.NodeId;

public final class MastershipTerm {

    private final NodeId master;
    private final int termNumber;

    private MastershipTerm(NodeId master, int term) {
        this.master = master;
        this.termNumber = term;
    }

    public static MastershipTerm of(NodeId master, int term) {
        return new MastershipTerm(master, term);
    }

    public NodeId master() {
        return master;
    }

    public int termNumber() {
        return termNumber;
    }

    @Override
    public int hashCode() {
        return Objects.hash(master, termNumber);
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        if (other instanceof MastershipTerm) {
            MastershipTerm that = (MastershipTerm) other;
            if (!this.master.equals(that.master)) {
                return false;
            }
            if (this.termNumber != that.termNumber) {
                return false;
            }
            return true;
        }
        return false;
    }
}

@@ -95,16 +95,60 @@
 odeId;%0A%0A
+import com.google.common.base.MoreObjects;%0A%0A
 public f
@@ -1188,11 +1188,242 @@
 e;%0A    %7D
+%0A%0A    @Override%0A    public String toString() %7B%0A        return MoreObjects.toStringHelper(getClass())%0A                .add(%22master%22, this.master)%0A                .add(%22termNumber%22, this.termNumber)%0A                .toString();%0A    %7D
 %0A%7D%0A

add toString