This example will will check if a number is between a range of numbers using java 8 and guava.
Using java 8 LongStream, a specialized stream for dealing with primitive longs, we will call LongStream.range passing a start value of 1 and an end value of 10 to create a range between 1 and 10. Then checking if the number four is within the range by calling Stream.filter and passing in a predicate created from a lambda expression.
Guava Range class is used to create boundaries around span of values, in this case 1 - 10. By calling the Range.contains method we are able to check if the number 4 is between 1 and 10.