/** {@inheritDoc} */ @Override public Iterable<IIsotope> isotopes() { logger.debug("Getting isotope iterator.."); return super.isotopes(); }
/** * Get the isotope instance given an IIsotope. The instance is those * that has the isotope with the same symbol, natural abundance and * exact mass. * * @param isotope The IIsotope for looking for * @return The IIsotope instance * @see #isotopes */ private IIsotope getIsotope(IIsotope isotope) { for (IIsotope thisIsotope : isotopes()) { if (isTheSame(isotope, thisIsotope)) return thisIsotope; } return null; }
/** * Get the isotope instance given an IIsotope. The instance is those * that has the isotope with the same symbol, natural abundance and * exact mass. * * @param isotope The IIsotope for looking for * @return The IIsotope instance * @see #isotopes */ private IIsotope getIsotope(IIsotope isotope) { for (IIsotope thisIsotope : isotopes()) { if (isTheSame(isotope, thisIsotope)) return thisIsotope; } return null; }
/** * True, if the MolecularFormula contains the given IIsotope object and not * the instance. The method looks for other isotopes which has the same * symbol, natural abundance and exact mass. * * @param isotope The IIsotope this MolecularFormula is searched for * @return True, if the MolecularFormula contains the given isotope object */ @Override public boolean contains(IIsotope isotope) { for (IIsotope thisIsotope : isotopes()) { if (isTheSame(thisIsotope, isotope)) { return true; } } return false; }
/** * True, if the MolecularFormula contains the given IIsotope object and not * the instance. The method looks for other isotopes which has the same * symbol, natural abundance and exact mass. * * @param isotope The IIsotope this MolecularFormula is searched for * @return True, if the MolecularFormula contains the given isotope object */ @Override public boolean contains(IIsotope isotope) { for (IIsotope thisIsotope : isotopes()) { if (isTheSame(thisIsotope, isotope)) { return true; } } return false; }
/** * Adds an Isotope to this MolecularFormula in a number of occurrences. * * @param isotope The isotope to be added to this MolecularFormula * @param count The number of occurrences to add * @see #addIsotope(IIsotope) */ @Override public IMolecularFormula addIsotope(IIsotope isotope, int count) { boolean flag = false; for (IIsotope thisIsotope : isotopes()) { if (isTheSame(thisIsotope, isotope)) { isotopes.put(thisIsotope, isotopes.get(thisIsotope) + count); flag = true; break; } } if (!flag) { isotopes.put(isotope, count); } return this; }
/** * Adds an Isotope to this MolecularFormula in a number of occurrences. * * @param isotope The isotope to be added to this MolecularFormula * @param count The number of occurrences to add * @see #addIsotope(IIsotope) */ @Override public IMolecularFormula addIsotope(IIsotope isotope, int count) { boolean flag = false; for (IIsotope thisIsotope : isotopes()) { if (isTheSame(thisIsotope, isotope)) { isotopes.put(thisIsotope, isotopes.get(thisIsotope) + count); flag = true; break; } } if (!flag) { isotopes.put(isotope, count); } return this; }
/** * Clones this MolecularFormula object and its content. I should * integrate into ChemObject. * * @return The cloned object */ @Override public Object clone() throws CloneNotSupportedException { // /* it is not a super class of chemObject */ // MolecularFormula clone = (MolecularFormula) super.clone(); // // start from scratch // clone.removeAllIsotopes(); // // clone all isotopes // Iterator<IIsotope> iterIso = this.isotopes(); // while(iterIso.hasNext()){ // IIsotope isotope = iterIso.next(); // clone.addIsotope((IIsotope) isotope.clone(),getIsotopeCount(isotope)); // } MolecularFormula clone = new MolecularFormula(); for (IIsotope isotope : isotopes()) { clone.addIsotope((IIsotope) isotope.clone(), getIsotopeCount(isotope)); } clone.setCharge(getCharge()); return clone; }
/** * Clones this MolecularFormula object and its content. I should * integrate into ChemObject. * * @return The cloned object */ @Override public Object clone() throws CloneNotSupportedException { // /* it is not a super class of chemObject */ // MolecularFormula clone = (MolecularFormula) super.clone(); // // start from scratch // clone.removeAllIsotopes(); // // clone all isotopes // Iterator<IIsotope> iterIso = this.isotopes(); // while(iterIso.hasNext()){ // IIsotope isotope = iterIso.next(); // clone.addIsotope((IIsotope) isotope.clone(),getIsotopeCount(isotope)); // } MolecularFormula clone = new MolecularFormula(); for (IIsotope isotope : isotopes()) { clone.addIsotope((IIsotope) isotope.clone(), getIsotopeCount(isotope)); } clone.setCharge(getCharge()); return clone; }