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

com.hfg.automation.platelayer.PlateLayerImpl Maven / Gradle / Ivy

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

import java.util.Collection;
import java.util.Iterator;

import com.hfg.automation.AutomationXML;
import com.hfg.automation.PlateLayout;
import com.hfg.automation.WellRef;
import com.hfg.util.CompareUtil;
import com.hfg.util.StringUtil;
import com.hfg.xml.XMLNode;
import com.hfg.xml.XMLTag;

//------------------------------------------------------------------------------
/**
 Abstract base plate layer.
 
@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 abstract class PlateLayerImpl implements PlateLayer, Comparable { private String mName; private LayerPlate mPlate; private PlateLayout mLayout; //########################################################################### // CONSTRUCTORS //########################################################################### //-------------------------------------------------------------------------- public PlateLayerImpl() { } //-------------------------------------------------------------------------- public PlateLayerImpl(String inName) { this(); setName(inName); } //-------------------------------------------------------------------------- public PlateLayerImpl(XMLNode inXML) { inXML.verifyTagName(AutomationXML.PLATE_LAYER); setName(inXML.getAttributeValue(AutomationXML.NAME_ATT)); XMLNode layoutTag = inXML.getOptionalSubtagByName(AutomationXML.PLATE_LAYOUT); if (layoutTag != null) { setLayout(new PlateLayout(layoutTag)); } } //########################################################################### // PUBLIC METHODS //########################################################################### //--------------------------------------------------------------------------- public XMLNode toXMLNode() { XMLNode node = new XMLTag(AutomationXML.PLATE_LAYER); node.setAttribute(AutomationXML.CLASS_ATT, getClass().getName()); if (StringUtil.isSet(name())) { node.setAttribute(AutomationXML.NAME_ATT, name()); } if (getLayout() != null) { node.addSubtag(getLayout().toXMLNode()); } return node; } //-------------------------------------------------------------------------- @Override public PlateLayerImpl clone() { PlateLayerImpl theClone; try { theClone = (PlateLayerImpl) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } return theClone; } //--------------------------------------------------------------------------- @Override public int hashCode() { int hashCode = super.hashCode(); if (StringUtil.isSet(name())) { hashCode += 31 * name().hashCode(); } if (getLayout() != null) { hashCode += 31 * getLayout().hashCode(); } return hashCode; } //--------------------------------------------------------------------------- @Override public boolean equals(Object inObj2) { return (0 == compareTo(inObj2)); } //--------------------------------------------------------------------------- @Override public int compareTo(Object inObj2) { int result = -1; if (inObj2 != null && inObj2 instanceof PlateLayer) { result = 0; if (this != inObj2) { PlateLayer plateLayer2 = (PlateLayer) inObj2; result = CompareUtil.compare(name(), plateLayer2.name()); if (0 == result) { result = CompareUtil.compare(getLayout(), plateLayer2.getLayout()); } } } return result; } //-------------------------------------------------------------------------- public PlateLayer setName(String inValue) { mName = inValue; return this; } //-------------------------------------------------------------------------- public String name() { return mName; } //--------------------------------------------------------------------------- public PlateLayer setPlate(LayerPlate inValue) { mPlate = inValue; return this; } //--------------------------------------------------------------------------- public PlateLayer setLayout(PlateLayout inValue) { mLayout = inValue; return this; } //--------------------------------------------------------------------------- public PlateLayout getLayout() { if (null == mLayout) { // Default to the plate's layout mLayout = mPlate.getLayout(); } return mLayout; } //--------------------------------------------------------------------------- public WellRef getNextAvailableWellRef() { WellRef nextWellRef = null; Collection occupiedWellRefs = getOccupiedWellRefs(); Iterator iterator = getLayout().wellRefIterator(); while (iterator.hasNext()) { WellRef wellRef = iterator.next(); if (null == occupiedWellRefs || ! occupiedWellRefs.contains(wellRef)) { nextWellRef = wellRef; break; } } return nextWellRef; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy