001package com.hfg.citation.ncbi;
002
003//------------------------------------------------------------------------------
004
005import java.util.HashSet;
006import java.util.Set;
007
008import com.hfg.util.CompareUtil;
009
010/**
011 Medical Subject Heading (MeSH®) value. MeSH headings are used to characterize
012 the contents of MEDLINE citations.
013 <div>
014 @author J. Alex Taylor, hairyfatguy.com
015 </div>
016 */
017//------------------------------------------------------------------------------
018// com.hfg XML/HTML Coding Library
019//
020// This library is free software; you can redistribute it and/or
021// modify it under the terms of the GNU Lesser General Public
022// License as published by the Free Software Foundation; either
023// version 2.1 of the License, or (at your option) any later version.
024//
025// This library is distributed in the hope that it will be useful,
026// but WITHOUT ANY WARRANTY; without even the implied warranty of
027// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
028// Lesser General Public License for more details.
029//
030// You should have received a copy of the GNU Lesser General Public
031// License along with this library; if not, write to the Free Software
032// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
033//
034// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
035// jataylor@hairyfatguy.com
036//------------------------------------------------------------------------------
037
038public class MeshHeading implements Comparable
039{
040   private String  mValue;
041   private String  mUniqueIdentifier;
042   private Boolean mIsMajorTopic;
043   private Set<MeshQualifier> mQualifiers;
044
045
046   //###########################################################################
047   // CONSTRUCTORS
048   //###########################################################################
049
050   //---------------------------------------------------------------------------
051   public MeshHeading(String inValue)
052   {
053      mValue = inValue;
054   }
055
056   //###########################################################################
057   // PUBLIC METHODS
058   //###########################################################################
059
060   //---------------------------------------------------------------------------
061   @Override
062   public String toString()
063   {
064      return getValue();
065   }
066
067   //---------------------------------------------------------------------------
068   @Override
069   public boolean equals(Object inObj2)
070   {
071      return (0 == compareTo(inObj2));
072   }
073
074   //---------------------------------------------------------------------------
075   @Override
076   public int hashCode()
077   {
078      int result = 1;
079
080      if (getValue() != null)
081      {
082         result = getValue().hashCode();
083      }
084
085      return result;
086   }
087
088   //---------------------------------------------------------------------------
089   @Override
090   public int compareTo(Object inObj2)
091   {
092      int result = -1;
093
094      if (inObj2 != null
095          && inObj2 instanceof MeshHeading)
096      {
097         result = CompareUtil.compare(getValue(), ((MeshHeading) inObj2).getValue());
098      }
099
100      return result;
101   }
102
103
104
105   //---------------------------------------------------------------------------
106   public String getValue()
107   {
108      return mValue;
109   }
110
111
112   //---------------------------------------------------------------------------
113   public MeshHeading setUniqueIdentifier(String inValue)
114   {
115      mUniqueIdentifier = inValue;
116      return this;
117   }
118
119   //---------------------------------------------------------------------------
120   public String getUniqueIdentifier()
121   {
122      return mUniqueIdentifier;
123   }
124
125
126   //---------------------------------------------------------------------------
127   public MeshHeading setIsMajorTopic(boolean inValue)
128   {
129      mIsMajorTopic = inValue;
130      return this;
131   }
132
133   //---------------------------------------------------------------------------
134   public Boolean isMajorTopic()
135   {
136      return mIsMajorTopic;
137   }
138
139
140   //---------------------------------------------------------------------------
141   public MeshHeading addQualifier(MeshQualifier inValue)
142   {
143      if (null == mQualifiers)
144      {
145         mQualifiers = new HashSet<>(3);
146      }
147
148      mQualifiers.add(inValue);
149      return this;
150   }
151
152   //---------------------------------------------------------------------------
153   public Set<MeshQualifier> getQualifiers()
154   {
155      return mQualifiers;
156   }
157}