All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.avarabyeu.jashing.demo.RandomNumberEventSource Maven / Gradle / Ivy

There is a newer version: 0.0.16
Show newest version
package com.github.avarabyeu.jashing.demo;

import com.github.avarabyeu.jashing.core.EventSource;
import com.github.avarabyeu.jashing.core.eventsource.ScheduledEventSource;
import com.github.avarabyeu.jashing.events.NumberEvent;

import java.util.Random;

/**
 * @author Andrei Varabyeu
 */
@EventSource("random-number-event-source")
public class RandomNumberEventSource extends ScheduledEventSource {

    private final Random r = new Random();

    private int lastValue;


    @Override
    protected NumberEvent produceEvent() {
        int current = r.nextInt(1000);
        int previous = this.lastValue;
        this.lastValue = current;
        return new NumberEvent(current, previous);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy