use of java.util.function.BiFunction in project waltz by khartec.
the class EntityStatisticGenerator method createIntStatsFor.
private void createIntStatsFor(EntityStatisticDefinition defn, Application[] applications, EntityStatisticValueDao valueDao, int bound, BiFunction<StatisticValueState, Integer, String> outcomeFn) {
Random rnd = new Random(System.currentTimeMillis());
List<EntityStatisticValue> values = streamAppRefs(applications).map(appRef -> {
StatisticValueState state = randomPick(StatisticValueState.values());
int v = state == StatisticValueState.PROVIDED ? rnd.nextInt(bound) : 0;
// naughty
v = rnd.nextInt(bound);
return ImmutableEntityStatisticValue.builder().entity(appRef).state(state).statisticId(defn.id().get()).current(true).createdAt(LocalDateTime.now()).value(Integer.toString(v)).outcome(outcomeFn.apply(state, v)).provenance(PROVENANCE).build();
}).collect(toList());
valueDao.bulkSaveValues(values);
}
Aggregations