RandFunction implements Function<Double> { @Override public Double apply(List<Object> objects) { Optional<Long> seed = (objects.size() == 1) ? Optional.of(Long.valueOf(String.valueOf(objects.get(0)))) : Optional.empty(); Random random = (seed.isPresent()) ? new Random(seed.get()) : new Random(); return random.nextDouble(); }  @Override Set<String> validateInput(List<Object> args); @Override Class<Double> getReturnType(); @Override FunctionName getName(); @Override Double apply(List<Object> objects); @Override String getSignature(); @Override String getDescription();  }
@Test public void apply() throws Exception { assertThat(function.apply(Collections.emptyList()), not(equalTo(function.apply(Collections.emptyList())))); assertThat(function.apply(Collections.singletonList(42)), equalTo(function.apply(Collections.singletonList(42)))); }