public static boolean compare ( IMolecularFormula formula1 , IMolecularFormula formula2 ) { if ( ! Objects . equals ( formula1 . getCharge ( ) , formula2 . getCharge ( ) ) ) return false ; if ( formula1 . getIsotopeCount ( ) != formula2 . getIsotopeCount ( ) ) return false ; for ( IIsotope isotope : formula1 . isotopes ( ) ) { if ( ! formula2 . contains ( isotope ) ) return false ; if ( formula1 . getIsotopeCount ( isotope ) != formula2 . getIsotopeCount ( isotope ) ) return false ; } for ( IIsotope isotope : formula2 . isotopes ( ) ) { if ( ! formula1 . contains ( isotope ) ) return false ; if ( formula2 . getIsotopeCount ( isotope ) != formula1 . getIsotopeCount ( isotope ) ) return false ; } return true ; }
Compare two IMolecularFormula looking at type and number of IIsotope and charge of the formula .