/** * gets the specimen position from the collection. * * @param specimenPositionCollection collection of specimen position. * @param fieldValue value to be searched. * @return specimen position. */ public static SpecimenPosition getSpecimenPositionFromCollection( Collection<SpecimenPosition> specimenPositionCollection, String fieldValue) { SpecimenPosition position = null; final Iterator<SpecimenPosition> specimenPosIterator = specimenPositionCollection.iterator(); while (specimenPosIterator.hasNext()) { final SpecimenPosition specimenPosition = specimenPosIterator.next(); if (specimenPosition.getSpecimen() != null && specimenPosition.getSpecimen().getLabel() != null && specimenPosition.getSpecimen().getLabel().equals(fieldValue)) { position = specimenPosition; break; } } return position; }
/** * checks for presence of specimen. * * @param specimenPositionCollection collection of specimen position. * @param specimenLabel label of specimen to be looked for. * @return true/false result of the operation. */ public static boolean isSpecimenPresent( Collection<SpecimenPosition> specimenPositionCollection, String specimenLabel) { boolean isPresent = false; final Iterator<SpecimenPosition> specimenPosIterator = specimenPositionCollection.iterator(); while (specimenPosIterator.hasNext()) { final SpecimenPosition position = specimenPosIterator.next(); if (position != null && position.getSpecimen() != null && position.getSpecimen().getLabel().equals(specimenLabel)) { isPresent = true; break; } } return isPresent; }