private List<Company> createCompanies(Random r) { List<Company> result = new ArrayList<Company>(); for (int i = 0; i < 50; i++) { Company com = new Company(String.valueOf(i), "Company " + (i + 1)); com.setFocusedSectors(new ArrayList<Sector>()); Set<Person> uniqueWorkers = new HashSet<Person>(); for (int j = 0; j < r.nextInt(20); j++) { Person worker = persons.get(r.nextInt(persons.size())); worker.getCompanies().add(com); uniqueWorkers.add(worker); } com.setWorkers(new ArrayList<Person>(uniqueWorkers)); result.add(com); } return result; }
private static List<Person> createPersons(Random r) { List<Person> result = new ArrayList<Person>(); String[] firstNames = new String[] {"Ivan", "Peter", "Sidor", "Vasil", "Urij", "Alex"}; String[] secondNames = new String[] {"Ivanov", "Petrov", "Sidorov", "Vasiljev", "Urijev", "Alexandrov", "Shulc"}; String[] descriptions = new String[] {"Student", "Professor", "Worker", "Driver", "Gardener"}; for (int i = 0; i < 100; i++) { Person person = new Person( String.valueOf(i), firstNames[r.nextInt(firstNames.length)], secondNames[r.nextInt(secondNames.length)], descriptions[r.nextInt(descriptions.length)]); person.setCompanies(new ArrayList<Company>()); result.add(person); } return result; }