/** * Add <code>count</code> H2 isotpes * * @param count the number of H2 to add * @return this builder */ public final FragBuilder addH2(int count) { compositionBuilder.add(periodicTable.getAtom(AtomicSymbol.H, 2), count); return this; }
/** GlycanFragAnnotation Builder */ public static class FragBuilder { static final PeriodicTable periodicTable = PeriodicTable.getInstance(); private final int charge; private GlycanFragment fragment; private Mass neutralLoss = Mass.ZERO; private final Composition.Builder compositionBuilder = new Composition.Builder(); /** * Construct a new FragBuilder * * @param charge the charge * @param fragment the glycan fragment */ public FragBuilder(int charge, GlycanFragment fragment) { checkNotNull(fragment); this.charge = charge; this.fragment = fragment; } /** * Copy constructor * * @param src the GlycanFragAnnotation from which to copy the values */ public FragBuilder(GlycanFragAnnotation src) { this.charge = src.getCharge(); this.fragment = src.getFragment(); } /** * Set the neutral loss * * @param neutralLoss the neutral loss * @return this builder */ public final FragBuilder setNeutralLoss(Mass neutralLoss) { this.neutralLoss = neutralLoss; return this; } /** * Add <code>count</code> C13 isotopes * * @param count the number of C13 isotopes * @return this builder */ public final FragBuilder addC13(int count) { compositionBuilder.add(periodicTable.getAtom(AtomicSymbol.C, 13), count); return this; } /** * Add <code>count</code> H2 isotpes * * @param count the number of H2 to add * @return this builder */ public final FragBuilder addH2(int count) { compositionBuilder.add(periodicTable.getAtom(AtomicSymbol.H, 2), count); return this; } /** * Add the <code>isotope</code> * * @param isotope the isotope to add * @return this builder */ public final FragBuilder addIsotope(Atom isotope) { checkArgument(!isotope.isDefaultIsotope()); compositionBuilder.add(isotope, 1); return this; } /** * Add all the atoms from <code>isotopeComposition</code> * * @param isotopeComposition the atoms to add * @return this builder */ public final FragBuilder addIsotopeComposition(Composition isotopeComposition) { compositionBuilder.addAll(isotopeComposition); return this; } /** * Build the CrossRingFragAnnotation annotation. * * @return the new CrossRingFragAnnotation */ public final GlycanFragAnnotation build() { Composition fragIsotopeComposition = compositionBuilder.isEmpty() ? GlycanFragAnnotation.EMPTY_COMPOSITION : compositionBuilder.build(); return new GlycanFragAnnotation(charge, fragment, fragIsotopeComposition, neutralLoss); } }