title: Filtering adjacent values and applying function on them
body: <p>I have list of numbers, for example 1, 5, 10, 15. Assuming these are links and current input is 1, then I would only be able to see 5, which is "next" value. When the input is 5, I would be able to see value 1, which represents "previous" and 10, which is "next". I only care about next and previous, and not anything past these or the input itself. Array is always ordered and has no duplicates.</p>
  
  <p>I am looking a nice way to find out what these next and previous values are from an integer array, and then call a function on one or both values, depending if it has 2 adjacent values or just one, if it's the first or last element.</p>
  
  <p>I've been trying to achieve something nice and fluent using Java 8 lambdas, but ended up with not very clean code.</p>
  
  <p>Anyone can advice something on this?</p>