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

com.hfg.automation.PlateLocation Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.automation;


import com.hfg.util.CompareUtil;
import com.hfg.util.StringUtil;

//------------------------------------------------------------------------------
/**
 Adds a specific plate reference to a well reference.
 
@author J. Alex Taylor, hairyfatguy.com
*/ //------------------------------------------------------------------------------ // com.hfg XML/HTML Coding Library // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library 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 // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com // [email protected] //------------------------------------------------------------------------------ public class PlateLocation implements Comparable { private Plate mPlate; private WellRef mWellRef; //########################################################################### // CONSTRUCTORS //########################################################################### //--------------------------------------------------------------------------- public PlateLocation(Plate inPlate, WellRef inWellRef) { mPlate = inPlate; mWellRef = inWellRef; } //########################################################################### // PUBLIC METHODS //########################################################################### //--------------------------------------------------------------------------- public PlateLocation setPlate(Plate inValue) { mPlate = inValue; return this; } //--------------------------------------------------------------------------- public Plate getPlate() { return mPlate; } //--------------------------------------------------------------------------- public PlateLocation setWellRef(WellRef inValue) { mWellRef = inValue; return this; } //--------------------------------------------------------------------------- public WellRef getWellRef() { return mWellRef; } //--------------------------------------------------------------------------- @Override public String toString() { return (StringUtil.isSet(getPlate().name()) ? getPlate().name() + " " : "") + getWellRef(); } //--------------------------------------------------------------------------- @Override public int hashCode() { int hashCode = getPlate().hashCode(); if (getPlate() != null && StringUtil.isSet(getPlate().name())) { hashCode += 31 * getPlate().name().hashCode(); } if (getWellRef() != null) { hashCode += 31 * getWellRef().hashCode(); } return hashCode; } //--------------------------------------------------------------------------- @Override public boolean equals(Object inObj2) { return (0 == compareTo(inObj2)); } //--------------------------------------------------------------------------- // If we try to compare the plate objects in a more detailed way this can fowl // up using the PlateLocation as a Map key as the plate contents could change // and hence change the hashcode value. @Override public int compareTo(Object inObj2) { int result = -1; if (inObj2 != null && inObj2 instanceof PlateLocation) { PlateLocation plateLocation2 = (PlateLocation) inObj2; if (getPlate() != null) { if (plateLocation2.getPlate() != null) { result = CompareUtil.compare(getPlate().name(), plateLocation2.getPlate().name()); } else { result = -1; } } else if (plateLocation2.getPlate() != null) { result = 1; } if (0 == result) { result = getWellRef().compareTo(plateLocation2.getWellRef()); } } return result; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy