1 /* Copyright (C) 2004-2007  The Chemistry Development Kit (CDK) project
2  *               2013       European Bioinformatics Institute
3  *                         John May
4  *
5  * Contact: cdk-devel@lists.sourceforge.net
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 package org.openscience.cdk.isomorphism.matchers.smarts;
22 
23 import org.openscience.cdk.interfaces.IAtom;
24 import org.openscience.cdk.interfaces.IChemObjectBuilder;
25 
26 /**
27  * SMARTS query atom for matching the total hydrogen count. This count is
28  * specified in SMARTS using {@code H<NUMBER>}.
29  *
30  * @cdk.module  smarts
31  * @cdk.keyword SMARTS
32  * @cdk.githash
33  */
34 @Deprecated
35 public final class TotalHCountAtom extends SMARTSAtom {
36 
37     /** The total hydrogen count to match. */
38     private final int totalHCount;
39 
TotalHCountAtom(int totalHCount, IChemObjectBuilder builder)40     public TotalHCountAtom(int totalHCount, IChemObjectBuilder builder) {
41         super(builder);
42         this.totalHCount = totalHCount;
43     }
44 
45     /**
46      * Check if the total hydrogen count of the {@code atom} is equal to the
47      * query.
48      *
49      * @param atom the atom to match
50      * @return the hydrogen count matches
51      */
52     @Override
matches(final IAtom atom)53     public boolean matches(final IAtom atom) {
54         return invariants(atom).totalHydrogenCount() == totalHCount;
55     }
56 
57     /**{@inheritDoc} */
58     @Override
toString()59     public String toString() {
60         return "H" + totalHCount;
61     }
62 }
63