class OxygenAtomCountDescriptor implements ISubstanceDescriptor {

	@Override
	public DescriptorValue calculate(ISubstance substance) {
        int count = 0;
        if (substance != null) {
            for (IAtomContainer container : substance.atomContainers()) {
                for (IAtom atom : container.atoms()) {
                    if ("O".equals(atom.getSymbol()) || 8 == atom.getAtomicNumber())
                        count++;
                }
            }
        }

		return new DescriptorValue(
		    getSpecification(), getParameterNames(), getParameters(),
		    new IntegerResult(count), getDescriptorNames()
		);
	}

}