Advertisement
Guest User

Untitled

a guest
Apr 11th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1.     /**
  2.      * Return the first Sighting object from a
  3.      * particular animal name and spotter ID.
  4.      * @param animal The type of animal.
  5.      * @param spotterID The ID of the spotter.
  6.      * @return An Optional of type Sighting in the sightings collection for
  7.      * that combination.
  8.      */
  9.     public Optional<Sighting> getFirstSighting(String animal, int spotterID)
  10.     {
  11.         return sightings.stream()
  12.             .filter(sighting -> animal.equals(sighting.getAnimal()))
  13.             .filter(sighting -> spotterID == sighting.getSpotter())
  14.             .findFirst();
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement