Code example for Random

Methods: nextDouble, nextInt

0
 
  static final Collection<Method> getters = ReflectionTools.getGetters(WeatherReport.class);
 
  public static WeatherReportImpl generate() { 
    WeatherReportImpl weatherReport = new WeatherReportImpl();
    weatherReport.setContinent(continents[r.nextInt(continents.length)]);
    weatherReport.setLatitude(new Double(360 * r.nextDouble()));
    weatherReport.setLongitude(new Double(360 * r.nextDouble()));
    weatherReport.setReportId(r.nextInt());
    weatherReport.setReportTime(new Date(System.currentTimeMillis()));
    weatherReport.setTemperature(r.nextInt(100));
    return weatherReport;
  } 
 
  //	private Collection<WeatherEvent> weatherEvents = new GenerateInstanceCollection<WeatherEvent>(WeatherEvent.class,3).generate(); 
  private Collection<WeatherEvent> weatherEvents = new ArrayList<WeatherEvent>();
 
  @Index 
  public Collection<WeatherEvent> getWeatherEvents() {
    return weatherEvents;
  }