@Override public List<Event> getNextEvents(Event event) { // Randomly choose a redirect RedirectEventProducer redirect = selector.next(); if (redirect == null) { return Collections.emptyList(); } else { return redirect.getNextEvents(event); } }
/** @param eventWeights list of events weights to select from */ public RandomRedirectEventProducer(List<EventWeight> eventWeights) { for (EventWeight eventWeight : eventWeights) { String eventName = eventWeight.getEventName(); if (eventName == null || eventName.length() == 0) { throw new RuntimeException("No event name provided."); } double weight = eventWeight.getWeight(); // Construct a redirector for this RedirectEventProducer redirect = new RedirectEventProducer(eventName); selector.add(weight, redirect); } }