class Filter {

    public static Function<Beacon, Boolean> proximityIsEqualTo(final Proximity... proximities) {
        return new Function<Beacon, Boolean>() {
            @Override
            public Boolean apply(Beacon beacon) {
                for (Proximity proximity : proximities) {
                    if (beacon.getProximity() == proximity) {
                        return true;
                    }
                }

                return false;
            }
        };
    }

}

class FilterTest {

  @Test
  public void proximityShouldBeEqualToImmediateAndNear() {

    // given
    Beacon beacon = Mockito.mock(Beacon.class);

    // when
    when(beacon.getProximity()).then(new Answer<Proximity>() {
      @Override
      public Proximity answer(InvocationOnMock invocationOnMock) throws Throwable {
        return Proximity.NEAR;
      }
    });

    Function<Beacon, Boolean> filter =
        Filter.proximityIsEqualTo(Proximity.IMMEDIATE, Proximity.NEAR);
    Boolean call = apply(filter, beacon);

    // then
    assertThat(call).isTrue();
  }

}