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

com.hfg.bio.taxonomy.EMBL_TaxonDivision Maven / Gradle / Ivy

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

import com.hfg.util.StringUtil;

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


//------------------------------------------------------------------------------
/**
 * Enumerated list of EMBL taxonomic divisions.
 * 
* Based on ftp://ftp.ebi.ac.uk/pub/databases/embl/doc/usrman.txt *
* @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 EMBL_TaxonDivision implements SeqRepositoryDivision, Serializable { //************************************************************************** // PRIVATE FIELDS //************************************************************************** private String mName; private String mCode; private static Map sUniqueCodeMap = new HashMap<>(20); //************************************************************************** // PUBLIC FIELDS //************************************************************************** /** Bacteriophage PHG */ public static EMBL_TaxonDivision BACTERIOPHAGE = new EMBL_TaxonDivision("Bacteriophage", "PHG"); /** Environmental Sample ENV */ public static EMBL_TaxonDivision ENVIRONMENTAL_SAMPLE = new EMBL_TaxonDivision("Environmental Sample", "ENV"); /** Fungal FUN */ public static EMBL_TaxonDivision FUNGAL = new EMBL_TaxonDivision("Fungal", "FUN"); /** Human HUM */ public static EMBL_TaxonDivision HUMAN = new EMBL_TaxonDivision("Human", "HUM"); /** Invertebrate INV */ public static EMBL_TaxonDivision INVERTEBRATE = new EMBL_TaxonDivision("Invertebrate", "INV"); /** Other Mammal MAM */ public static EMBL_TaxonDivision OTHER_MAMMAL = new EMBL_TaxonDivision("Other Mammal", "MAM"); /** Other Vertebrate VRT */ public static EMBL_TaxonDivision OTHER_VERTEBRATE = new EMBL_TaxonDivision("Other Vertebrate", "VRT"); /** Mus musculus MUS */ public static EMBL_TaxonDivision MUS_MUSCULUS = new EMBL_TaxonDivision("Mus musculus", "Mus"); /** Plant PLN */ public static EMBL_TaxonDivision PLANT = new EMBL_TaxonDivision("Plant", "PLN"); /** Prokaryote PRO */ public static EMBL_TaxonDivision PROKARYOTE = new EMBL_TaxonDivision("Prokaryote", "PRO"); /** Other Rodent ROD */ public static EMBL_TaxonDivision OTHER_RODENT = new EMBL_TaxonDivision("Other Rodent", "ROD"); /** Synthetic SYN */ public static EMBL_TaxonDivision SYNTHETIC = new EMBL_TaxonDivision("Synthetic", "SYN"); /** Transgenic TGN */ public static EMBL_TaxonDivision TRANSGENIC = new EMBL_TaxonDivision("Transgenic", "TGN"); /** Unclassified UNC */ public static EMBL_TaxonDivision UNCLASSIFIED = new EMBL_TaxonDivision("Unclassified", "UNC"); /** Viral VRL */ public static EMBL_TaxonDivision VIRAL = new EMBL_TaxonDivision("Viral", "VRL"); //************************************************************************** // CONSTRUCTORS //************************************************************************** //-------------------------------------------------------------------------- private EMBL_TaxonDivision(String inName, String inCode) { mName = inName; mCode = inCode; if (sUniqueCodeMap.containsKey(mCode)) { throw new RuntimeException("A object already exists with the code '" + mCode + "'!"); } sUniqueCodeMap.put(mCode, this); } //************************************************************************** // PUBLIC METHODS //************************************************************************** //-------------------------------------------------------------------------- public static Collection values() { return sUniqueCodeMap.values(); } //-------------------------------------------------------------------------- /** Returns the corresponding EMBL_TaxonDivision by comparing the value to the name and code values of the enumerated set. @param inValue the name or code of the EMBL division to retrieve @return EMBL_TaxonDivision object corresponding to the specified value */ public static EMBL_TaxonDivision valueOf(String inValue) { EMBL_TaxonDivision value = null; if (StringUtil.isSet(inValue)) { for (EMBL_TaxonDivision division : sUniqueCodeMap.values()) { if (division.name().equalsIgnoreCase(inValue) || division.getCode().equalsIgnoreCase(inValue)) { value = division; break; } } } return value; } //-------------------------------------------------------------------------- public String name() { return mName; } //-------------------------------------------------------------------------- /** The same as name(). */ @Override public String toString() { return name(); } //-------------------------------------------------------------------------- /** Returns the 3-letter EMBL division code. @return the 3-letter EMBL division code */ public String getCode() { return mCode; } //************************************************************************** // 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 sUniqueCodeMap.get(mCode + ""); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy