Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Return the first Sighting object from a
- * particular animal name and spotter ID.
- * @param animal The type of animal.
- * @param spotterID The ID of the spotter.
- * @return An Optional of type Sighting in the sightings collection for
- * that combination.
- */
- public Optional<Sighting> getFirstSighting(String animal, int spotterID)
- {
- return sightings.stream()
- .filter(sighting -> animal.equals(sighting.getAnimal()))
- .filter(sighting -> spotterID == sighting.getSpotter())
- .findFirst();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement