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

com.hfg.bio.seq.SeqTopology Maven / Gradle / Ivy

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

import com.hfg.util.StringUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.Collection;
import java.io.Serializable;


//------------------------------------------------------------------------------
/**
 * Enumeration of sequence topology types
 * 
* @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 SeqTopology implements Serializable { //************************************************************************** // PRIVATE FIELDS //************************************************************************** private String mName; private static Map sUniqueValueMap = new HashMap<>(4); //************************************************************************** // PUBLIC FIELDS //************************************************************************** public static SeqTopology LINEAR = new SeqTopology("linear"); public static SeqTopology CIRCULAR = new SeqTopology("circular"); //************************************************************************** // CONSTRUCTORS //************************************************************************** //-------------------------------------------------------------------------- private SeqTopology(String inName) { mName = inName; if (sUniqueValueMap.containsKey(mName)) { throw new RuntimeException("A object already exists with the name '" + mName + "'!"); } sUniqueValueMap.put(mName, this); } //************************************************************************** // PUBLIC METHODS //************************************************************************** //-------------------------------------------------------------------------- public static Collection values() { return sUniqueValueMap.values(); } //-------------------------------------------------------------------------- /** Returns the corresponding SeqTopology by comparing the value to the names in the enumerated set. @param inValue the name of the sequence topology to retrieve @return SeqTopology object corresponding to the specified value */ public static SeqTopology valueOf(String inValue) { SeqTopology value = null; if (StringUtil.isSet(inValue)) { for (SeqTopology obj : sUniqueValueMap.values()) { if (obj.name().equalsIgnoreCase(inValue)) { value = obj; break; } } } return value; } //-------------------------------------------------------------------------- public String name() { return mName; } //-------------------------------------------------------------------------- /** The same as name(). */ @Override public String toString() { return name(); } //************************************************************************** // PRIVATE METHODS //************************************************************************** //-------------------------------------------------------------------------- /** * This method is called after de-serialization, allowing the object * to nominate a replacement object to be used in the output * graph instead of this object. We don't want multiple objects of each type * to exist in a target VM, so instances replace themselves with * local objects. */ private Object readResolve() { return sUniqueValueMap.get(mName + ""); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy