/** * Replication Benchmarker * https://github.com/score-team/replication-benchmarker/ * Copyright (C) 2013 LORIA / Inria / SCORE Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package jbenchmarker.woot; import crdt.tree.orderedtree.PositionIdentifier; /** * A woot position defined as a triplet <previous, id, next>. * @author urso */ public class WootPosition implements WootId, PositionIdentifier { final private WootIdentifier id; final private WootIdentifier ip; // previous final private WootIdentifier in; // next public WootPosition(WootIdentifier id, WootIdentifier ip, WootIdentifier in) { this.id = id; this.ip = ip; this.in = in; } @Override public WootIdentifier getId() { return id; } public WootIdentifier getIn() { return in; } public WootIdentifier getIp() { return ip; } @Override public WootPosition clone() { return new WootPosition(id.clone(), ip.clone(), in.clone()); } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final WootPosition other = (WootPosition) obj; if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) { return false; } if (this.ip != other.ip && (this.ip == null || !this.ip.equals(other.ip))) { return false; } if (this.in != other.in && (this.in == null || !this.in.equals(other.in))) { return false; } return true; } @Override public int hashCode() { int hash = 7; hash = 29 * hash + (this.id != null ? this.id.hashCode() : 0); hash = 29 * hash + (this.ip != null ? this.ip.hashCode() : 0); hash = 29 * hash + (this.in != null ? this.in.hashCode() : 0); return hash; } }