Skip to content

Commit

Permalink
Introducing new abstract super class to allow default implementations…
Browse files Browse the repository at this point in the history
… - mirrors the preexisting abstract classes for atom/bond descriptors.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Jul 31, 2013
1 parent d138673 commit 6bd8a83
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 4 deletions.
36 changes: 36 additions & 0 deletions src/main/org/openscience/cdk/qsar/AbstractAtomPairDescriptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program 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. All we ask is that proper credit is given
* for our work, which includes - but is not limited to - adding the above
* copyright notice to the beginning of your source code files, and to any
* copyright notice that you may distribute with programs based on this work.
*
* This program 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 program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/

package org.openscience.cdk.qsar;

/**
* A super class for atom pair descriptors allowing default implementations for
* interface methods.
*
* @author John May
* @cdk.module qsar
*/
public abstract class AbstractAtomPairDescriptor extends AbstractDescriptor
implements IAtomPairDescriptor {

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
* @cdk.module qsar
* @cdk.githash
*/
public abstract class AbstractAtomicDescriptor implements IAtomicDescriptor {
public abstract class AbstractAtomicDescriptor extends AbstractDescriptor implements IAtomicDescriptor {

private static final String PREVIOUS_ATOMCONTAINER = "previousAtomContainer";

private Map cachedDescriptorValues = null;

/**
* Returns true if the cached IDescriptorResult's are for the given IAtomContainer.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.result.IDescriptorResult;

/**
Expand All @@ -40,7 +39,7 @@
* @cdk.module qsar
* @cdk.githash
*/
public abstract class AbstractBondDescriptor implements IBondDescriptor {
public abstract class AbstractBondDescriptor extends AbstractDescriptor implements IBondDescriptor {

private static final String PREVIOUS_ATOMCONTAINER = "previousAtomContainer";

Expand Down
46 changes: 46 additions & 0 deletions src/main/org/openscience/cdk/qsar/AbstractDescriptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program 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. All we ask is that proper credit is given
* for our work, which includes - but is not limited to - adding the above
* copyright notice to the beginning of your source code files, and to any
* copyright notice that you may distribute with programs based on this work.
*
* This program 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 program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/

package org.openscience.cdk.qsar;

import org.openscience.cdk.interfaces.IChemObjectBuilder;

/**
* A super class for molecular descriptors allowing default implementations for
* interface methods.
*
* @author John May
* @cdk.module qsar
*/
abstract class AbstractDescriptor implements IDescriptor {

/**
* Default implementation of initialise allows optional override.
*
* @param builder chem object build
*/
@Override public void initialise(IChemObjectBuilder builder) {
// do nothing
}

}
35 changes: 35 additions & 0 deletions src/main/org/openscience/cdk/qsar/AbstractMolecularDescriptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2013 John May <jwmay@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program 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. All we ask is that proper credit is given
* for our work, which includes - but is not limited to - adding the above
* copyright notice to the beginning of your source code files, and to any
* copyright notice that you may distribute with programs based on this work.
*
* This program 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 program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 U
*/

package org.openscience.cdk.qsar;

/**
* A super class for molecular descriptors allowing default implementations for
* interface methods.
*
* @author John May
* @cdk.module qsar
*/
public abstract class AbstractMolecularDescriptor extends AbstractDescriptor implements IMolecularDescriptor {

}
11 changes: 11 additions & 0 deletions src/main/org/openscience/cdk/qsar/IDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.openscience.cdk.IImplementationSpecification;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.qsar.result.IDescriptorResult;

/**
Expand Down Expand Up @@ -86,6 +87,16 @@
*/
public interface IDescriptor {

/**
* Initialise the descriptor with the specified chem object builder. This
* allows descriptors that required domain objects, such as for SMARTS queries
* to initialise correctly. If you do not need domain objects then this method
* does not need to be implemented.
*
* @param builder chem object builder to use with this descriptor
*/
void initialise(IChemObjectBuilder builder);

/**
* Returns a <code>IImplementationSpecification</code> which specifies which descriptor
* is implemented by this class.
Expand Down

0 comments on commit 6bd8a83

Please sign in to comment.