001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 * Created on 01-21-2010 021 */ 022package org.biojava.nbio.core.sequence.template; 023 024 025/** 026 * The details of a Compound 027 * @author Andy Yates 028 */ 029public abstract class AbstractCompound implements Compound { 030 031 private final String base; 032 private final String upperedBase; 033 private String shortName = null; 034 private String longName = null; 035 private String description = null; 036 private Float molecularWeight = null; 037 038 039 // Added an empty constructor for Serialization 040 public AbstractCompound(){ 041 this.base = null; 042 this.upperedBase = null; 043 } 044 045 public AbstractCompound(String base) { 046 this.base = base; 047 this.upperedBase = base.toUpperCase(); 048 } 049 050 public String getBase() { 051 return base; 052 } 053 054 public String getUpperedBase() { 055 return upperedBase; 056 } 057 058 @Override 059public String getDescription() { 060 return description; 061 } 062 063 @Override 064public void setDescription(String description) { 065 this.description = description; 066 } 067 068 @Override 069public String getShortName() { 070 return shortName; 071 } 072 073 @Override 074public void setShortName(String shortName) { 075 this.shortName = shortName; 076 } 077 078 @Override 079public String getLongName() { 080 return longName; 081 } 082 083 @Override 084public void setLongName(String longName) { 085 this.longName = longName; 086 } 087 088 @Override 089public Float getMolecularWeight() { 090 return molecularWeight; 091 } 092 093 @Override 094public void setMolecularWeight(Float molecularWeight) { 095 this.molecularWeight = molecularWeight; 096 } 097 098 @Override 099 public String toString() { 100 return base; 101 } 102 103 @Override 104 public boolean equals(Object obj) { 105 if (obj == null) { 106 return false; 107 } 108 if (!(obj instanceof AbstractCompound)) { 109 return false; 110 } 111 AbstractCompound them = (AbstractCompound) obj; 112 return this.base.equals(them.base); 113 } 114 115 @Override 116 public int hashCode() { 117 return this.base.hashCode(); 118 } 119 120 @Override 121 public boolean equalsIgnoreCase(Compound compound) { 122 if (compound == null) { 123 return false; 124 } 125 if (!(compound instanceof AbstractCompound)) { 126 return false; 127 } 128 AbstractCompound them = (AbstractCompound) compound; 129 return this.base.equalsIgnoreCase(them.base); 130 } 131}